/* ==========================================================================
   军训 · 只有一道门 —— 界面样式
   配色取军训现场：迷彩绿 / 军毯黄 / 警戒红 / 报话机米色
   ========================================================================== */

:root {
  --ink: #f2f0e4;
  --ink-dim: #b9bda8;
  --paper: #eff0e3;
  --camo-1: #1b2417;
  --camo-2: #22301d;
  --camo-3: #2f4026;
  --camo-4: #3d5231;
  --khaki: #cdb377;
  --khaki-deep: #9c8348;
  --alert: #d4573f;
  --alert-deep: #9c3324;
  --ok: #7fae62;
  --sky: #cfe0ea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px rgba(6, 12, 6, 0.45);
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(141, 176, 106, 0.18), transparent 60%),
    radial-gradient(900px 500px at 92% 8%, rgba(205, 179, 119, 0.14), transparent 55%),
    linear-gradient(168deg, #111a10 0%, #16210f 42%, #0d1309 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 16px 26px;
}

/* ------------------------------- 顶栏 ---------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #27331d;
  background: linear-gradient(180deg, var(--khaki) 0%, var(--khaki-deep) 100%);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--paper);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------- 按钮 ---------------------------------- */

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(1px) scale(0.995); }
.btn:focus-visible { outline: 2px solid var(--khaki); outline-offset: 2px; }

