/* ============================================================================
 * 军训跑酷 · 三连的荣耀 —— 样式表
 * 主题：迷彩绿 + 卡其 + 军训红
 * ==========================================================================*/

:root {
  --camo-900: #101a09;
  --camo-800: #1d2a10;
  --camo-700: #33421d;
  --camo-600: #4c6128;
  --camo-500: #6b8339;
  --khaki: #ece2c0;
  --khaki-dim: #b9ae86;
  --red: #c62828;
  --red-light: #ff6659;
  --gold: #ffca28;
  --ink: #0a0f06;
  --panel-bg: linear-gradient(160deg, rgba(38, 52, 22, 0.97), rgba(16, 24, 10, 0.98));
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  color: var(--khaki);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system,
    "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 620px at 50% -10%, #34461f 0%, #1b2610 45%, #0b1106 100%);
}

/* 迷彩斑块背景 */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 20% 30%, #3f5123 0 70px, transparent 71px),
    radial-gradient(circle at 72% 62%, #2f3d1a 0 100px, transparent 101px),
    radial-gradient(circle at 44% 88%, #4a5c28 0 80px, transparent 81px),
    radial-gradient(circle at 88% 18%, #35441d 0 60px, transparent 61px);
  background-size: 420px 420px, 560px 560px, 380px 380px, 300px 300px;
  filter: blur(3px);
  animation: camoDrift 40s linear infinite alternate;
}

@keyframes camoDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-30px, 20px, 0) scale(1.06); }
}

/* ============================================================================
 * 舞台
 * ==========================================================================*/
.stage {
  position: relative;
  width: min(100%, 1120px);
  aspect-ratio: 960 / 600;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 2px rgba(236, 226, 192, 0.14) inset;
  background: #0b1106;
  isolation: isolate;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================================
 * 顶部 HUD
 * ==========================================================================*/
.hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  pointer-events: none;
  z-index: 4;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.hud-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 148px;
  padding: 8px 14px 9px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(20, 28, 12, 0.82), rgba(10, 16, 6, 0.72));
  border: 1px solid rgba(236, 226, 192, 0.18);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.hud-card.slim {
  min-width: 112px;
}

.hud-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--khaki-dim);
}

.hud-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 15px;
  color: var(--khaki);
}

.hud-value b {
  font-size: 26px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #fff3c4;
  text-shadow: 0 0 14px rgba(255, 202, 40, 0.45);
  transition: transform 0.12s ease;
}

.hud-value b.pop {
  transform: scale(1.14);
}

.hud-value i {
  font-style: normal;
  font-size: 12px;
  color: var(--khaki-dim);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 19px;
  cursor: pointer;
  color: var(--khaki);
  background: rgba(12, 18, 8, 0.72);
  border: 1px solid rgba(236, 226, 192, 0.2);
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover { transform: translateY(-2px); background: rgba(40, 56, 22, 0.9); }
.icon-btn.off { opacity: 0.5; }

/* ============================================================================
 * 教官警告条
 * ==========================================================================*/
.coach-warn {
  position: absolute;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 84%);
  padding: 10px 16px 12px;
  border-radius: 14px;
  text-align: center;
  background: linear-gradient(160deg, rgba(140, 20, 20, 0.94), rgba(70, 8, 8, 0.94));
  border: 1px solid rgba(255, 120, 100, 0.55);
  box-shadow: 0 0 30px rgba(198, 40, 40, 0.55);
  animation: warnIn 0.28s cubic-bezier(0.2, 1.4, 0.5, 1), warnPulse 0.9s ease-in-out infinite 0.28s;
  z-index: 5;
}

