:root {
  color-scheme: dark;
  --bg: #03151b;
  --surface: #06242d;
  --surface-2: #0a313a;
  --text: #f4efe3;
  --muted: #9eb2b3;
  --line: rgba(255, 255, 255, .09);
  --gold: #eab55a;
  --gold-2: #f5d18d;
  --cyan: #66d4d2;
  --radius: 22px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(34, 117, 124, .20), transparent 35rem),
    radial-gradient(circle at 100% 20%, rgba(234, 181, 90, .10), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button { font: inherit; }
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .055; z-index: 20; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E"); }
.topbar, .shell { width: min(1240px, calc(100% - 32px)); margin-inline: auto; }
.topbar { padding: 18px 0; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 13px; color: var(--text); text-decoration: none; }
.brand img { width: 64px; height: 64px; border-radius: 50%; box-shadow: 0 0 28px rgba(234, 181, 90, .18); }
.brand span { display: grid; gap: 1px; }
.brand strong { font-size: 1.18rem; letter-spacing: .18em; }
.brand small { color: var(--muted); letter-spacing: .08em; }
.ghost-button, .footer-note button { border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.035); border-radius: 999px; padding: 10px 15px; cursor: pointer; }
.shell { padding-bottom: 36px; }
.scoreboard { border: 1px solid var(--line); border-radius: 28px; padding: 28px; background: linear-gradient(125deg, rgba(10,49,58,.96), rgba(4,24,30,.96)); box-shadow: 0 26px 80px rgba(0,0,0,.28); display: grid; grid-template-columns: 1.2fr 1fr; gap: 26px; }
.score-copy h1 { margin: 0 0 10px; max-width: 730px; font-size: clamp(2rem, 4vw, 4rem); line-height: .98; letter-spacing: -.04em; }
.score-copy p { margin: 0; max-width: 730px; color: var(--muted); font-size: 1.03rem; line-height: 1.6; }
.score-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-self: end; }
.score-stats div { min-width: 0; padding: 16px; border-radius: 17px; border: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.16); }
.score-stats span, .score-stats small { display: block; color: var(--muted); font-size: .75rem; }
.score-stats strong { display: block; margin: 4px 0; font-size: clamp(1.5rem, 2vw, 2.25rem); color: var(--gold-2); }
.goal-line { grid-column: 1 / -1; }
.goal-copy { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 8px; font-size: .88rem; }
.goal-copy span { color: var(--muted); }
.progress, .timer-track { height: 9px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.08); }
.progress div, .timer-track div { width: 0; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .35s ease; }
.game-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 18px; }
.game-tab { min-height: 58px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 15px; color: var(--muted); background: rgba(6,36,45,.80); cursor: pointer; font-weight: 800; text-align: left; transition: .18s ease; }
.game-tab span { color: var(--gold); margin-right: 8px; font-size: .76rem; letter-spacing: .12em; }
.game-tab:hover { color: var(--text); border-color: rgba(102,212,210,.32); transform: translateY(-1px); }
.game-tab.active { color: #241400; border-color: var(--gold); background: linear-gradient(180deg, var(--gold-2), var(--gold)); box-shadow: 0 12px 30px rgba(234,181,90,.16); }
.game-tab.active span { color: #563608; }
.game-stage { margin-top: 12px; }
.game-view { min-height: 500px; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; background: linear-gradient(135deg, rgba(8,38,47,.98), rgba(3,22,28,.99)); box-shadow: 0 18px 55px rgba(0,0,0,.22); display: grid; grid-template-columns: minmax(250px, .62fr) minmax(0, 1.38fr); gap: 30px; align-items: center; overflow: hidden; }
.game-view[hidden] { display: none; }
.game-copy { align-self: stretch; display: flex; flex-direction: column; justify-content: center; padding: 8px 4px; }
.panel-number { color: var(--gold); font-weight: 900; letter-spacing: .18em; font-size: .8rem; }
.game-copy h2 { margin: 10px 0 10px; font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1; letter-spacing: -.04em; }
.game-copy > p:not(.panel-status) { margin: 0; color: var(--muted); line-height: 1.65; max-width: 520px; }
.game-rule { margin-top: 24px; padding: 14px 16px; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; background: rgba(0,0,0,.15); display: flex; justify-content: space-between; gap: 16px; }
.game-rule strong { color: var(--gold-2); }
.game-rule span { color: var(--muted); text-align: right; }
.game-play { min-width: 0; border: 1px solid rgba(255,255,255,.07); border-radius: 19px; padding: 20px; background: rgba(0,0,0,.13); }
.primary-button, .secondary-button { border: 0; border-radius: 13px; min-height: 46px; padding: 0 18px; cursor: pointer; font-weight: 900; letter-spacing: .02em; transition: transform .16s ease, opacity .16s ease, box-shadow .16s ease; }
.primary-button { color: #2a1902; background: linear-gradient(180deg, var(--gold-2), var(--gold)); box-shadow: 0 10px 28px rgba(234,181,90,.18); }
.secondary-button { color: var(--text); background: rgba(102,212,210,.12); border: 1px solid rgba(102,212,210,.28); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.primary-button:disabled, .secondary-button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.action-button { width: min(100%, 360px); display: block; margin: 18px auto 0; }
.panel-status { min-height: 42px; margin: 16px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.wheel-box { position: relative; width: min(320px, 84vw); aspect-ratio: 1; margin: 0 auto; }
.wheel { position: absolute; inset: 10px; border-radius: 50%; border: 8px solid #b67c28; background: conic-gradient(#0f5661 0 45deg,#173c48 45deg 90deg,#8d5d22 90deg 135deg,#15515a 135deg 180deg,#704822 180deg 225deg,#12414d 225deg 270deg,#9d6a28 270deg 315deg,#194b55 315deg 360deg); box-shadow: inset 0 0 0 4px rgba(255,255,255,.08), 0 14px 40px rgba(0,0,0,.35); transition: transform 4s cubic-bezier(.12,.72,.12,1); }
.wheel::after { content: ""; position: absolute; width: 66px; height: 66px; border-radius: 50%; background: #06242d; border: 5px solid var(--gold); inset: 50% auto auto 50%; transform: translate(-50%,-50%); }
.wheel span { position: absolute; left: 50%; top: 50%; transform: rotate(calc(var(--n) * 45deg + 22.5deg)) translateY(-122px) rotate(calc((var(--n) * -45deg) - 22.5deg)); transform-origin: 0 0; font-weight: 900; color: #fff7e8; font-size: 1rem; }
.wheel-pointer { position: absolute; z-index: 3; left: 50%; top: -2px; transform: translateX(-50%); width: 0; height: 0; border-left: 15px solid transparent; border-right: 15px solid transparent; border-top: 32px solid var(--gold-2); filter: drop-shadow(0 4px 5px rgba(0,0,0,.5)); }
.click-score { display: flex; justify-content: space-between; align-items: end; max-width: 360px; margin: 0 auto 2px; color: var(--muted); }
.click-score strong { color: var(--gold-2); font-size: 3rem; line-height: 1; }
.crate { position: relative; display: block; width: 230px; height: 180px; margin: 22px auto; border: 0; background: transparent; cursor: pointer; }
.crate-lid { position: absolute; z-index: 2; top: 13px; left: 8px; width: 214px; height: 44px; border: 4px solid #d39a48; border-radius: 8px; background: linear-gradient(180deg,#9a642d,#71431f); transform-origin: 18px 40px; transition: transform .13s ease; }
.crate-body { position: absolute; bottom: 0; left: 20px; width: 190px; height: 135px; border: 4px solid #c78d3d; border-radius: 5px 5px 12px 12px; background: repeating-linear-gradient(90deg,#7b4a22 0 31px,#8e5827 31px 35px); display: grid; place-items: center; box-shadow: 0 15px 35px rgba(0,0,0,.28); }
.crate-body::before, .crate-body::after { content: ""; position: absolute; left: 0; right: 0; height: 16px; background: #b67731; border-top: 3px solid #d59b4d; border-bottom: 3px solid #73421c; }
.crate-body::before { top: 15px; } .crate-body::after { bottom: 15px; }
.crate img { position: relative; z-index: 1; width: 82px; height: auto; filter: drop-shadow(0 5px 8px rgba(0,0,0,.5)); pointer-events: none; }
.crate:active .crate-lid, .crate.hit .crate-lid { transform: rotate(-7deg) translateY(-5px); }
.crate:disabled { cursor: not-allowed; opacity: .65; }
.run-hud, .race-hud { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 10px; color: var(--muted); font-size: .83rem; flex-wrap: wrap; }
.run-hud strong, .race-hud strong { color: var(--gold-2); }
.canvas-wrap { position: relative; border-radius: 15px; overflow: hidden; border: 1px solid rgba(255,255,255,.09); background: #061e26; }
.run-canvas-wrap { aspect-ratio: 960 / 420; }
.race-canvas-wrap { aspect-ratio: 820 / 470; }
canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.canvas-start { position: absolute; inset: auto 50% 18px auto; transform: translateX(50%); min-width: 170px; min-height: 44px; border: 0; border-radius: 999px; background: var(--gold-2); color: #241400; font-weight: 900; cursor: pointer; }
.mobile-action { width: 100%; margin-top: 12px; }

.race-standings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}
.race-standing {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
}
.race-standing strong { color: var(--gold-2); font-size: .82rem; }
.race-standing.player { border-color: rgba(234,181,90,.42); background: rgba(234,181,90,.09); color: var(--text); }
.race-standing .car-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; box-shadow: 0 0 0 2px rgba(255,255,255,.08); }
.race-standing span:last-child { overflow: hidden; text-overflow: ellipsis; }

.race-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.tiers { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: rgba(5,28,35,.88); display: grid; grid-template-columns: .72fr 1.28fr; gap: 22px; align-items: center; }
.tiers h2 { margin: 0 0 7px; }
.tiers p { margin: 0; color: var(--muted); line-height: 1.5; font-size: .9rem; }
.tier-list { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.tier { padding: 12px 8px; text-align: center; border-radius: 13px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.03); }
.tier.active { border-color: var(--gold); background: rgba(234,181,90,.10); }
.tier strong, .tier span { display: block; }
.tier strong { color: var(--gold-2); font-size: 1.04rem; }
.tier span { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.footer-note { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 3px 0; color: var(--muted); font-size: .8rem; }
.footer-note button { font-size: .78rem; }
.topbar-actions { display:flex; align-items:center; gap:8px; }
.topbar-actions a { text-decoration:none; }
.reward-zone, .analog-rally { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(300px,.65fr); gap:24px; align-items:center; margin:18px 0; padding:24px; border:1px solid rgba(234,181,90,.42); border-radius:22px; background:linear-gradient(135deg,rgba(234,181,90,.13),rgba(13,44,52,.88)); box-shadow:0 18px 50px rgba(0,0,0,.24); }
.reward-zone h2, .analog-rally h2 { margin:4px 0 8px; font-size:clamp(1.45rem,3vw,2.15rem); }
.reward-zone p, .analog-rally p { margin:0; color:var(--muted); }
.reward-zone form { display:grid; gap:8px; }
.reward-zone label { font-weight:900; }
.reward-row { display:flex; gap:8px; }
.reward-row input { min-width:0; flex:1; border:1px solid var(--line); border-radius:12px; background:#03141a; color:#fff; padding:12px 13px; font:inherit; }
.reward-zone small { color:var(--muted); line-height:1.4; }
.reward-zone a { color:var(--gold-2); }
.reward-result { padding:14px; border:1px solid rgba(77,231,174,.42); border-radius:14px; background:rgba(12,62,52,.72); }
.reward-result.is-error { border-color:rgba(255,105,120,.52); background:rgba(78,25,32,.72); }
.reward-code { display:block; margin:8px 0; color:var(--gold-2); font-size:clamp(1.25rem,4vw,1.8rem); font-weight:1000; letter-spacing:.08em; }
.reward-result .primary-button { display:inline-block; margin-top:8px; text-decoration:none; }
.analog-rally { grid-template-columns:minmax(0,1fr) auto; }
.analog-rally .primary-button { text-decoration:none; white-space:nowrap; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translate(-50%,20px); opacity: 0; pointer-events: none; background: #f4d496; color: #1f1608; padding: 12px 18px; border-radius: 999px; font-weight: 800; box-shadow: 0 16px 45px rgba(0,0,0,.35); transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
@media (max-width: 900px) {
  .scoreboard { grid-template-columns: 1fr; }
  .game-tabs { display: flex; overflow-x: auto; scrollbar-width: thin; padding-bottom: 3px; }
  .game-tab { flex: 0 0 min(240px, 68vw); }
  .game-view { grid-template-columns: 1fr; min-height: 0; }
  .game-copy { padding: 0; }
  .tiers { grid-template-columns: 1fr; }
  .reward-zone, .analog-rally { grid-template-columns:1fr; }
}
@media (max-width: 700px) {
  .topbar, .shell { width: min(100% - 20px, 1240px); }
  .topbar { padding: 10px 0; }
  .brand img { width: 52px; height: 52px; }
  .scoreboard { padding: 20px; border-radius: 20px; }
  .score-stats { grid-template-columns: repeat(3, 1fr); }
  .score-stats div { padding: 11px 8px; }
  .score-stats strong { font-size: 1.3rem; }
  .score-stats span, .score-stats small { font-size: .63rem; }
  .goal-copy { align-items: flex-end; }
  .goal-copy span { text-align: right; font-size: .72rem; }
  .game-view { padding: 18px; gap: 18px; }
  .game-play { padding: 12px; }
  .game-copy h2 { font-size: 2.25rem; }
  .wheel-box { width: min(248px, 78vw); }
  .wheel span { transform: rotate(calc(var(--n) * 45deg + 22.5deg)) translateY(-92px) rotate(calc((var(--n) * -45deg) - 22.5deg)); }
  .crate { transform: scale(.88); margin-block: 6px; }
  .tier-list { grid-template-columns: repeat(3, 1fr); }
  .footer-note { align-items: flex-start; flex-direction: column; }
  .ghost-button { padding: 9px 11px; font-size: .76rem; }
  .topbar-actions { align-items:stretch; flex-direction:column; }
  .reward-zone, .analog-rally { padding:18px; }
  .reward-row { flex-direction:column; }
  .reward-row .primary-button { width:100%; }
  .race-hud { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); font-size: .68rem; gap: 6px; }
  .race-hud span { padding: 6px 5px; border-radius: 8px; background: rgba(255,255,255,.035); text-align: center; }
  .race-hud strong { display:block; margin-top:2px; }
  .race-standings { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media (max-width: 700px) {
  .game-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .game-tab { min-width: 0; width: 100%; min-height: 54px; padding: 10px 11px; font-size: .82rem; }
  .game-tab span { display: block; margin: 0 0 3px; font-size: .66rem; }
}

.run-progress {
  height: 8px;
  margin: 0 0 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.35);
}
.run-progress div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e59b35, #ffd98f);
  transition: width .12s linear;
}
.run-canvas-wrap {
  box-shadow: 0 18px 42px rgba(0,0,0,.32), inset 0 0 0 1px rgba(255,255,255,.04);
}
.run-canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 24%, transparent 76%, rgba(0,0,0,.12));
}
@media (max-width: 700px) {
  .run-hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: .68rem; }
  .run-hud span { text-align: center; padding: 6px 4px; border-radius: 8px; background: rgba(255,255,255,.035); }
  .run-hud strong { display: block; margin-top: 2px; font-size: .84rem; }
}
