:root {
  --bg: #050403;
  --gold: #f3ba2f;
  --gold-2: #ffd35c;
  --red: #ff4d4d;
  --green: #58d68d;
  --text: #f7f7f3;
  --muted: #9a9488;
  --line: rgba(255, 255, 255, .1);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 50% -140px, rgba(243, 186, 47, .1), transparent 70%),
    linear-gradient(180deg, #0a0806 0%, #050403 55%, #030202 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.shell { width: min(720px, calc(100% - 28px)); margin-inline: auto; }

.run-header {
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.run-brand { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 950; letter-spacing: -.03em; }
.run-brand img { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(243, 186, 47, .2); }
.run-header-actions { display: flex; align-items: center; gap: 8px; }
.run-back { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; color: #cfcfc9; font-size: 10px; font-weight: 900; letter-spacing: .06em; background: rgba(255, 255, 255, .02); }
.run-back:hover { border-color: rgba(243, 186, 47, .3); color: var(--gold); }

.run-title { margin: 6px 0 4px; text-align: center; }
.run-title h1 { margin: 0; font-size: clamp(28px, 6vw, 42px); font-weight: 950; letter-spacing: -.04em; line-height: 1; }
.run-title span { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .02em; }

.game-frame {
  margin: 14px auto 10px;
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 76vh;
  border: 1px solid rgba(243, 186, 47, .22);
  border-radius: 20px;
  overflow: hidden;
  background: #0a0806;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .5);
  touch-action: none;
}
#gameCanvas { display: block; width: 100%; height: 100%; touch-action: none; }

#hud {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.hud-top, .hud-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#hud strong {
  padding: 6px 12px;
  border: 1px solid rgba(243, 186, 47, .25);
  border-radius: 999px;
  background: rgba(5, 4, 3, .55);
  backdrop-filter: blur(6px);
  font-size: 13px;
  font-weight: 950;
  letter-spacing: -.01em;
}
.hud-zone {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(5, 4, 3, .55);
  backdrop-filter: blur(6px);
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
}
.hud-energy {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.hud-energy-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .15s linear; }
.hud-coins {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(5, 4, 3, .55);
  backdrop-filter: blur(6px);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.tutorial-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(5, 4, 3, .7);
  border: 1px solid rgba(243, 186, 47, .25);
  font-size: 10px;
  font-weight: 800;
  color: #cfcfc9;
  pointer-events: none;
}

#gameBanner {
  position: absolute;
  top: 40%;
  left: 50%;
  z-index: 4;
  transform: translate(-50%, -50%) scale(.85);
  padding: 10px 20px;
  border: 1px solid rgba(243, 186, 47, .35);
  border-radius: 12px;
  background: rgba(6, 5, 4, .78);
  color: var(--gold-2);
  font-size: clamp(13px, 3.6vw, 18px);
  font-weight: 950;
  letter-spacing: .01em;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#gameBanner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  text-align: center;
  background: rgba(5, 4, 3, .82);
  backdrop-filter: blur(10px);
}
.overlay .kicker { color: var(--gold); font-size: 10px; font-weight: 950; letter-spacing: .16em; }
.overlay h2 { margin: 2px 0 0; font-size: clamp(22px, 6vw, 32px); font-weight: 950; letter-spacing: -.03em; }

.rider-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 420px;
}
.rider-button {
  min-height: 84px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .025);
  transition: border-color .15s ease, transform .15s ease, background .15s ease, box-shadow .2s ease;
}
.rider-button img { width: 40px; height: 40px; object-fit: contain; transition: transform .15s ease; }
.rider-button .dice { font-size: 26px; line-height: 1; }
.rider-button span { font-size: 9px; font-weight: 950; letter-spacing: .07em; color: #cfcfc9; }
.rider-button small { font-size: 8px; font-weight: 700; color: #6f6a5f; letter-spacing: .02em; }
.rider-button:hover { border-color: rgba(243, 186, 47, .4); transform: translateY(-2px); background: rgba(243, 186, 47, .04); }
.rider-button:hover img { transform: scale(1.06); }
.rider-button.active {
  border-color: var(--gold);
  background: rgba(243, 186, 47, .1);
  transform: scale(1.06) translateY(-3px);
  box-shadow: 0 0 0 1px rgba(243, 186, 47, .25), 0 12px 28px rgba(243, 186, 47, .18);
  z-index: 1;
}
.rider-button.active img { width: 46px; height: 46px; }
.rider-button.active span { color: var(--gold); }
.rider-button.hop img { animation: rider-hop .42s ease; }
@keyframes rider-hop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-10px) scale(1.08); }
  60% { transform: translateY(2px) scale(.97); }
  100% { transform: translateY(0) scale(1); }
}

