/* ═══════════ 玩具车跑酷 ToyCar Rush ═══════════ */
:root {
  --gold: #ffd94d;
  --gold-deep: #f5a623;
  --ink: #0b0620;
  --ink-2: #140b33;
  --cyan: #35e0ff;
  --magenta: #ff3d9a;
  --green: #43f78d;
  --red: #ff4d5e;
  --text: #f4f1ff;
  --text-dim: #a99fd0;
  --panel: rgba(20, 12, 48, 0.72);
  --panel-line: rgba(255, 217, 77, 0.22);
  font-size: clamp(13px, 1.6vw + 8px, 18px);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "HarmonicOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  user-select: none;
  touch-action: none;
}
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(4, 2, 14, 0.55) 100%); }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 30; opacity: 0; background: #ff2233; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* ── 通用覆盖层 ── */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between; padding: max(4vh, 20px) 5vw;
  opacity: 0; pointer-events: none; transition: opacity .35s ease; }
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay.dim { background: rgba(6, 3, 20, 0.62); backdrop-filter: blur(10px); justify-content: center; }

/* ── 启动 ── */
#boot { background: radial-gradient(ellipse at 50% 35%, #1d0f4d 0%, var(--ink) 70%); justify-content: center; }
.boot-inner { text-align: center; }
.boot-car { font-size: 3.4rem; animation: bootBounce 1s ease-in-out infinite; }
@keyframes bootBounce { 0%,100% { transform: translateY(0) rotate(-6deg);} 50% { transform: translateY(-14px) rotate(6deg);} }
.boot-bar { width: 220px; height: 6px; margin: 22px auto 12px; border-radius: 99px;
  background: rgba(255,255,255,.1); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width .3s ease;
  box-shadow: 0 0 12px var(--gold); }
.boot-text { color: var(--text-dim); font-size: .9rem; }

/* ── 标题/按钮 ── */
.eyebrow { letter-spacing: .35em; color: var(--cyan); font-size: .78rem; text-transform: uppercase;
  text-shadow: 0 0 14px rgba(53,224,255,.8); }
.game-title { font-size: clamp(3rem, 11vw, 6.2rem); line-height: 1.05; margin: .5vh 0 1.2vh;
  font-weight: 900; letter-spacing: .04em; }
