/* NEON APEX — 界面层
   深色玻璃面板 + 暖橙高光，全部尺寸用 clamp/vmin，缩放不裁控件 */

:root {
  --bg: #05060a;
  --panel: rgba(10, 12, 18, 0.62);
  --panel-strong: rgba(8, 10, 15, 0.86);
  --line: rgba(255, 255, 255, 0.10);
  --line-soft: rgba(255, 255, 255, 0.06);
  --txt: #eef1f6;
  --dim: #8d95a5;
  --accent: #ff7a3d;
  --accent-soft: #ffb27a;
  --red: #ff3b46;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

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

#ui {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(10px, 1.6vw, 24px);
  gap: 8px;
  pointer-events: none;
  user-select: none;
  opacity: 1;
  transition: opacity .25s ease;
}
#ui.dim { opacity: .18; }

.hud { display: flex; align-items: flex-start; justify-content: space-between; }
.hud-bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: clamp(8px, 1.4vw, 20px);
}
/* 显式指定列位：提示面板在窄屏被隐藏时，速度和地图不会挤到左边 */
.hud-bottom .hints { grid-column: 1; }
.hud-bottom .speed-cluster { grid-column: 2; }
.hud-bottom .map-panel { grid-column: 3; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .05);
}

/* ---------- 顶部左：圈数 ---------- */
.lap-panel {
  padding: 10px clamp(12px, 1.2vw, 18px) 11px;
  min-width: clamp(150px, 16vw, 210px);
}
.lap-line { display: flex; align-items: baseline; gap: 10px; }
.lap-num { font-family: var(--mono); font-size: clamp(20px, 2.2vw, 30px); line-height: 1; letter-spacing: -.02em; }
.lap-num b { color: #fff; font-weight: 600; }
.lap-num i { color: var(--dim); font-style: normal; margin: 0 2px; font-size: .7em; }
.lap-num span { color: var(--dim); }
.row { display: flex; justify-content: space-between; gap: 14px; margin-top: 6px; font-size: clamp(10px, .86vw, 12px); }
.k {
  color: var(--dim);
  font-size: clamp(9px, .78vw, 11px);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.v { color: #e8ebf2; }
.v.best { color: var(--accent-soft); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- 顶部右 ---------- */
.top-right { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.total-panel { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding: 8px 14px; }
.total-panel .v { font-size: clamp(13px, 1.15vw, 17px); }
.btn-row { display: flex; flex-direction: column; gap: 6px; }
.icon-btn {
  width: clamp(30px, 2.6vw, 38px);
  height: clamp(30px, 2.6vw, 38px);
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #cfd6e3;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { background: rgba(255, 122, 61, .16); color: #fff; border-color: rgba(255, 122, 61, .5); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.off { color: #5c6472; }

/* ---------- 底部左：操作提示 ---------- */
.hints { padding: 10px 14px 11px; max-width: 46vw; justify-self: start; }
.hint-title { font-size: 9px; letter-spacing: .18em; color: var(--dim); margin-bottom: 6px; }
.hint-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 5px 16px;
  font-size: clamp(10px, .84vw, 12px);
  color: #b9c1cf;
}
.hint-grid span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, .07);
  color: #e9edf5;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
}

/* ---------- 底部中：速度 ---------- */
.speed-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  min-width: clamp(160px, 20vw, 260px);
  justify-self: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .8);
}
.speed-bar {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .10);
  overflow: hidden;
}
.speed-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, #ffd0a8, var(--accent) 55%, #ff3b46);
  box-shadow: 0 0 14px rgba(255, 122, 61, .85);
  transition: width .08s linear;
}
.speed-read { display: flex; align-items: baseline; gap: 7px; }
#speedVal {
  font-size: clamp(34px, 4.6vw, 62px);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: .92;
  color: #fff;
  text-shadow: 0 0 26px rgba(255, 150, 90, .35), 0 4px 24px rgba(0, 0, 0, .8);
}
.speed-read .unit { font-size: clamp(9px, .85vw, 12px); letter-spacing: .16em; color: #aeb6c4; }
.speed-meta { display: flex; gap: 10px; align-items: center; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; }
#gearLabel { color: #dfe5ef; }
.drift { color: var(--accent); opacity: 0; transition: opacity .12s; }
.drift.on { opacity: 1; }

/* ---------- 底部右：小地图 ---------- */
.map-panel { padding: 8px 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; justify-self: end; }
#minimap {
  width: clamp(92px, 9.4vw, 148px);
  height: clamp(92px, 9.4vw, 148px);
  display: block;
}
.map-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 4px 2px;
  font-family: var(--mono);
  font-size: 9px;
  color: #9aa3b2;
}