.btn-primary {
  color: #1d2715;
  background: linear-gradient(180deg, #e2c988 0%, var(--khaki-deep) 100%);
  box-shadow: 0 3px 0 #5c4c26, var(--shadow);
}
.btn-primary:hover { background: linear-gradient(180deg, #efd79a 0%, #ac8f4d 100%); }

.btn-outline {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(205, 179, 119, 0.4);
}
.btn-outline:hover { background: rgba(205, 179, 119, 0.14); border-color: var(--khaki); }

.btn-ghost {
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.09);
  font-size: 13px;
  padding: 7px 12px;
}
.btn-ghost:hover { color: var(--ink); background: rgba(255, 255, 255, 0.09); }
.btn-ghost[aria-pressed="false"] { color: #8d9182; }

.btn-lg { font-size: 17px; padding: 13px 30px; letter-spacing: 2px; }
.btn-mini { font-size: 12px; padding: 5px 11px; border-radius: 7px; }

/* ------------------------------- 舞台 ---------------------------------- */

.stage { display: block; }

.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0c1108;
  border: 1px solid rgba(205, 179, 119, 0.28);
  box-shadow: var(--shadow);
  /* 手机端：不要让滑动页面、双击缩放把摇杆操作抢走 */
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.footnote {
  margin: 12px 4px 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: #8f9481;
  text-align: center;
}

.footnote .ver {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(205, 179, 119, 0.16);
  border: 1px solid rgba(205, 179, 119, 0.4);
  color: var(--khaki);
  font-weight: 700;
  letter-spacing: 1px;
}

/* ------------------------------- HUD ----------------------------------- */

.hud {
  position: absolute;
  inset: 10px 12px auto 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  font-size: clamp(11px, 1.35vw, 14px);
}
.hud > * { pointer-events: auto; }

.hud-left { display: flex; gap: 6px; flex-wrap: wrap; }
.hud-right { display: flex; gap: 6px; align-items: center; }

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(10, 16, 8, 0.62);
  border: 1px solid rgba(205, 179, 119, 0.28);
  color: var(--ink);
  backdrop-filter: blur(3px);
}

.hud-key { color: var(--ink-dim); font-size: 0.86em; letter-spacing: 1px; }
.hud-chip b { font-variant-numeric: tabular-nums; color: var(--khaki); }

.hud-center {
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(10, 16, 8, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--paper);
  font-weight: 700;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}

/* --------------------------- 提示条 / 横幅 ------------------------------ */

.toast {
  position: absolute;
  left: 50%;
  bottom: 16%;
  transform: translateX(-50%);
  max-width: 82%;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(12, 20, 10, 0.86);
  border: 1px solid rgba(205, 179, 119, 0.4);
  color: var(--paper);
  font-size: clamp(12px, 1.5vw, 16px);
  font-weight: 600;
  text-align: center;
  animation: toastIn 0.28s ease;
  pointer-events: auto; /* 点一下可收起 */
  cursor: pointer;
}
.toast.warn { border-color: rgba(212, 87, 63, 0.75); color: #ffd8cd; }
.toast.good { border-color: rgba(127, 174, 98, 0.8); color: #e2f5d4; }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* 开场/过关横幅：只是一条不挡视线的提示条，绝不再遮住整个画面 */
.cleared-banner {
  position: absolute;
  inset: 0;
  pointer-events: none; /* 整块不吃点击，操作不被挡 */
  cursor: pointer;
  background: none;
  border: none;
}
.cleared-banner > span {
  pointer-events: auto; /* 只有这条提示本身可以点（点一下收起） */
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  max-width: 88%;
  padding: 10px 26px;
  border-radius: 999px;
  background: rgba(8, 14, 6, 0.76);
  border: 1px solid rgba(205, 179, 119, 0.55);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  color: var(--khaki);
  font-size: clamp(17px, 3vw, 30px);
  font-weight: 900;
  letter-spacing: 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: toastIn 0.3s ease;
}
/* 手机端操作（虚拟摇杆 + 跳跃键）直接画在 canvas 里，见 game.js 的 drawTouchControls，
   所以这里不再需要 HTML 触屏按钮的样式 */
/* ------------------------------ 浮层面板 ------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3% 4%;
  background: linear-gradient(180deg, rgba(9, 15, 7, 0.88), rgba(9, 15, 7, 0.94));
  overflow: auto;
  z-index: 5;
}
.overlay[hidden] { display: none; }
.overlay-dim { background: rgba(9, 15, 7, 0.82); }

.panel {
  width: min(660px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: clamp(16px, 2.6vw, 30px);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(38, 51, 30, 0.96), rgba(24, 34, 19, 0.98));
  border: 1px solid rgba(205, 179, 119, 0.34);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: panelIn 0.24s ease;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.panel-wide { width: min(860px, 100%); }
.panel-small { width: min(400px, 100%); text-align: center; }
.panel-menu { text-align: center; }

.panel h1 {
  margin: 6px 0 10px;
  font-size: clamp(24px, 4.6vw, 46px);
  letter-spacing: 8px;
  color: var(--paper);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}
.panel h2 {
  margin: 4px 0 12px;
  font-size: clamp(19px, 2.8vw, 28px);
  letter-spacing: 3px;
  color: var(--khaki);
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--khaki);
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 3px;
  color: #98a084;
  text-transform: uppercase;
}

.lead {
  margin: 0 auto 16px;
  max-width: 46em;
  font-size: clamp(13px, 1.6vw, 15.5px);
  line-height: 1.85;
  color: #d7dac7;
  text-align: center;
}
.lead.small { font-size: 13.5px; text-align: center; }
.lead strong { color: var(--khaki); }

/* -------------------------------- 表单 --------------------------------- */

.field { margin: 14px auto 18px; max-width: 420px; text-align: left; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  letter-spacing: 2px;
  color: #9ba287;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--paper);
  background: rgba(10, 16, 8, 0.6);
  border: 1px solid rgba(205, 179, 119, 0.35);
  border-radius: var(--radius-sm);
}
.field input:focus { outline: none; border-color: var(--khaki); background: rgba(10, 16, 8, 0.85); }
.field input::placeholder { color: #767c68; }

/* ------------------------------- 布局块 -------------------------------- */

.menu-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.panel-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.panel-actions.column { flex-direction: column; align-items: stretch; }
.panel-small .panel-actions { justify-content: center; }

.tips {
  margin: 16px auto 0;
  padding: 0;
  list-style: none;
  max-width: 52em;
  text-align: left;
  font-size: 13px;
  line-height: 1.95;
  color: #b8bda7;
}
.tips li { position: relative; padding-left: 16px; }
.tips li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--khaki-deep);
  transform: rotate(45deg);
}
.tips b { color: var(--paper); }
.tips em { color: #efc9a0; font-style: normal; }
.tips strong { color: #ffd9a8; }

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 22px;
  margin-top: 10px;
}
.help-grid .tips { margin-top: 4px; }

/* ------------------------------ 关卡预习 ------------------------------- */

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(228px, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.level-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(10, 16, 8, 0.45);
  border: 1px solid rgba(205, 179, 119, 0.22);
  text-align: left;
}
.level-card h4 {
  margin: 0 0 4px;
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--paper);
}
.level-card .idx {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  color: #25301a;
  background: var(--khaki);
}
.level-card p { margin: 6px 0 0; font-size: 12.5px; line-height: 1.75; color: #adb39c; }
.level-card .tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #d3d8c4;
}
.tag.real { border-color: rgba(212, 87, 63, 0.6); color: #f2b6a8; }
.tag.fake { border-color: rgba(127, 174, 98, 0.6); color: #c6e2b3; }

/* ------------------------------- 成绩榜 -------------------------------- */

.table-wrap {
  max-height: 46vh;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(205, 179, 119, 0.22);
  margin-top: 8px;
}
.board { width: 100%; border-collapse: collapse; font-size: 13px; }
.board th, .board td { padding: 9px 10px; text-align: left; white-space: nowrap; }
.board thead th {
  position: sticky;
  top: 0;
  background: #26331d;
  color: var(--khaki);
  font-weight: 700;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(205, 179, 119, 0.3);
}
.board tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.035); }
.board tbody tr.me { background: rgba(205, 179, 119, 0.16); }
.board td { color: #d3d8c4; font-variant-numeric: tabular-nums; }
.board td.rank { color: var(--khaki); font-weight: 800; }
.board .empty { padding: 22px; text-align: center; color: #8f9481; }

/* ------------------------------- 结算页 -------------------------------- */

.score-ring {
  width: clamp(110px, 15vw, 158px);
  height: clamp(110px, 15vw, 158px);
  margin: 6px auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  background:
    radial-gradient(circle at 50% 42%, rgba(205, 179, 119, 0.2), transparent 62%),
    rgba(10, 16, 8, 0.6);
  border: 3px solid var(--khaki-deep);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.5);
}
.score-ring span {
  font-size: clamp(34px, 5.2vw, 58px);
  font-weight: 900;
  color: var(--khaki);
  font-variant-numeric: tabular-nums;
  align-self: center;
  line-height: 1;
}
.score-ring small { color: #9ba287; font-size: 13px; align-self: center; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  margin: 14px 0 6px;
}
.stat {
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: rgba(10, 16, 8, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.stat b { display: block; font-size: 19px; color: var(--paper); font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: #98a084; letter-spacing: 1px; }

.breakdown {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.9;
  color: #98a084;
}
.upload-state { margin: 10px 0 0; min-height: 20px; font-size: 13px; color: var(--ok); }
.upload-state.err { color: #ef9c86; }

/* ------------------------------- 小屏适配 ------------------------------ */

@media (max-width: 720px) {
  #app { padding: 8px 8px 18px; }
  .brand-title { font-size: 16px; letter-spacing: 2px; }
  .brand-badge { font-size: 11px; }
  .topbar-actions .btn { font-size: 12px; padding: 6px 10px; }
  .footnote { font-size: 11.5px; }
  .hud { inset: 6px 8px auto 8px; }
  .hud-center { display: none; }
  .tbtn { width: 56px; height: 56px; font-size: 19px; }
  .board th:nth-child(5), .board td:nth-child(5),
  .board th:nth-child(6), .board td:nth-child(6),
  .board th:nth-child(7), .board td:nth-child(7) { display: none; }
}

@media (max-width: 420px) {
  .field { margin: 10px auto 14px; }
  .menu-actions .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