.game-title span { color: var(--text); text-shadow: 0 0 30px rgba(53,224,255,.55); }
.game-title em { font-style: normal; margin-left: .12em;
  background: linear-gradient(100deg, var(--gold) 20%, #ff9d3d 55%, var(--magenta) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(255,157,61,.45)); }
.subtitle { color: var(--text-dim); max-width: 34em; font-size: .95rem; line-height: 1.7; }

.btn { display: block; width: 100%; padding: .95em 2.2em; margin-top: 12px; border-radius: 16px;
  border: 1px solid var(--panel-line); background: var(--panel); color: var(--text);
  font-size: 1.05rem; font-weight: 700; letter-spacing: .08em; cursor: pointer;
  backdrop-filter: blur(8px); transition: transform .15s ease, box-shadow .2s ease, background .2s ease; }
.btn:hover { transform: translateY(-2px); background: rgba(40, 26, 86, .8); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: #3a2503; border: none; box-shadow: 0 6px 28px rgba(245,166,35,.38), inset 0 1px 0 rgba(255,255,255,.5); }
.btn-primary:hover { background: linear-gradient(135deg, #ffe27a, #ffb43d); box-shadow: 0 10px 34px rgba(245,166,35,.5); }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--panel-line);
  background: var(--panel); color: var(--text); font-size: 1.1rem; cursor: pointer; backdrop-filter: blur(8px); }
.icon-btn:hover { background: rgba(40,26,86,.85); }

/* ── 主菜单 ── */
#menu { align-items: flex-start; }
.menu-top { padding-top: 3vh; }
.menu-bottom { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.menu-car-name { font-size: 1rem; color: var(--gold); letter-spacing: .15em; font-weight: 700;
  text-shadow: 0 0 16px rgba(255,217,77,.5); }
.menu-btns { width: min(320px, 84vw); }
.menu-btns .btn:first-child { margin-top: 0; }
.menu-foot { width: min(320px, 84vw); display: flex; justify-content: space-between; align-items: center;
  color: var(--text-dim); font-size: .82rem; }

/* ── 面板头 ── */
.panel-head { width: 100%; display: flex; align-items: center; gap: 14px; }
.panel-head h2 { font-size: 1.5rem; letter-spacing: .1em; flex: 1; text-shadow: 0 0 18px rgba(53,224,255,.35); }
.icon-btn.back { font-size: 1.6rem; line-height: 0; }
.scan-badge { font-size: .75rem; color: var(--cyan); border: 1px solid rgba(53,224,255,.4);
  padding: 5px 10px; border-radius: 99px; background: rgba(53,224,255,.08); white-space: nowrap; }

/* ── 选关 ── */
.diff-switch { display: flex; border-radius: 12px; overflow: hidden; border: 1px solid var(--panel-line); }
.diff-switch button { padding: 8px 14px; border: none; background: var(--panel); color: var(--text-dim);
  font-size: .85rem; cursor: pointer; }
.diff-switch button.on[data-diff="easy"] { background: rgba(67,247,141,.2); color: var(--green); }
.diff-switch button.on[data-diff="normal"] { background: rgba(255,157,61,.25); color: #ffb43d; }
.diff-switch button.on[data-diff="hard"] { background: rgba(255,77,94,.2); color: var(--red); }
.world-tabs { display: flex; gap: 8px; margin: 2vh 0; overflow-x: auto; max-width: 100%; padding-bottom: 4px; }
.world-tab { flex: 0 0 auto; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--panel-line);
  background: var(--panel); cursor: pointer; text-align: left; min-width: 132px; transition: all .2s ease; }
.world-tab .w-name { font-weight: 800; font-size: .95rem; }
.world-tab .w-sub { font-size: .68rem; color: var(--text-dim); margin-top: 3px; }
.world-tab.on { border-color: var(--tab-c, var(--gold)); box-shadow: 0 0 18px -4px var(--tab-c, var(--gold)); }
.world-tab.locked { opacity: .38; filter: grayscale(.8); }
.level-list { width: 100%; display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.level-card { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: 18px;
  border: 1px solid var(--panel-line); background: var(--panel); backdrop-filter: blur(8px);
  cursor: pointer; transition: all .18s ease; }
.level-card:hover { transform: translateY(-2px); border-color: var(--lc, var(--gold)); box-shadow: 0 8px 26px -10px var(--lc, var(--gold)); }
.level-card.locked { opacity: .4; cursor: not-allowed; filter: grayscale(.7); }
.level-num { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 900; font-size: 1.2rem; color: #0b0620; background: var(--lc, var(--gold)); flex: 0 0 auto; }
.level-info { flex: 1; }
.level-name { font-weight: 800; font-size: 1.05rem; }
.level-meta { font-size: .76rem; color: var(--text-dim); margin-top: 4px; display: flex; gap: 12px; }
.level-stars { color: var(--gold); letter-spacing: 2px; font-size: 1rem; white-space: nowrap; }
.level-stars .off { color: rgba(255,255,255,.16); }

/* ── 车库 ── */
#garage { justify-content: space-between; }
.garage-mid { width: 100%; display: flex; align-items: center; justify-content: space-between; flex: 1; }
.garage-arrow { width: 58px; height: 88px; border-radius: 18px; border: 1px solid var(--panel-line);
  background: var(--panel); color: var(--gold); font-size: 2.4rem; cursor: pointer; backdrop-filter: blur(8px);
  transition: all .15s ease; line-height: 0; }
.garage-arrow:hover { background: rgba(40,26,86,.9); transform: scale(1.05); }
.garage-arrow:active { transform: scale(.96); }
.garage-info { text-align: center; }
.garage-name { font-size: 1.6rem; font-weight: 900; letter-spacing: .06em;
  text-shadow: 0 2px 14px rgba(0,0,0,.9), 0 0 24px rgba(255,217,77,.4); }
.garage-cn { color: var(--text); margin-top: 4px; letter-spacing: .3em;
  text-shadow: 0 2px 10px rgba(0,0,0,.9); }
.garage-idx { color: var(--text-dim); font-size: .8rem; margin-top: 8px; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 8px rgba(0,0,0,.9); }
.garage-foot { width: min(320px, 84vw); text-align: center; }
.garage-loading { color: var(--cyan); font-size: .85rem; margin-bottom: 10px; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ── HUD ── */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#hud .icon-btn { pointer-events: auto; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 0; }
.money-panel { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 16px;
  padding: 10px 18px 12px; backdrop-filter: blur(8px); min-width: 190px; }
.money-row { display: flex; align-items: baseline; gap: 8px; }
.money { font-size: 1.7rem; font-weight: 900; font-variant-numeric: tabular-nums; transition: color .2s;
  text-shadow: 0 0 18px rgba(255,217,77,.35); }
.money.neg { color: var(--red); text-shadow: 0 0 18px rgba(255,77,94,.5); }
.money.win { color: var(--green); text-shadow: 0 0 18px rgba(67,247,141,.5); }
.money.bump { animation: bump .3s ease; }
@keyframes bump { 35% { transform: scale(1.22); } }
.target { color: var(--text-dim); font-size: .9rem; font-variant-numeric: tabular-nums; }
.target-bar { height: 5px; margin-top: 8px; border-radius: 99px; background: rgba(255,255,255,.09); overflow: hidden; }
.target-bar i { display: block; height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width .35s ease; }
.hud-right { display: flex; gap: 10px; align-items: center; }
.hud-level { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px;
  padding: 9px 14px; font-weight: 800; font-size: .9rem; color: var(--cyan); backdrop-filter: blur(8px); }
.progress-track { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 88px); left: 16px; right: 16px;
  height: 4px; border-radius: 99px; background: rgba(255,255,255,.08); }
.progress-track i { display: block; height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta)); box-shadow: 0 0 10px var(--cyan); }
.progress-track .flag { position: absolute; right: -4px; top: -11px; font-size: .9rem; }
.steer-hint { position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 26px); left: 0; right: 0;
  text-align: center; color: rgba(244,241,255,.55); font-size: .9rem; letter-spacing: .1em;
  animation: pulse 2s ease-in-out infinite; transition: opacity .6s; }

/* 浮字 */
#floaters { position: absolute; inset: 0; overflow: hidden; }
.floater { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 1.5rem;
  text-shadow: 0 2px 12px rgba(0,0,0,.7); animation: floatUp 1.1s ease-out forwards; white-space: nowrap; }
.floater.good { color: var(--green); } .floater.bad { color: var(--red); }
.floater.mult { color: var(--cyan); } .floater.div { color: var(--gold); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%,-30%) scale(.6); }
  18% { opacity: 1; transform: translate(-50%,-60%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%,-190%) scale(1); } }

/* ── 对话框 ── */
.dialog { width: min(360px, 88vw); background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 24px; padding: 30px 26px; text-align: center; backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8); }
.dialog h2 { font-size: 1.6rem; letter-spacing: .08em; margin-bottom: 14px; }
.result-stars { font-size: 2.2rem; letter-spacing: .2em; color: var(--gold);
  text-shadow: 0 0 24px rgba(255,217,77,.6); margin-bottom: 6px; }
.result-stars .off { color: rgba(255,255,255,.14); text-shadow: none; }
.result-sub { color: var(--text-dim); font-size: .9rem; margin-bottom: 14px; }
.result-money { font-size: 2.6rem; font-weight: 900; font-variant-numeric: tabular-nums;
  color: var(--gold); text-shadow: 0 0 30px rgba(255,217,77,.5); margin-bottom: 4px; }
.result-money.neg { color: var(--red); text-shadow: 0 0 30px rgba(255,77,94,.5); }
.result-best { color: var(--text-dim); font-size: .8rem; min-height: 1.2em; margin-bottom: 8px; }
.result-dialog .btn { margin-top: 10px; }

/* 加载模态 */
.loading-dialog { min-width: min(300px, 80vw); }
.loading-text { font-size: 1rem; margin: 14px 0 12px; letter-spacing: .1em; }
.loading-pct { margin-top: 8px; color: var(--gold); font-weight: 800; font-variant-numeric: tabular-nums; }

/* 分享海报 */
#share { z-index: 70; }
.share-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; max-height: 100%; }
.share-wrap img { max-height: 82vh; max-width: 88vw; border-radius: 18px; box-shadow: 0 24px 80px rgba(0,0,0,.7); }
.share-hint { color: var(--text-dim); font-size: .85rem; }