@keyframes warnIn {
  from { transform: translate(-50%, -26px) scale(0.9); opacity: 0; }
  to   { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

@keyframes warnPulse {
  0%, 100% { box-shadow: 0 0 26px rgba(198, 40, 40, 0.45); }
  50%      { box-shadow: 0 0 44px rgba(255, 90, 70, 0.8); }
}

.coach-warn-text {
  font-size: 15px;
  font-weight: 700;
  color: #ffe9e5;
  letter-spacing: 1px;
}

.coach-warn-text em {
  font-style: normal;
  color: #ffd166;
}

.coach-warn-bar {
  margin-top: 8px;
  height: 7px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
}

.coach-warn-bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #ffd166, #ff6659);
  transition: width 0.1s linear;
}

/* ============================================================================
 * 遮罩层与面板
 * ==========================================================================*/
.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: radial-gradient(circle at 50% 40%, rgba(10, 16, 6, 0.55), rgba(6, 10, 4, 0.9));
  backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease both;
  overflow: auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.panel {
  position: relative;
  width: min(720px, 100%);
  padding: 26px 30px 24px;
  border-radius: 20px;
  background: var(--panel-bg);
  border: 1px solid rgba(236, 226, 192, 0.2);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.4) inset;
  animation: panelIn 0.34s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

@keyframes panelIn {
  from { transform: translateY(18px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.panel::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 15px;
  border: 1px dashed rgba(236, 226, 192, 0.16);
  pointer-events: none;
}

.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--gold);
  text-transform: uppercase;
}

.title {
  margin: 0 0 6px;
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: 3px;
  color: #fff8e1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 30px rgba(255, 202, 40, 0.25);
}

.title span {
  display: block;
  font-size: 20px;
  letter-spacing: 8px;
  color: var(--camo-500);
  text-shadow: none;
  margin-top: 6px;
}

.title.small { font-size: 30px; letter-spacing: 4px; }

.subtitle {
  margin: 10px 0 16px;
  font-size: 14px;
  color: var(--khaki-dim);
}

/* ---------- 规则列表 ---------- */
.rules {
  margin: 0 0 20px;
  padding: 14px 16px 14px 18px;
  list-style: none;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border-left: 3px solid var(--camo-500);
  font-size: 13.5px;
  line-height: 2;
  color: #ddd3ac;
}

.rules li { display: flex; align-items: center; gap: 8px; }
.rules b {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  margin: 0 2px;
  border-radius: 5px;
  text-align: center;
  background: rgba(236, 226, 192, 0.14);
  border: 1px solid rgba(236, 226, 192, 0.25);
  color: #fff;
  font-size: 12.5px;
}

.dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}
.dot.red    { background: var(--red-light); color: var(--red-light); }
.dot.white  { background: #f2f2f2; color: #f2f2f2; }
.dot.green  { background: #8fd07a; color: #8fd07a; }
.dot.wood   { background: #e0a94f; color: #e0a94f; }
.dot.steel  { background: #c3ccd6; color: #c3ccd6; }
.dot.gold   { background: var(--gold); color: var(--gold); }
.dot.danger { background: var(--red); color: var(--red); }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 2px;
  color: #16200c;
  padding: 12px 26px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #d8e6a8, #a9bd6a);
  box-shadow: 0 6px 0 #55692c, 0 12px 26px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #55692c, 0 6px 14px rgba(0, 0, 0, 0.4); }

.btn.primary {
  background: linear-gradient(180deg, #ffe082, #f0a91e);
  color: #2a1c02;
  box-shadow: 0 6px 0 #9c6a08, 0 12px 26px rgba(0, 0, 0, 0.4);
}
.btn.primary:active { box-shadow: 0 2px 0 #9c6a08, 0 6px 14px rgba(0, 0, 0, 0.4); }

.btn.red {
  background: linear-gradient(180deg, #ff8a76, #d32f2f);
  color: #fff;
  box-shadow: 0 6px 0 #7f1414, 0 12px 26px rgba(0, 0, 0, 0.4);
}

.btn.ghost {
  background: transparent;
  color: var(--khaki);
  border: 1px solid rgba(236, 226, 192, 0.3);
  box-shadow: none;
}
.btn.ghost:active { transform: translateY(2px); }

.btn.big {
  width: 100%;
  padding: 16px 26px;
  font-size: 18px;
  letter-spacing: 6px;
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 6px 0 #9c6a08, 0 12px 26px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(255, 202, 40, 0.5); }
  50%      { box-shadow: 0 6px 0 #9c6a08, 0 12px 26px rgba(0, 0, 0, 0.4), 0 0 0 12px rgba(255, 202, 40, 0); }
}

.btn.small { padding: 10px 18px; font-size: 13px; letter-spacing: 1px; }

.hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--khaki-dim);
  letter-spacing: 1px;
}

/* ---------- 结算 ---------- */
.result-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 16px 0 12px;
}

.result-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(236, 226, 192, 0.16);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-card span { font-size: 12px; letter-spacing: 2px; color: var(--khaki-dim); }
.result-card strong {
  font-size: 30px;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.result-card strong i { font-style: normal; }
.result-card strong u { font-size: 13px; text-decoration: none; color: var(--khaki-dim); margin-left: 4px; }

.result-card.gold {
  border-color: rgba(255, 202, 40, 0.45);
  background: linear-gradient(160deg, rgba(255, 202, 40, 0.16), rgba(0, 0, 0, 0.34));
}
.result-card.gold strong { color: var(--gold); text-shadow: 0 0 18px rgba(255, 202, 40, 0.5); }
.result-card.gold.flash { animation: recordFlash 1.1s ease-in-out 2; }

@keyframes recordFlash {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 202, 40, 0); }
  50%      { box-shadow: 0 0 28px rgba(255, 202, 40, 0.85); }
}

.new-record {
  margin: 0 0 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
  animation: recordPop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

@keyframes recordPop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.submit-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.submit-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--khaki);
  border-radius: 12px;
  border: 1px solid rgba(236, 226, 192, 0.24);
  background: rgba(0, 0, 0, 0.35);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.submit-row input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 202, 40, 0.18);
}
.submit-row input::placeholder { color: rgba(185, 174, 134, 0.7); }

.board {
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(236, 226, 192, 0.14);
  margin-bottom: 18px;
}

.board-title {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 8px;
}

.board-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 208px;
  overflow: auto;
}

.board-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 13.5px;
  color: #ded4ae;
  animation: rowIn 0.3s ease both;
}

