* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd8ff; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: #1f2a44; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border: 1px solid #b7c2d6; border-bottom-width: 3px; border-radius: 6px; background: #fff; font: 600 12px system-ui; text-align: center; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(20, 40, 80, .55); backdrop-filter: blur(3px); z-index: 20; overflow: auto; padding: 16px; }
.overlay.clear { background: rgba(20, 40, 80, .25); backdrop-filter: none; }
.card { background: #fff; border-radius: 18px; padding: 22px 26px; box-shadow: 0 16px 50px rgba(0, 0, 0, .3); max-width: 420px; width: 100%; max-height: 100%; overflow: auto; }
.card.wide { max-width: 940px; }
h1 { margin: 0 0 4px; font-size: 30px; } h2 { margin: 14px 0 8px; font-size: 17px; }
.sub { margin: 0 0 14px; color: #5b6b8c; }
.cols { display: flex; gap: 28px; flex-wrap: wrap; } .col { flex: 1 1 340px; min-width: 0; }
label { display: block; font-weight: 600; font-size: 14px; margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=number] { width: 100%; padding: 10px 12px; border: 2px solid #c9d3e6; border-radius: 10px; font-size: 16px; user-select: text; }
input:focus { outline: none; border-color: #1e88e5; }
.note { font-size: 12.5px; color: #5b6b8c; margin: 6px 0; line-height: 1.4; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; } .buttons.vertical { flex-direction: column; }
button { padding: 10px 16px; border: 2px solid #c9d3e6; border-radius: 12px; background: #f4f7fc; font: 600 15px system-ui; color: #1f2a44; cursor: pointer; }
button:hover { background: #e7eefa; } button:disabled { opacity: .45; cursor: default; }
button.primary { background: #e53935; border-color: #b71c1c; color: #fff; } button.primary:hover { background: #d32f2f; }
button.small { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.keys { border-collapse: collapse; font-size: 13.5px; } .keys td { padding: 3px 10px 3px 0; vertical-align: top; } .keys td:first-child { white-space: nowrap; }

/* HUD */
#hud > div { position: fixed; z-index: 5; pointer-events: none; }
#topLeft { top: 14px; left: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#modeBadge, #raceInfo, #specInfo, #board, #speed, #roomLabel, #hints, #status, .toast { background: rgba(20, 30, 50, .72); color: #fff; border-radius: 12px; padding: 6px 12px; font-size: 14px; }
#modeBadge { font-weight: 700; }
#raceInfo { line-height: 1.5; } #raceInfo .big { font-size: 76px; font-weight: 900; line-height: 1; text-shadow: 0 3px 0 rgba(0, 0, 0, .35); } #raceInfo small { font-size: 26px; margin-left: 8px; opacity: .8; }
#pos.changed { display: inline-block; animation: pop .35s ease-out; } #pos.first { color: #ffd54f; }
#gap { font-size: 17px; font-weight: 700; color: #ffb74d; margin: 2px 0 4px; } #gap.lead { color: #9ccc65; }
#specInfo { line-height: 1.5; max-width: 320px; }
#board { top: 14px; right: 14px; min-width: 200px; padding: 8px 10px; }
#board .row { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 13.5px; }
#board .row.me { color: #ffe082; font-weight: 700; } #board .row.follow { text-decoration: underline; }
#board img, #podium img, #resultList img { width: 24px; height: 24px; border-radius: 6px; border: 2px solid #fff; object-fit: cover; }
#board .n { width: 22px; text-align: right; opacity: .85; } #board .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; } #board .lp { opacity: .8; font-size: 12px; }
#board h3 { margin: 0 0 4px; font-size: 13px; opacity: .8; font-weight: 600; }
#bottomLeft { left: 14px; bottom: 46px; } #minimap { display: block; border-radius: 12px; background: rgba(20, 30, 50, .72); }
#bottomRight { right: 14px; bottom: 46px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#itemSlot { width: 78px; height: 78px; border-radius: 18px; background: rgba(20, 30, 50, .72); border: 3px solid #fff; display: flex; align-items: center; justify-content: center; font-size: 44px; }
#itemSlot.has { border-color: #ffd54f; box-shadow: 0 0 18px #ffd54f; }
#turboBar { width: 160px; height: 10px; border-radius: 6px; background: rgba(20, 30, 50, .72); overflow: hidden; } #turboFill { height: 100%; width: 0; background: #40c4ff; }
#speed { font-size: 15px; } #speed b { font-size: 28px; font-variant-numeric: tabular-nums; }
#roomLabel { left: 50%; bottom: 70px; transform: translateX(-50%); font-size: 18px; font-weight: 700; }
#countdown { left: 50%; top: 30%; transform: translate(-50%, -50%); font-size: 150px; font-weight: 900; color: #fff; text-shadow: 0 6px 0 #e53935, 0 10px 30px rgba(0, 0, 0, .5); }
#toasts { left: 50%; top: 14px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { font-weight: 600; animation: pop .25s ease-out; max-width: 80vw; text-align: center; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
#hints { left: 14px; bottom: 10px; font-size: 12px; opacity: .9; white-space: nowrap; max-width: calc(100vw - 28px); overflow: hidden; text-overflow: ellipsis; }
#status { right: 14px; bottom: 12px; font-size: 13px; background: none; padding: 0; text-shadow: 0 1px 3px #000; }
#adminBadge { pointer-events: auto; cursor: pointer; color: #1f2a44; background: #ffe082; border: none; border-radius: 10px; padding: 4px 10px; font: 700 13px system-ui; text-shadow: none; }
#adminBadge:hover { background: #ffd54f; }

.panel { position: fixed; z-index: 25; top: 70px; left: 50%; transform: translateX(-50%); width: 300px; background: #fff; border-radius: 16px; padding: 16px 18px; box-shadow: 0 16px 50px rgba(0, 0, 0, .35); }
.panel h2 { margin: 0 0 6px; display: flex; justify-content: space-between; align-items: center; }
label.check { display: flex; align-items: center; gap: 8px; } label.check input { width: 18px; height: 18px; }

#podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 16px 0; }
#podium .step { text-align: center; width: 130px; } #podium .step img { width: 72px; height: 72px; border-radius: 14px; border: 3px solid #1f2a44; }
#podium .block { margin-top: 6px; border-radius: 10px 10px 0 0; color: #fff; font-weight: 800; font-size: 26px; display: flex; align-items: center; justify-content: center; }
#podium .p1 .block { height: 96px; background: #f9a825; } #podium .p2 .block { height: 68px; background: #90a4ae; } #podium .p3 .block { height: 48px; background: #a1662f; }
#podium .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#resultList { margin: 0; padding: 0; list-style: none; columns: 2; font-size: 14px; } #resultList li { display: flex; gap: 8px; align-items: center; padding: 3px 0; break-inside: avoid; }
#resultList .tm { margin-left: auto; font-variant-numeric: tabular-nums; opacity: .8; }
#bodyGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; margin-top: 4px; }
.bodyPick { padding: 2px; border-radius: 10px; background: #f4f7fc; aspect-ratio: 1; }
.bodyPick img { width: 100%; height: 100%; object-fit: contain; display: block; }
.bodyPick.sel { border-color: #e53935; background: #ffebee; }
#wrongWay { left: 50%; top: 22%; transform: translate(-50%, -50%); padding: 10px 26px; border-radius: 16px; background: rgba(198, 40, 40, .9); border: 3px solid #fff; color: #fff; font-size: 44px; font-weight: 900; text-align: center; white-space: nowrap; animation: wrongWay .5s ease-in-out infinite alternate; }
#wrongWay small { display: block; font-size: 16px; font-weight: 600; }
@keyframes wrongWay { to { opacity: .55; } }
#vehPick { display: flex; align-items: stretch; gap: 6px; margin-top: 4px; }
#vehPick > button { flex: 0 0 38px; font-size: 18px; padding: 0; }
#vehStage { position: relative; flex: 1; min-width: 0; border-radius: 14px; overflow: hidden; background: linear-gradient(#bfe3ff, #eaf5ff 55%, #cfd8dc 56%, #b0bec5); }
#vehPreview { display: block; width: 100%; height: 210px; }
#vehName { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-weight: 800; font-size: 15px; color: #1f2a44; text-shadow: 0 1px 0 rgba(255, 255, 255, .7); pointer-events: none; }
.note.credits { margin-top: 10px; font-size: 11.5px; opacity: .75; } .note.credits a { color: inherit; }
#paintGrid { display: flex; gap: 10px; margin-top: 4px; }
.paintPick { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #b0bec5; cursor: pointer; }
.paintPick.sel { box-shadow: 0 0 0 3px #e53935; }
.paintPick:disabled { opacity: .3; cursor: not-allowed; }
#modeInput, #teamsInput { width: 100%; margin-top: 4px; padding: 6px 8px; border-radius: 8px; font: inherit; }
#elimRisk { font-size: 14px; font-weight: 800; color: #ff5252; animation: wrongWay .5s ease-in-out infinite alternate; }
#battleItems { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin: 4px 0 6px; font-size: 13.5px; }
#battleItems label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
#teamPts { font-weight: 800; font-size: 16px; }
#board .row .tm { font-size: 13px; }
