/* =========================================================================
 * 轨道无限跑酷 · 样式
 * 深色霓虹、单手可玩、刘海安全区适配
 * ========================================================================= */

:root {
  --bg: #05060f;
  --ink: #eaf2ff;
  --muted: #8ea0c0;
  --cyan: #5ad1ff;
  --amber: #ffd166;
  --orange: #ff6b3d;
  --violet: #b78cff;
  --line: rgba(120, 200, 255, 0.16);
  --panel: linear-gradient(180deg, rgba(20, 24, 46, 0.96), rgba(9, 11, 22, 0.98));
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #10152c 0%, #05060f 60%);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

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

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) 0 calc(14px + var(--safe-l));
}

.hud-left .score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

#score {
  font-size: clamp(28px, 5.2vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 2px 18px rgba(90, 209, 255, 0.35);
}

.hud-left .unit {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.1em;
}

.meta-row {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.meta-row .sep { opacity: 0.5; }

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

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(10, 14, 28, 0.62);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  backdrop-filter: blur(6px);
}

.stat.small { font-size: 11px; font-weight: 600; color: var(--muted); }
.stat .ico { color: var(--amber); font-size: 11px; }

.icon-btn {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 28, 0.62);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.icon-btn:active { transform: scale(0.95); }

.effects {
  position: absolute;
  top: calc(64px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90vw;
}

.chip {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 24, 0.7);
  font-variant-numeric: tabular-nums;
}
.chip.shield { color: var(--cyan); border-color: rgba(90, 209, 255, 0.45); }
.chip.magnet { color: var(--violet); border-color: rgba(183, 140, 255, 0.45); }
.chip.double { color: var(--amber); border-color: rgba(255, 209, 102, 0.45); }
.chip.combo { color: #fff; border-color: rgba(255, 255, 255, 0.35); }

.items {
  position: absolute;
  left: calc(14px + var(--safe-l));
  bottom: calc(16px + var(--safe-b));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.item-slot {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px dashed rgba(120, 200, 255, 0.22);
  background: rgba(8, 12, 24, 0.55);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, border-color 0.2s ease;
}
.item-slot.filled {
  border-style: solid;
  border-color: rgba(120, 200, 255, 0.42);
  background: rgba(16, 22, 42, 0.82);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.item-slot.filled:active { transform: scale(0.92); }
.item-slot .glyph { font-weight: 800; font-size: 16px; }
.item-slot .count {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px #000;
}
.item-slot[disabled] { cursor: default; opacity: 0.45; }

/* ---------------- 倒数 / 吐司 ---------------- */

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(72px, 16vw, 140px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(90, 209, 255, 0.7), 0 8px 40px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 8;
  letter-spacing: -0.04em;
}

.countdown.pop { animation: pop 0.32s cubic-bezier(0.2, 0.9, 0.2, 1); }

@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 0.95; }
}

.toast {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 4px 24px rgba(90, 209, 255, 0.6);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 9;
}
.toast.show { opacity: 1; transform: translate(-50%, -62%); }

/* ---------------- 屏幕 ---------------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(18px + var(--safe-t)) 18px calc(18px + var(--safe-b));
  background: radial-gradient(90% 70% at 50% 30%, rgba(9, 12, 26, 0.55), rgba(3, 4, 10, 0.9));
  backdrop-filter: blur(3px);
  z-index: 10;
  overflow-y: auto;
}

.menu-card, .panel {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 24px 22px;
  box-shadow: var(--shadow);
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.panel { width: min(420px, 100%); text-align: center; }
.panel.wide { width: min(480px, 100%); text-align: left; }

.eyebrow {
  margin: 0 0 10px;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--cyan);
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.85;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(34px, 7vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 900;
}
h1 span {
  background: linear-gradient(100deg, var(--cyan), var(--violet) 55%, var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 4.4vw, 28px);
  letter-spacing: -0.01em;
}

h3 {
  margin: 18px 0 8px;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-weight: 700;
}

.tagline {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.best { margin: 0 0 2px; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gap { margin: 0 0 18px; font-size: 12px; color: var(--muted); }

.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(18, 24, 44, 0.9);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.2s ease, background 0.2s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.985); }

.btn.primary {
  background: linear-gradient(100deg, #2f7cff, #56d1ff 45%, #b78cff);
  border: none;
  color: #04101f;
  box-shadow: 0 10px 30px rgba(60, 140, 255, 0.35);
}
.btn.primary.big { padding: 16px; font-size: 17px; letter-spacing: 0.02em; }

.btn.ghost { background: transparent; color: var(--muted); }

.btn.danger {
  background: transparent;
  border-color: rgba(255, 107, 61, 0.4);
  color: #ff9c86;
  margin-top: 16px;
  font-size: 13px;
}

.keys {
  list-style: none;
  margin: 18px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  font-size: 11.5px;
  color: var(--muted);
}
.keys li { display: flex; justify-content: space-between; gap: 8px; }
.keys b { color: var(--ink); font-weight: 700; }

.foot {
  margin: 16px 0 0;
  font-size: 10.5px;
  color: rgba(142, 160, 192, 0.7);
  text-align: center;
  letter-spacing: 0.04em;
}

.muted { color: var(--muted); }
.small { font-size: 11px; }

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

.panel.dead h2 { color: #fff; }
.hint { margin: 6px auto 4px; font-size: 13px; color: #cfe0f5; line-height: 1.65; max-width: 34em; }
.detail { margin: 6px 0 14px; font-size: 11px; letter-spacing: 0.02em; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 12px;
}
.result-grid .cell {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.result-grid .num {
  font-size: clamp(18px, 3.4vw, 22px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.result-grid .label { font-size: 10px; letter-spacing: 0.16em; color: var(--muted); }

.best-value {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.04em;
}

.actions { display: flex; gap: 10px; }
.actions .btn { margin-top: 0; }
.actions.column { flex-direction: column; }

.dead-hint {
  margin: 14px 0 0;
  font-size: 10.5px;
  color: rgba(142, 160, 192, 0.75);
  letter-spacing: 0.06em;
}

/* ---------------- 设置 ---------------- */

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 2px;
  border-bottom: 1px solid rgba(120, 200, 255, 0.1);
  font-size: 14px;
}

.row select {
  background: rgba(18, 24, 44, 0.9);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
}

input[type="checkbox"] {
  appearance: none;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex: none;
}
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
input[type="checkbox"]:checked { background: linear-gradient(100deg, #2f7cff, #56d1ff); }
input[type="checkbox"]:checked::after { transform: translateX(20px); }

.skins { display: grid; gap: 8px; margin: 6px 0 8px; }

.skin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.skin .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 12px currentColor; }
.skin .name { flex: 1; }
.skin .req { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.skin.active { border-color: rgba(90, 209, 255, 0.6); background: rgba(90, 209, 255, 0.1); }
.skin.locked { opacity: 0.45; cursor: not-allowed; }

/* ---------------- 横屏小高度适配 ---------------- */

@media (max-height: 520px) {
  .menu-card, .panel { padding: 18px; }
  .keys { display: none; }
  .result-grid { margin: 10px 0; }
  .tagline { margin-bottom: 10px; }
}

@media (max-width: 420px) {
  .hud-bar { padding-left: 12px; padding-right: 12px; }
  .stat.small { display: none; }
  .item-slot { width: 46px; height: 46px; }
}