.select-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.select-chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  color: #cfcfc9;
  background: rgba(255, 255, 255, .02);
}
.select-chip-button { border: 0; cursor: pointer; color: var(--gold); background: rgba(243, 186, 47, .08); }

.run-primary {
  min-height: 50px;
  padding: 0 26px;
  border: 0;
  border-radius: 13px;
  color: #050505;
  background: var(--gold);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .03em;
  box-shadow: 0 14px 34px rgba(243, 186, 47, .12);
  transition: transform .15s ease, opacity .15s ease;
}
.run-primary:hover:not(:disabled) { transform: translateY(-2px); }
.run-primary:disabled { opacity: .4; cursor: not-allowed; }

.run-secondary {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #e2e2dd;
  background: rgba(255, 255, 255, .02);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .03em;
}
.run-secondary:hover { border-color: rgba(243, 186, 47, .3); }

.over-score { font-size: clamp(38px, 11vw, 58px); font-weight: 950; letter-spacing: -.04em; color: var(--gold); line-height: 1; }
.over-best { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.over-rider { color: #cfcfc9; font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.over-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 4px; }
.over-links { margin-top: 2px; }

.over-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.over-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(243, 186, 47, .12);
  border: 1px solid rgba(243, 186, 47, .3);
  color: var(--gold);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: .06em;
}
.over-badge-level { background: rgba(88, 214, 141, .12); border-color: rgba(88, 214, 141, .3); color: var(--green); }

.over-progress { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; max-width: 320px; }
.over-level { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.over-level span { font-size: 9px; font-weight: 950; letter-spacing: .08em; color: var(--muted); }
.over-level-bar { width: 100%; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.over-level-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .3s ease; }
.over-bull { font-size: 11px; font-weight: 950; letter-spacing: .12em; color: #cfcfc9; }
.over-rank { margin: 0; color: var(--gold); font-size: 11px; font-weight: 800; min-height: 14px; }
.over-box-cta { border-color: rgba(243, 186, 47, .4); color: var(--gold); }

.box-reveal { font-size: 64px; line-height: 1; }
.box-subtitle { margin: 0; color: var(--muted); font-size: 11px; max-width: 300px; }

.locker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 460px; max-height: 46vh; overflow-y: auto; }
.locker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .02);
  text-align: center;
}
.locker-card.locked { opacity: .4; }
.locker-card.equipped { border-color: var(--gold); background: rgba(243, 186, 47, .08); }
.locker-card strong { font-size: 10px; font-weight: 900; color: #f7f7f3; }
.locker-card small { font-size: 8px; color: var(--muted); letter-spacing: .04em; }
.locker-rarity { font-size: 8px; font-weight: 950; letter-spacing: .08em; }
.locker-card.rarity-common .locker-rarity { color: #9fb4c7; }
.locker-card.rarity-rare .locker-rarity { color: #7fb8ff; }
.locker-card.rarity-legendary .locker-rarity { color: var(--gold); }

.daily-list { display: grid; gap: 10px; width: 100%; max-width: 420px; }
.daily-row { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .02); text-align: left; }
.daily-row.done { border-color: rgba(88, 214, 141, .35); background: rgba(88, 214, 141, .06); }
.daily-row-top { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 800; color: #e2e2dd; margin-bottom: 6px; }
.daily-bar { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.daily-bar-fill { height: 100%; background: var(--gold); }

.bullboard-tabs { display: flex; gap: 6px; }
.bullboard-tab {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .02);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .05em;
}
.bullboard-tab.active { border-color: var(--gold); color: var(--gold); background: rgba(243, 186, 47, .08); }

.run-footer {
  margin: 6px 0 30px;
  padding-bottom: env(safe-area-inset-bottom);
  text-align: center;
  color: #55504a;
  font-size: 10px;
  line-height: 1.6;
}

/* Bullboard */
.bullboard-submit {
  width: 100%;
  max-width: 460px;
  padding: 14px;
  border: 1px solid rgba(243, 186, 47, .25);
  border-radius: 14px;
  background: rgba(243, 186, 47, .04);
}
.bullboard-submit p { margin: 0 0 10px; font-size: 12px; color: #cfcfc9; }
.bullboard-submit strong { color: var(--gold); }
.bullboard-status { min-height: 14px; margin: 8px 0 0 !important; font-size: 10px; color: var(--muted); }
.bullboard-status.error { color: var(--red) !important; }
.bullboard-status.success { color: var(--green) !important; }

.wallet-options, .wallet-fallback { margin-top: 10px; display: grid; gap: 7px; text-align: left; }
.wallet-option, .wallet-fallback a {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #d6d6d1;
  background: rgba(255, 255, 255, .02);
  font: inherit;
  text-align: left;
}
.wallet-option:hover, .wallet-fallback a:hover { border-color: rgba(243, 186, 47, .3); }
.wallet-option:disabled { cursor: wait; opacity: .58; }
.wallet-option span { display: flex; align-items: center; gap: 10px; }
.wallet-option img { width: 24px; height: 24px; border-radius: 7px; }
.wallet-option small, .wallet-fallback small { color: #6c6c66; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.wallet-fallback > span { margin: 3px 2px 0; color: #666660; font-size: 8px; font-weight: 950; letter-spacing: .13em; }
.wallet-note { margin-top: 10px !important; color: #696963 !important; font-size: 9px !important; }

.bullboard-list { width: 100%; max-width: 460px; max-height: 42vh; overflow-y: auto; display: grid; gap: 6px; }
.bullboard-loading, .bullboard-empty { color: var(--muted); font-size: 11px; padding: 10px; }
.bullboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .02);
  font-size: 11px;
  text-align: left;
}
.bullboard-row.mine { border-color: rgba(243, 186, 47, .4); background: rgba(243, 186, 47, .06); }
.bullboard-rank { flex: 0 0 26px; color: var(--gold); font-weight: 950; }
.bullboard-wallet { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #d8d3c8; }
.bullboard-holder { color: var(--gold); font-size: 9px; }
.bullboard-rider { color: var(--muted); font-size: 9px; letter-spacing: .06em; }
.bullboard-score { flex: 0 0 auto; font-weight: 950; color: #f7f7f3; }

@media (max-width: 480px) {
  .run-header { padding: calc(6px + env(safe-area-inset-top)) 0 2px; }
  .run-brand { font-size: 15px; }
  .run-brand img { width: 24px; height: 24px; }
  .run-back { padding: 6px 9px; font-size: 9px; }
  .run-title { margin: 0; }
  .run-title h1 { font-size: clamp(18px, 5.6vw, 24px); }
  .run-title span { margin-top: 2px; font-size: 9px; }
  .game-frame { margin: 8px auto 6px; aspect-ratio: auto; height: 80vh; max-height: none; border-radius: 14px; }
  .rider-grid { max-width: 340px; }
  .run-footer { margin: 2px 0 12px; font-size: 8.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