@keyframes rowIn {
  from { transform: translateX(-8px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.board-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.035); }
.board-list li .rank {
  flex: 0 0 26px;
  text-align: center;
  font-weight: 700;
  color: var(--khaki-dim);
}
.board-list li.top1 .rank { color: #ffd54f; }
.board-list li.top2 .rank { color: #e0e0e0; }
.board-list li.top3 .rank { color: #ffab73; }
.board-list li .who {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-list li .val {
  font-variant-numeric: tabular-nums;
  color: #fff3c4;
  font-weight: 700;
}
.board-list li.me {
  background: rgba(255, 202, 40, 0.14);
  box-shadow: 0 0 0 1px rgba(255, 202, 40, 0.35) inset;
}
.board-list li.empty {
  justify-content: center;
  color: var(--khaki-dim);
  font-size: 13px;
  padding: 16px 0;
}

.panel-actions {
  display: flex;
  gap: 12px;
}
.panel-actions .btn { flex: 1; }

/* ============================================================================
 * 触屏方向键
 * ==========================================================================*/
.touch-pad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.touch-pad button {
  pointer-events: auto;
  width: 74px;
  height: 66px;
  border-radius: 16px;
  font-size: 20px;
  font-family: inherit;
  font-weight: 700;
  color: #f3ecd0;
  background: rgba(16, 24, 10, 0.6);
  border: 1px solid rgba(236, 226, 192, 0.3);
  backdrop-filter: blur(4px);
  transition: transform 0.08s ease, background 0.08s ease;
}
.touch-pad button:active { transform: scale(0.94); background: rgba(107, 131, 57, 0.75); }
.touch-mid { display: flex; gap: 12px; }

/* ============================================================================
 * 工具类 & 响应式
 * ==========================================================================*/
.hidden { display: none !important; }

@media (max-width: 720px) {
  body { padding: 8px; }
  .stage { border-radius: 12px; }
  .hud { padding: 10px; }
  .hud-card { min-width: 118px; padding: 6px 10px 7px; }
  .hud-card.slim { min-width: 92px; }
  .hud-value b { font-size: 20px; }
  .hud-value i, .hud-label { font-size: 10px; }
  .panel { padding: 20px 18px 18px; }
  .title { font-size: 28px; letter-spacing: 2px; }
  .title span { font-size: 14px; letter-spacing: 4px; }
  .title.small { font-size: 22px; }
  .rules { font-size: 12px; line-height: 1.9; padding: 10px 12px; }
  .result-card strong { font-size: 22px; }
  .coach-warn { top: 78px; font-size: 12px; }
  .coach-warn-text { font-size: 12.5px; }
  .touch-pad button { width: 62px; height: 56px; font-size: 17px; }
}

@media (max-height: 560px) {
  .rules { display: none; }
}

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