/* 账户 / 排行榜 */
.acct-row { display: flex; gap: 10px; width: min(320px, 84vw); }
.acct-chip { flex: 1; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--panel-line);
  background: var(--panel); color: var(--text); font-size: .88rem; cursor: pointer; backdrop-filter: blur(8px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-chip:hover { background: rgba(40,26,86,.85); }
.text-input { width: 100%; padding: 13px 16px; margin-top: 10px; border-radius: 12px;
  border: 1px solid var(--panel-line); background: rgba(6,3,20,.6); color: var(--text);
  font-size: 1rem; outline: none; }
.text-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,217,77,.15); }
.auth-err { margin-top: 10px; color: var(--red); font-size: .85rem; }
.rank-dialog { width: min(420px, 92vw); }
.rank-tabs, .rank-scope { display: flex; gap: 8px; margin-top: 12px; }
.rank-tabs .tab, .rank-scope .tab { flex: 1; padding: 9px 0; border-radius: 10px; border: 1px solid var(--panel-line);
  background: rgba(6,3,20,.5); color: var(--text-dim); font-size: .85rem; cursor: pointer; }
.rank-tabs .tab.on, .rank-scope .tab.on { background: rgba(255,217,77,.18); color: var(--gold); border-color: rgba(255,217,77,.4); }
.rank-scope { margin-top: 8px; }
.rank-list { margin-top: 14px; max-height: 46vh; overflow-y: auto; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; margin-bottom: 6px;
  background: rgba(255,255,255,.04); }
.rank-row.self { background: rgba(255,217,77,.14); border: 1px solid rgba(255,217,77,.35); }
.rank-no { width: 26px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }
.rank-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-val i { font-style: normal; font-size: .72rem; color: var(--text-dim); margin-left: 6px; }
.rank-empty { text-align: center; color: var(--text-dim); padding: 30px 0; }
.rank-me { margin-top: 10px; color: var(--gold); font-size: .88rem; text-align: center; }

@media (max-width: 640px) {
  .money-panel { min-width: 150px; padding: 8px 14px 10px; }
  .money { font-size: 1.35rem; }
  .garage-arrow { width: 46px; height: 72px; font-size: 1.8rem; }
  .level-list { gap: 9px; }
  .level-card { padding: 12px 16px; }
}
