* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #10141a; color: #e8ecf1; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
#cvs { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
/* the card centres, and a card taller than a phone's landscape screen scrolls instead of clipping */
.overlay { position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; background: rgba(8, 10, 14, 0.78); z-index: 20; padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.overlay[hidden] { display: none; }
.card { background: #1b2129; border: 1px solid #2c3540; border-radius: 12px; padding: 22px 24px; width: min(440px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.5); margin: auto; }
.card[hidden] { display: none; }
h1 { margin: 0 0 6px; font-size: 26px; }
h2 { margin: 18px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: #9aa6b4; }
.muted { color: #9aa6b4; }
.small { font-size: 13px; }
.err { color: #ff7b72; margin: 10px 0 0; }
label { display: block; margin: 12px 0; }
input, select { width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 8px; border: 1px solid #3a4553; background: #0f141a; color: #e8ecf1; font-size: 16px; }
.row { display: flex; gap: 10px; margin-top: 12px; }
.row input { margin: 0; }
button { padding: 10px 16px; border-radius: 8px; border: 1px solid #3a4553; background: #27303b; color: #e8ecf1; font-size: 15px; cursor: pointer; }
button.primary { background: #2f7cf6; border-color: #2f7cf6; color: #fff; }
button:disabled { opacity: .45; cursor: default; }
.codebox { font-size: 15px; color: #9aa6b4; }
.codebox b { font-size: 30px; letter-spacing: .18em; color: #fff; margin-left: 10px; font-family: ui-monospace, Menlo, monospace; }
#players { list-style: none; padding: 0; margin: 0; }
#players li { padding: 6px 0; display: flex; align-items: center; gap: 10px; }
#players .dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
#players .host { color: #9aa6b4; font-size: 12px; }

#hud[hidden] { display: none; }
.panel { position: fixed; left: 12px; top: 12px; background: rgba(12, 16, 22, .7); border: 1px solid #2c3540; border-radius: 10px; padding: 10px 12px; min-width: 150px; z-index: 10; font-size: 14px; }
.panel div { display: flex; justify-content: space-between; gap: 12px; }
.panel .me { color: #7dffb0; }
#top { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 18px; background: rgba(12, 16, 22, .7); border: 1px solid #2c3540; border-radius: 10px; padding: 8px 16px; z-index: 10; font-size: 16px; }
#clock { font-family: ui-monospace, Menlo, monospace; }
#arrowWrap { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); text-align: center; z-index: 10; }
#arrow { font-size: 46px; line-height: 1; color: #7dffb0; text-shadow: 0 2px 10px rgba(0,0,0,.6); transition: transform .08s linear; }
#dist { font-size: 14px; color: #e8ecf1; text-shadow: 0 1px 4px #000; }
#speed { position: fixed; right: 16px; bottom: 16px; font-size: 26px; font-family: ui-monospace, Menlo, monospace; text-shadow: 0 1px 6px #000; z-index: 10; }
.centre { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 15; pointer-events: none; font-size: 22px; text-shadow: 0 2px 10px #000; }
.centre[hidden] { display: none; }
.big { font-size: 96px; font-weight: 700; color: #fff; }
#touch { display: none; }
@media (pointer: coarse) {
  #touch { display: block; }
  #speed { bottom: 160px; right: 50%; transform: translateX(50%); }
}
/* the left thumb steers on a horizontal stick, the right thumb holds the pedals: what the
   mobile racers do (steer left, go and stop right, speed in the middle) */
#stick { position: fixed; left: 18px; bottom: 26px; width: 180px; height: 90px; border-radius: 45px; background: rgba(16, 20, 26, .55); border: 1px solid rgba(255,255,255,.18); z-index: 12; touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; background: rgba(255,255,255,.75); box-shadow: 0 2px 10px rgba(0,0,0,.5); }
#pedals { position: fixed; right: 18px; bottom: 26px; display: flex; flex-direction: column; gap: 10px; z-index: 12; }
#pedals button { width: 120px; font-size: 18px; font-weight: 700; letter-spacing: .06em; border-radius: 16px; touch-action: none; user-select: none; -webkit-user-select: none; }
#gas { height: 96px; background: rgba(47, 124, 246, .8); border-color: #2f7cf6; }
#brake { height: 64px; background: rgba(229, 72, 77, .8); border-color: #e5484d; }
#pedals button.on { filter: brightness(1.35); }
#opts { position: fixed; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 14px; font-size: 13px; color: #cbd3dc; z-index: 12; background: rgba(12, 16, 22, .55); padding: 4px 10px; border-radius: 8px; }
#opts input { width: auto; margin: 0 4px 0 0; }
#results { font-size: 18px; padding-left: 24px; }
#results li { margin: 6px 0; }

#showcase { display: flex; gap: 14px; align-items: center; margin-top: 8px; }
#preview { width: 180px; height: 130px; border-radius: 10px; background: #0f141a; flex: none; }
#stats { flex: 1; }
.stat { display: grid; grid-template-columns: 86px 1fr 70px; align-items: center; gap: 8px; font-size: 13px; margin: 5px 0; color: #cbd3dc; }
.stat .bar { height: 8px; border-radius: 4px; background: #0f141a; overflow: hidden; }
.stat .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2f7cf6, #7dffb0); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.stat b { font-weight: 500; text-align: right; font-family: ui-monospace, Menlo, monospace; white-space: nowrap; font-size: 12px; }
.modes button { flex: 1; text-align: left; line-height: 1.2; }
.modes button small { display: block; color: #9aa6b4; font-size: 12px; margin-top: 2px; }
.modes button.on { border-color: #2f7cf6; background: #1f3a63; }
#btnReset { position: fixed; right: 16px; top: 64px; z-index: 11; background: rgba(39, 48, 59, .8); }
#flagHud { position: fixed; top: 110px; left: 50%; transform: translateX(-50%); z-index: 10; background: rgba(12, 16, 22, .7); border: 1px solid #2c3540; border-radius: 10px; padding: 6px 14px; font-size: 15px; }
#flagHud[hidden] { display: none; }
#flagHud.mine { border-color: #7dffb0; color: #7dffb0; }
@media (pointer: coarse) { #btnReset { top: auto; bottom: 150px; right: 50%; transform: translateX(50%); } }
@media (max-height: 500px) { .card { padding: 14px 18px; } h1 { font-size: 20px; } h2 { margin: 10px 0 6px; } #preview { width: 120px; height: 90px; } .stat { margin: 3px 0; } }