/* ---------- 覆盖层 ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 122, 61, .10), transparent 55%),
    radial-gradient(90% 70% at 50% 100%, rgba(30, 60, 120, .12), transparent 60%),
    rgba(3, 4, 7, .82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20;
  transition: opacity .28s ease, visibility .28s;
}
.screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.screen-inner {
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: clamp(20px, 3vw, 40px);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: linear-gradient(180deg, rgba(18, 20, 27, .92), rgba(8, 9, 13, .95));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .06);
  text-align: left;
}
.screen-inner.compact { width: min(440px, 100%); }
.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 12px;
}
h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 62px);
  line-height: .92;
  letter-spacing: -.04em;
  font-weight: 700;
}
h1 span { color: var(--accent); }
h2 { margin: 0 0 14px; font-size: clamp(24px, 3vw, 32px); letter-spacing: -.02em; }
.sub { margin: 8px 0 0; color: #c8cfdb; font-size: clamp(13px, 1.1vw, 15px); letter-spacing: .04em; }
.desc { margin: 14px 0 0; color: #8f98a8; font-size: 13px; line-height: 1.7; }
.key-list { display: grid; gap: 7px; margin: 20px 0 22px; font-size: 12px; color: #a9b2c1; }
.key-list > div { display: flex; align-items: center; gap: 5px; }
.key-list span { margin-left: 6px; }
.cta {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 160, 110, .5);
  background: linear-gradient(180deg, #ff8a4d, #f2652a);
  color: #1a0d05;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(242, 101, 42, .32);
  transition: transform .1s, filter .15s;
}
.cta:hover { filter: brightness(1.08); }
.cta:active { transform: translateY(1px) scale(.995); }
.cta em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .18);
  opacity: .8;
}
.ghost {
  width: 100%;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: #cfd6e3;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.ghost:hover { background: rgba(255, 255, 255, .09); }
.btn-col { display: grid; gap: 8px; margin-top: 18px; }
.foot-note { margin-top: 14px; font-size: 10px; color: #5f6776; letter-spacing: .06em; text-align: center; }
.pause-stats, .result-grid { display: grid; gap: 8px; margin: 4px 0 6px; }
.pause-stats > div, .result-grid > div {
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line-soft);
  font-size: 13px;
}
.pause-stats b, .result-grid b { font-weight: 600; }
.lap-list { margin-top: 12px; display: grid; gap: 4px; font-family: var(--mono); font-size: 11px; color: #98a1b0; }
.lap-list div { display: flex; justify-content: space-between; padding: 4px 10px; border-radius: 6px; }
.lap-list div.best { color: var(--accent-soft); background: rgba(255, 122, 61, .08); }

/* ---------- 倒计时 / 提示 ---------- */
.countdown {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
}
.countdown span {
  font-family: var(--mono);
  font-size: clamp(80px, 16vw, 190px);
  font-weight: 700;
  letter-spacing: -.05em;
  color: #fff;
  text-shadow: 0 0 70px rgba(255, 122, 61, .8), 0 0 140px rgba(255, 80, 40, .4);
  animation: cdPop .55s cubic-bezier(.2, 1.3, .4, 1);
}
.countdown.go span { color: #b6ffd0; text-shadow: 0 0 80px rgba(80, 255, 150, .8); }
@keyframes cdPop {
  0% { transform: scale(1.55); opacity: 0; filter: blur(6px); }
  55% { transform: scale(1); opacity: 1; filter: blur(0); }
  100% { transform: scale(.96); opacity: .92; }
}
.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22%;
  transform: translate(-50%, 10px);
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 122, 61, .35);
  background: rgba(20, 12, 8, .82);
  color: #ffc7a3;
  font-size: 12px;
  letter-spacing: .05em;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 18;
  backdrop-filter: blur(10px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.nogl {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #05060a;
  color: #dfe5ef;
  z-index: 50;
  text-align: center;
  padding: 24px;
}
.nogl p { color: #8d95a5; font-size: 13px; max-width: 420px; line-height: 1.7; }
.nogl.hidden { display: none; }

/* ---------- 自适应 ---------- */
@media (max-width: 760px) {
  .hints { display: none; }
  .hud-bottom { justify-content: space-between; }
  .speed-cluster { min-width: 130px; }
  .map-panel { padding: 6px 6px 3px; }
}
@media (max-height: 560px) {
  .hints { display: none; }
  .screen-inner { padding: 16px 18px; }
  h1 { font-size: 32px; }
  .key-list { margin: 12px 0 14px; }
  .desc { display: none; }
  .lap-panel .row:nth-child(2) { display: none; }
}
@media (max-height: 430px) {
  .map-panel { display: none; }
  .screen-inner .key-list { display: none; }
}
