/* Pothole Rally — warm asphalt-and-chai palette, phone first. */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: radial-gradient(circle at 15% 0%, #4a3222 0%, #241812 55%, #150e0a 100%);
  color: #fff3e0; font: 500 15px/1.4 'Segoe UI', Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body { display: flex; flex-direction: column; padding-bottom: 44px; }
button, input, select { font: inherit; }

#toasts { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 90; pointer-events: none; padding: 0 10px; }
.toast { max-width: 420px; background: #1c1108; border: 2px solid #FFB300; border-radius: 14px; padding: 8px 14px; font-size: 13px; text-align: center; box-shadow: 0 6px 16px rgba(0,0,0,.5); animation: tIn .2s ease-out, tOut .3s ease-in 3.2s forwards; }
.toast b { display: block; font-size: 14px; color: #FFD54A; }
.toast small { display: block; color: #ffd9a8; font-style: italic; margin-top: 2px; }
.toast.hit { border-color: #ff6b4a; } .toast.hit b { color: #ff9c85; }
.toast.ok { border-color: #7ee0c7; } .toast.ok b { color: #7ee0c7; }
@keyframes tIn { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tOut { to { opacity: 0; transform: translateY(-8px); } }

.screen { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 16px 12px 24px; }
.screen[hidden] { display: none; }
.card { width: 100%; max-width: 480px; background: rgba(40, 26, 18, .7); border: 1px solid rgba(255, 179, 0, .3); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card.wide, .screen.wide .card { max-width: 900px; }
.title { margin: 0; font-size: 22px; font-weight: 800; color: #FFB300; text-align: center; }
.title .sub { display: block; font-size: 12px; font-weight: 600; color: #e9cfb0; margin-top: 2px; }
.board-title { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: #e9cfb0; }
.hint { font-size: 12px; color: #d9bfa0; }
.error-msg { color: #ff8a5c; font-size: 13px; font-weight: 700; text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; color: #e9cfb0; }
input, select { padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255,179,0,.4); background: #150e0a; color: #fff3e0; font-size: 15px; min-width: 0; }
input:focus, select:focus { outline: 2px solid #FF9933; }
input[type=range] { padding: 0; accent-color: #FFB300; }
.row input:not([type=range]) { flex: 1; }

.btn { padding: 10px 14px; border-radius: 999px; border: 1px solid rgba(255,179,0,.45); background: rgba(255,255,255,.06); color: #fff3e0; font-weight: 800; font-size: 14px; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(90deg, #FFB300, #FF7A1A); color: #241100; border: 0; }
.btn:disabled { opacity: .45; cursor: default; }

.ride-picker { display: flex; gap: 8px; }
.ride-picker button { flex: 1; font-size: 28px; padding: 6px 0; border-radius: 14px; border: 2px solid transparent; background: #150e0a; cursor: pointer; }
.ride-picker button.sel { border-color: #FFB300; background: #2a1c10; }

.road-list { display: flex; flex-direction: column; gap: 8px; }
.road { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,179,0,.2); }
.road .info { flex: 1; min-width: 0; }
.road .name { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.road .meta { font-size: 11px; color: #d9bfa0; }
.road .btn { padding: 8px 12px; font-size: 13px; }
.road .del { border-color: rgba(255,120,90,.5); color: #ff9c85; }

/* ── Playing ── */
.screen.play { padding: 0; align-items: stretch; }
#stage { position: relative; flex: 1; display: flex; justify-content: center; align-items: stretch; background: #0d0806; min-height: 0; }
#cv { display: block; height: calc(100vh - 44px); height: calc(100dvh - 44px); max-width: 100vw; aspect-ratio: 360 / 640; touch-action: none; background: #2b2b2f; }
#hud { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: min(100vw, calc((100dvh - 44px) * 0.5625)); height: 0; pointer-events: none; }
.hud-clocks { position: absolute; top: 28px; left: 8px; display: flex; flex-direction: column; gap: 4px; }
.hud-health { position: absolute; top: 8px; left: 8px; width: 96px; height: 14px; background: rgba(0,0,0,.6); border-radius: 8px; overflow: hidden; }
.hud-health i { display: block; height: 100%; width: 100%; background: #4ade80; transition: width .2s, background .2s; }
.hud-health span { position: absolute; inset: 0; text-align: center; font-size: 10px; font-weight: 800; line-height: 14px; }
.clock { background: rgba(0,0,0,.6); border-radius: 10px; padding: 3px 9px; font-size: 10px; line-height: 1.15; }
.clock b { display: block; font-size: 16px; }
.clock.g b { color: #7ee0c7; } .clock.r b { color: #ffb066; }
.clock.r.bad b { color: #ff6b4a; }
#mini { position: absolute; top: 8px; right: 8px; width: 64px; height: 64px; background: rgba(0,0,0,.55); border-radius: 12px; }
.hud-bar { position: absolute; top: 76px; right: 8px; width: 64px; height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.hud-bar i { display: block; height: 100%; width: 0; background: #FFB300; }
.hud-hits { position: absolute; top: 88px; right: 8px; font-size: 12px; font-weight: 800; background: rgba(0,0,0,.55); border-radius: 8px; padding: 1px 7px; }
.hud-quit { position: absolute; top: 4px; left: 112px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; pointer-events: auto; cursor: pointer; }
.race-board { position: absolute; top: 118px; right: 8px; background: rgba(0,0,0,.55); border-radius: 10px; padding: 4px 8px; font-size: 11px; font-weight: 700; pointer-events: none; }
.race-board[hidden] { display: none; }
#controls { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); width: min(100vw, calc((100dvh - 44px) * 0.5625)); display: grid; grid-template-columns: 1fr 2fr 2fr 1fr; gap: 8px; padding: 0 10px; }
.ctl { height: 58px; border-radius: 16px; border: 2px solid rgba(255,255,255,.25); background: rgba(0,0,0,.5); color: #fff; font-size: 15px; font-weight: 800; touch-action: manipulation; cursor: pointer; }
.ctl.arrow { font-size: 22px; }
.ctl.honk { border-color: #FFB300; }
.ctl:active { transform: scale(.95); }
.ctl.jugaad { --m: 0%; border-color: #7ee0c7; background: linear-gradient(90deg, rgba(126,224,199,.55) var(--m), rgba(0,0,0,.5) var(--m)); }
.ctl.jugaad.ready { animation: ready 0.7s ease-in-out infinite; }
.ctl.honk:disabled { opacity: .5; }
@keyframes ready { 50% { box-shadow: 0 0 18px #7ee0c7; } }

/* ── Result ── */
.stars { text-align: center; font-size: 34px; color: #FFB300; letter-spacing: 6px; }
.res-big { text-align: center; font-size: 28px; font-weight: 900; color: #ffb066; }
.res-sub { text-align: center; color: #7ee0c7; font-weight: 700; }
.res-roast { text-align: center; font-style: italic; color: #ffe0b8; }
.res-list { margin: 0; padding: 0; list-style: none; font-size: 13px; color: #e9cfb0; display: grid; gap: 4px; }
.winners-list { display: flex; flex-direction: column; gap: 6px; }
.rank-row { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 10px; background: rgba(255,179,0,.1); font-weight: 700; }
.rank-row .pl { width: 24px; color: #FFB300; font-weight: 900; }
.rank-row .nm { flex: 1; } .rank-row .tm { color: #ffb066; font-size: 12px; }

/* ── Map maker ── */
.ed-map { height: 340px; border-radius: 14px; overflow: hidden; border: 1px solid rgba(255,179,0,.3); background: #1a120c; }
.ed-results { display: flex; flex-direction: column; gap: 4px; }
.ed-result { display: flex; gap: 6px; align-items: center; padding: 6px 8px; border-radius: 10px; border: 1px solid rgba(255,179,0,.25); background: rgba(255,255,255,.05); font-size: 13px; }
.ed-result .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-result .src { background: #4285f4; color: #fff; border-radius: 6px; padding: 0 5px; margin-right: 6px; font-size: 10px; }
.ed-result .btn { padding: 5px 9px; font-size: 12px; flex-shrink: 0; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-map { cursor: crosshair; }
.palette button { min-height: 34px; padding: 6px 9px; border-radius: 999px; border: 1px solid rgba(255,179,0,.3); background: #150e0a; color: #fff3e0; font-size: 12px; font-weight: 700; cursor: pointer; }
.palette button.sel { background: #FFB300; color: #241100; }
.ed-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .ed-grid { grid-template-columns: 1fr 1fr; } }
.ed-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.ed-item { display: flex; gap: 8px; align-items: center; font-size: 12px; padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.05); }
.ed-item .x { margin-left: auto; background: none; border: 0; color: #ff9c85; cursor: pointer; font-size: 14px; }
.ed-item .cap { color: #d9bfa0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.saved-box { padding: 10px; border-radius: 12px; background: rgba(126,224,199,.12); border: 1px solid #7ee0c7; font-size: 13px; }
.saved-box .code { font-size: 26px; font-weight: 900; letter-spacing: 6px; color: #7ee0c7; }
.hz-marker { font-size: 20px; text-align: center; line-height: 24px; filter: drop-shadow(0 1px 2px #000); }

/* ── Ideas ── */
.emoji-in { max-width: 70px; text-align: center; font-size: 22px; }
.idea-list { display: flex; flex-direction: column; gap: 8px; }
.idea { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.05); }
.idea .em { font-size: 30px; }
.idea .body { flex: 1; min-width: 0; }
.idea .nm { font-weight: 800; }
.idea .ds { font-size: 12px; color: #d9bfa0; }
.idea .sev { font-size: 11px; color: #ffb066; }
.vote { min-width: 62px; }
.vote.on { background: #FFB300; color: #241100; }

/* ── Race lobby ── */
.room-code-label { text-align: center; font-size: 11px; letter-spacing: 2px; font-weight: 800; color: #e9cfb0; }
.room-code { text-align: center; font-size: 40px; font-weight: 900; letter-spacing: 10px; color: #FFB300; }
.code-in { text-align: center; letter-spacing: 6px; text-transform: uppercase; }
.player-list { display: flex; flex-direction: column; gap: 6px; }
.player-row { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.05); font-weight: 700; }
.player-row .em { font-size: 22px; }
.badge { font-size: 9px; font-weight: 800; background: #FFB300; color: #241100; padding: 2px 6px; border-radius: 999px; }
.player-row.off { opacity: .4; }

@media (max-width: 380px) { .ctl { height: 52px; font-size: 13px; } }

/* shown only after a win — make it the obvious next step */
#btnShare { background: linear-gradient(180deg, #7fe3c1, #2fbf71) !important; color: #0e2a1c !important; border: 0 !important; font-weight: 800; animation: winPulse 1.6s ease-in-out infinite; }
@keyframes winPulse { 50% { transform: scale(1.04); } }
