/* Drift Dash — builds on /style.css (light theme, cards, buttons) */
#raceView:not([hidden]) ~ .music-btn { display: none; } /* in a race the toggle lives in the HUD */
.dd-logo { font-size: 24px; }
.view.wide { max-width: 1120px; align-items: stretch; }

/* ---------- entry ---------- */
.hero-road { position: relative; height: 64px; margin: -6px -6px 0; border-radius: 16px; overflow: hidden;
  background: repeating-linear-gradient(90deg, #fff 0 26px, transparent 26px 52px) center / 100% 4px no-repeat, linear-gradient(#5d6175, #4a4e61); }
.hero-car { position: absolute; top: 4px; font-size: 30px; transform: scaleX(-1); animation: zoom 3.2s linear infinite; }
.hero-car.two { top: 30px; animation-duration: 4.1s; animation-delay: -1.5s; }
@keyframes zoom { from { left: -15%; } to { left: 110%; } }

/* ---------- setup ---------- */
.setup-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.setup-title { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -.5px; }
.share { display: flex; gap: 8px; min-width: min(420px, 100%); }
.share input { flex: 1; font-size: 14px; padding: 12px 14px; color: #4a4670; background: #fff; }
.setup-grid { display: grid; grid-template-columns: 1.15fr 1.15fr .9fr; gap: 16px; align-items: start; }
.panel { padding: 20px; }
.panel h2 { margin: 0 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.host-only-note { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; color: #a9a5c6; }
.count { margin-left: auto; color: var(--ink); }

.cars { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.car-card { text-align: left; background: #fff; border: 2px solid transparent; border-radius: 16px; padding: 10px 12px 12px; box-shadow: 0 4px 14px -8px rgba(60,40,160,.3); transition: transform .15s, border-color .2s, box-shadow .2s; }
.car-card:hover { transform: translateY(-2px); }
.car-card.sel { border-color: var(--c); box-shadow: 0 10px 26px -12px var(--c); }
.car-card canvas { display: block; width: 100%; height: 54px; }
.car-card .cname { font-weight: 800; font-size: 16px; line-height: 1.15; }
.car-card .ctag { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 1px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; margin-top: 6px; font-size: 11px; color: var(--muted); align-items: center; }
.bar { height: 6px; border-radius: 4px; background: #efedf9; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--c); }

.tracks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.track-card { background: #fff; border: 2px solid transparent; border-radius: 16px; padding: 8px; text-align: left; box-shadow: 0 4px 14px -8px rgba(60,40,160,.3); transition: transform .15s, border-color .2s; }
.track-card:not(:disabled):hover { transform: translateY(-2px); }
.track-card:disabled { cursor: default; opacity: .55; }
.track-card.sel { border-color: #ff6a6a; opacity: 1; }
.track-card canvas { display: block; width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; }
.track-card .tname { font-weight: 700; font-size: 14px; margin: 6px 2px 0; }
.record { margin: 12px 2px 4px; font-size: 13px; color: var(--muted); min-height: 18px; }
.record b { color: var(--ink); }

.opts { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.opt { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.seg { display: inline-flex; background: #efedf9; border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.sel { background: #fff; color: var(--ink); box-shadow: 0 2px 8px -3px rgba(60,40,160,.35); }
.seg button:disabled { cursor: default; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: #efedf9; border-radius: 12px; padding: 3px; }
.stepper button { border: 0; width: 32px; height: 30px; border-radius: 9px; background: #fff; font-size: 18px; font-weight: 700; }
.stepper button:disabled { opacity: .4; cursor: default; }
.stepper b { min-width: 26px; text-align: center; }

.racers { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.racers li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 8px 10px; box-shadow: 0 4px 12px -8px rgba(60,40,160,.3); font-weight: 700; }
.racers li canvas { width: 46px; height: 26px; flex: none; }
.racers li .rn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.racers li small { color: var(--muted); font-weight: 600; font-size: 11px; }
.racers li.bot { background: #f7f6fd; color: var(--muted); }
.racers li.offline { opacity: .5; }
.wait-host { text-align: center; color: var(--muted); margin: 6px 0 0; }

@media (max-width: 980px) { .setup-grid { grid-template-columns: 1fr 1fr; } .racers-panel { grid-column: 1 / -1; } }
@media (max-width: 640px) { .setup-grid { grid-template-columns: 1fr; } .setup-title { font-size: 26px; } }

/* ---------- race view ---------- */
.race-view { position: fixed; inset: 0; z-index: 20; background: #1b1735; touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: max(12px, env(safe-area-inset-top)) 14px 0; pointer-events: none; }
.hud-left { background: rgba(255,255,255,.88); border-radius: 18px; padding: 8px 16px 10px; box-shadow: 0 10px 30px -12px rgba(20,10,60,.5); backdrop-filter: blur(8px); }
.pos { font-weight: 900; line-height: 1; color: var(--ink); }
.pos b { font-size: 44px; }
.pos sup { font-size: 18px; margin-left: 1px; }
.pos span { font-size: 18px; color: var(--muted); margin-left: 4px; }
.lapline { font-weight: 700; font-size: 14px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.hud-right { display: flex; gap: 8px; align-items: flex-start; pointer-events: auto; }
#minimap { width: 170px; height: 120px; background: rgba(255,255,255,.85); border-radius: 16px; box-shadow: 0 10px 30px -12px rgba(20,10,60,.5); }
.icon-btn { border: 0; width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.88); font-size: 18px; box-shadow: 0 10px 30px -12px rgba(20,10,60,.5); }
.standings { position: absolute; left: 14px; top: calc(max(12px, env(safe-area-inset-top)) + 96px); margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.standings li { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.78); border-radius: 10px; padding: 3px 8px 3px 4px; color: var(--ink); transition: transform .3s; }
.standings li i { width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-style: normal; font-size: 11px; }
.standings li.me { background: #fff; box-shadow: 0 0 0 2px var(--c); }
.standings li.done::after { content: '🏁'; }

.center-msg { position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%); font-size: clamp(38px, 9vw, 86px); font-weight: 900; color: #fff; letter-spacing: -1px;
  -webkit-text-stroke: 6px #1e1b3a; paint-order: stroke fill; text-shadow: 0 8px 0 rgba(30,20,90,.35), 0 12px 40px rgba(30,20,90,.45); pointer-events: none; white-space: nowrap; }
.center-msg.pop { animation: msgpop .7s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes msgpop { from { transform: translate(-50%, -50%) scale(.3); opacity: 0; } }
.lights { position: absolute; left: 50%; top: 16%; transform: translateX(-50%); display: flex; gap: 12px; padding: 12px 16px; background: #1e1b3a; border-radius: 20px; box-shadow: 0 16px 40px -14px #000; }
.lights i { width: 34px; height: 34px; border-radius: 50%; background: #3a3560; transition: background .1s, box-shadow .1s; }
.lights i.on { background: #ff4d6d; box-shadow: 0 0 22px #ff4d6d; }
.lights.go i { background: #22c55e; box-shadow: 0 0 22px #22c55e; }
.banner { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -10px); opacity: 0; padding: 10px 18px; border-radius: 999px; background: #fff; font-weight: 800; color: var(--ink);
  box-shadow: 0 14px 40px -14px rgba(20,10,60,.6); transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap; }
.banner.show { opacity: 1; transform: translate(-50%, 0); }

/* touch controls */
.touch { position: absolute; left: 0; right: 0; bottom: 0; display: none; justify-content: space-between; align-items: flex-end; padding: 0 16px max(16px, env(safe-area-inset-bottom)); pointer-events: none; }
.touch.show { display: flex; }
.touch-left, .touch-right { display: flex; gap: 14px; align-items: flex-end; pointer-events: auto; }
.touch-right { display: grid; grid-template-columns: auto auto; grid-template-areas: ". nitro" "honk brake"; gap: 12px 12px; align-items: end; justify-items: center; }
.touch-right .small { grid-area: honk; }
.touch-right .nitro { grid-area: nitro; }
.touch-right .brake { grid-area: brake; }
.tbtn { width: 84px; height: 84px; border-radius: 50%; border: 0; font-size: 30px; font-weight: 900; color: var(--ink); background: rgba(255,255,255,.82);
  box-shadow: 0 10px 26px -10px rgba(20,10,60,.6), inset 0 -4px 0 rgba(60,40,160,.12); backdrop-filter: blur(6px); touch-action: none; transition: transform .08s, background .1s; position: relative; }
.tbtn.down { transform: scale(.92); background: #fff; box-shadow: 0 4px 14px -8px rgba(20,10,60,.6), inset 0 3px 0 rgba(60,40,160,.12); }
.tbtn.brake { font-size: 14px; letter-spacing: 1px; background: rgba(255,255,255,.82); }
.tbtn.brake.down { background: #ffe1e7; }
.tbtn.nitro { width: 74px; height: 74px; display: grid; place-items: center; background: linear-gradient(135deg, #ff8a4c, #ff4d6d); }
.tbtn.nitro span { position: relative; font-size: 28px; }
.tbtn.nitro svg { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); }
.tbtn.nitro .ring-bg { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 3; }
.tbtn.nitro .ring { fill: none; stroke: #ffd23d; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100.5; stroke-dashoffset: 0; transition: stroke-dashoffset .1s; }
.tbtn.small { width: 52px; height: 52px; font-size: 22px; }
.keys-hint { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.85); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); pointer-events: none; white-space: nowrap; }
.keys-hint .nitro-mini { display: inline-block; vertical-align: middle; width: 60px; height: 8px; border-radius: 4px; background: #efedf9; margin-left: 8px; overflow: hidden; }
.keys-hint .nitro-mini i { display: block; height: 100%; background: linear-gradient(90deg, #ff8a4c, #ff4d6d); }
@media (max-width: 600px) {
  .tbtn { width: 72px; height: 72px; }
  .tbtn.nitro { width: 64px; height: 64px; }
  .tbtn.small { width: 46px; height: 46px; }
  #minimap { width: 120px; height: 85px; }
  .pos b { font-size: 34px; }
  .standings { display: none; }
}

/* results */
.results { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(235, 232, 252, .45); backdrop-filter: blur(6px); }
.results-card { width: min(460px, 100%); padding: 26px 22px; text-align: center; animation: rise .5s cubic-bezier(.2,.9,.3,1.2) both; max-height: calc(100dvh - 32px); overflow: auto; }
.results-card h2 { margin: 0 0 16px; font-size: 28px; }
.podium { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.podium li { display: grid; grid-template-columns: 34px 46px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: #f7f6fd; font-weight: 700; }
.podium li.me { background: #fff4f6; box-shadow: 0 0 0 2px #ff6a8a; }
.podium li .medal { font-size: 22px; text-align: center; }
.podium li canvas { width: 46px; height: 26px; }
.podium li small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; }
.podium li .t { font-variant-numeric: tabular-nums; text-align: right; }
.results-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
