:root { --ink: #eaf2ff; --hot: #ff4fa8; --cool: #6fe3ff; --gold: #ffd84a; --panel: rgba(6, 8, 28, .82); --edge: #4a5cff; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; color: var(--ink); font-family: VT323, ui-monospace, monospace; font-size: 22px; }
canvas#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; }
.hidden { display: none !important; }
.dim { opacity: .6; } .small { font-size: 17px; }
.k { color: #9fb2ff; font-size: .8em; letter-spacing: 1px; }
button { font: inherit; color: var(--ink); background: linear-gradient(#2a3290, #121650); border: 2px solid #8a98ff; border-radius: 3px;
  padding: 6px 16px; cursor: pointer; letter-spacing: 2px; text-shadow: 2px 2px 0 #000; box-shadow: inset 0 1px 0 #b8c2ff55, 0 3px 0 #000a; }
button:hover, button.sel { background: linear-gradient(#5a3cff, #2a1690); border-color: #fff; color: #fff; }
button.big { background: linear-gradient(#ff5fb0, #a0185c); border-color: #ffd0e8; }
button.big:hover { background: linear-gradient(#ff8fc8, #c0287c); }
button:disabled { opacity: .45; cursor: default; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; z-index: 5; }
#loading { background: #000; gap: 14px; letter-spacing: 3px; }
#bar { width: 280px; height: 12px; border: 2px solid #4a5cff; } #bar > div { height: 100%; width: 0; background: linear-gradient(90deg, #4a5cff, #ff4fa8); }
#lmsg { opacity: .5; font-size: 16px; }
.blink { animation: blink 1.1s steps(2) infinite; } @keyframes blink { 50% { opacity: 0; } }

.logo { font-family: 'Press Start 2P', monospace; font-style: italic; display: flex; align-items: baseline; gap: .3em; transform: skewX(-8deg); }
.logo .l1 { font-size: min(8vw, 76px); background: linear-gradient(#fff 10%, #9fd8ff 45%, #2a48ff 52%, #b8e8ff 90%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(4px 4px 0 #0a0830) drop-shadow(0 0 14px #4a7cff); }
.logo .l2 { font-size: min(10vw, 96px); background: linear-gradient(#fff3a0 10%, #ffb020 50%, #ff3d6e 55%, #ffd0e0 95%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(4px 4px 0 #300818) drop-shadow(0 0 14px #ff4f8a); }
.sub { letter-spacing: 6px; color: var(--cool); text-shadow: 0 0 10px #2af; font-size: min(5vw, 26px); text-align: center; }
.menu { display: flex; flex-direction: column; gap: 10px; width: min(320px, 90vw); margin-top: 10px; }
.menu button { font-size: 26px; }
.hint { opacity: .5; font-size: 17px; }
#title { background: linear-gradient(transparent 55%, #000c); }

.panel { background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px #000, 0 0 30px #2a3cff55, inset 0 0 40px #1a2a8044; padding: 14px 20px; width: min(520px, 94vw); }
.panel.wide { width: min(780px, 94vw); } .panel.tall { max-height: 88vh; display: flex; flex-direction: column; }
.ptitle { font-family: 'Press Start 2P', monospace; font-size: 15px; color: var(--gold); letter-spacing: 2px; margin-bottom: 10px; text-shadow: 2px 2px 0 #000; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
#garage { justify-content: space-between; }
.carrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#carName { font-size: 34px; letter-spacing: 3px; text-align: center; flex: 1; color: #fff; text-shadow: 0 0 12px #6fe3ff; }
#carBy { text-align: center; font-size: 16px; }
.namefield { display: flex; align-items: center; gap: 12px; font-size: 24px; color: #9fb2ff; }
.namefield input { flex: 1; min-width: 0; font: inherit; font-size: 28px; background: #000; color: var(--hot); border: 2px solid #4a5cff; padding: 4px 10px; text-transform: uppercase; letter-spacing: 3px; outline: none; }
.namefield input:focus { border-color: var(--hot); }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; text-shadow: 2px 2px 0 #000, 0 0 6px #000; }
#hud b { font-weight: normal; color: #fff; }
#hLap { position: absolute; left: 18px; top: 12px; font-size: 40px; }
#hLap b { font-size: 56px; color: var(--gold); }
.tag { font-size: 22px; padding: 1px 8px; border: 2px solid currentColor; vertical-align: middle; color: var(--cool); }
#hTime { position: absolute; right: 18px; top: 12px; text-align: right; font-size: 40px; }
#splits { font-size: 22px; opacity: .85; }
#hPos { position: absolute; left: 18px; top: 84px; font-family: 'Press Start 2P', monospace; font-style: italic; }
#hPos b { font-size: 44px; color: var(--hot); } #hPos .k { font-size: 18px; }
#map { position: absolute; left: 12px; bottom: 12px; width: 180px; height: 180px; image-rendering: pixelated; }
#speedo { position: absolute; right: 14px; bottom: 10px; width: 220px; height: 220px; }
#gauge { position: absolute; inset: 0; width: 100%; height: 100%; }
#kmh { position: absolute; left: 0; right: 0; top: 74px; text-align: center; font-family: 'Press Start 2P', monospace; font-size: 34px; font-style: italic; color: #fff; }
#speedo .unit { position: absolute; left: 0; right: 0; top: 116px; text-align: center; }
#mbps { position: absolute; left: 0; right: 0; top: 150px; text-align: center; font-size: 28px; color: var(--cool); }
#lights { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); display: flex; gap: 10px; padding: 10px 14px; background: #000c; border: 2px solid #333; opacity: 0; transition: opacity .3s; }
#lights.on { opacity: 1; }
#lights i { width: 34px; height: 34px; border-radius: 50%; background: #300; box-shadow: inset 0 0 6px #000; }
#lights i.r { background: radial-gradient(#ff9a8a, #ff1a10 60%, #800); box-shadow: 0 0 18px #f22; }
#lights.go i { background: radial-gradient(#b8ffb0, #2f2 60%, #070); box-shadow: 0 0 18px #2f4; }
#banner { position: absolute; left: 0; right: 0; top: 38%; text-align: center; font-family: 'Press Start 2P', monospace; font-style: italic; font-size: min(9vw, 64px); color: #fff;
  text-shadow: 4px 4px 0 #a0185c, 0 0 20px var(--hot); opacity: 0; transition: opacity .25s; }
#banner.on { opacity: 1; }
#banner small { display: block; font-size: .35em; margin-top: 14px; color: var(--cool); text-shadow: 2px 2px 0 #000; }

.total { font-family: 'Press Start 2P', monospace; font-style: italic; font-size: min(8vw, 46px); text-align: center; color: var(--gold); text-shadow: 3px 3px 0 #000, 0 0 16px #ffb020; margin: 6px 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.grid3 > div { border: 1px solid #2a3cff88; padding: 8px 4px; background: #0008; }
.grid3 b { font-size: 44px; font-weight: normal; color: #fff; }
.msg { text-align: center; min-height: 1.3em; margin-top: 10px; color: var(--cool); }
.how { line-height: 1.25; padding-left: 20px; } .how li { margin: 6px 0; } .how b { color: var(--gold); font-weight: normal; }
.tablewrap { overflow: auto; flex: 1; min-height: 120px; }
table { width: 100%; border-collapse: collapse; font-size: 21px; }
th { text-align: left; color: #9fb2ff; font-weight: normal; border-bottom: 2px solid #4a5cff; padding: 2px 6px; position: sticky; top: 0; background: #080a24; }
td { padding: 2px 6px; border-bottom: 1px solid #1a2260; white-space: nowrap; }
tr.me td { background: #ff4fa833; color: #fff; }
tr:nth-child(1) td:first-child { color: var(--gold); } tr:nth-child(2) td:first-child { color: #d8e0f0; } tr:nth-child(3) td:first-child { color: #e09050; }
#mute { position: fixed; right: 10px; top: 10px; z-index: 6; padding: 2px 10px; font-size: 20px; }
#mute.off { opacity: .4; text-decoration: line-through; }
body.racing #mute { top: auto; bottom: 240px; }

@media (max-width: 640px) {
  html, body { font-size: 19px; }
  #hLap { font-size: 28px; } #hLap b { font-size: 40px; } #hTime { font-size: 28px; }
  #hPos { top: 64px; } #hPos b { font-size: 30px; }
  #map { width: 110px; height: 110px; }
  #speedo { transform: scale(.7); transform-origin: bottom right; }
  .grid3 b { font-size: 32px; }
  table { font-size: 17px; } #board th:nth-child(3), #board td:nth-child(3) { display: none; }
  body.racing #mute { bottom: 170px; }
}

#cardImg { display: block; width: 100%; aspect-ratio: 1200 / 630; background: #000; border: 2px solid #4a5cff; image-rendering: auto; }
#replayHud { position: fixed; inset: 0; z-index: 4; cursor: pointer; text-shadow: 2px 2px 0 #000; }
#replayHud .rec { position: absolute; left: 18px; top: 14px; font-family: 'Press Start 2P', monospace; font-size: 18px; color: #fff; display: flex; align-items: center; gap: 10px; }
#replayHud .rec i { width: 14px; height: 14px; border-radius: 50%; background: #f22; box-shadow: 0 0 10px #f22; animation: blink 1s steps(2) infinite; }
#rpInfo { position: absolute; right: 18px; top: 12px; font-size: 30px; text-align: right; }
#rpBar { position: absolute; left: 18px; right: 18px; bottom: 18px; height: 6px; background: #0008; border: 1px solid #4a5cff; }
#rpBar > div { height: 100%; width: 0; background: linear-gradient(90deg, #4a5cff, #ff4fa8); }
#replayHud .rphint { position: absolute; left: 0; right: 0; bottom: 32px; text-align: center; opacity: .55; font-size: 18px; }
/* letterbox bars for the TV-replay feel */
#replayHud::before, #replayHud::after { content: ''; position: absolute; left: 0; right: 0; height: 7vh; background: #000; }
#replayHud::before { top: 0; } #replayHud::after { bottom: 0; }
#replayHud > * { z-index: 1; }

/* head to head */
.lbcar { font-size: 28px; letter-spacing: 2px; text-align: center; flex: 1; color: #fff; text-shadow: 0 0 10px #6fe3ff; }
.carrow.small .lbcar { font-size: 22px; }
#lbIntro > * { margin: 10px 0; }
.joinrow input { font: inherit; font-size: 26px; width: 7em; background: #000; color: var(--gold); border: 2px solid #4a5cff; padding: 2px 10px; text-transform: uppercase; letter-spacing: 6px; text-align: center; outline: none; }
.invite { text-align: center; font-size: 26px; }
.invite b { font-family: 'Press Start 2P', monospace; font-size: 30px; color: var(--gold); letter-spacing: 6px; text-shadow: 3px 3px 0 #000; margin-left: 10px; }
.slots { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin: 14px 0 8px; }
.slot { border: 2px solid #2a3cff; background: #0008; padding: 10px; text-align: center; min-height: 86px; }
.slot.me { border-color: var(--hot); }
.slot .nm { font-size: 30px; color: #fff; } .slot .cr { color: #9fb2ff; } .slot .st { font-size: 18px; color: var(--cool); }
.slot.empty { opacity: .55; display: flex; align-items: center; justify-content: center; }
.vs { font-family: 'Press Start 2P', monospace; font-style: italic; color: var(--hot); font-size: 22px; text-shadow: 2px 2px 0 #000; }
#dragHud { position: fixed; inset: 0; pointer-events: none; z-index: 4; text-shadow: 2px 2px 0 #000, 0 0 6px #000; }
.dp { position: absolute; left: 14px; top: 12px; width: min(42vw, 300px); background: #05061acc; border: 2px solid var(--hot); padding: 6px 10px; }
.dp.right { left: auto; right: 14px; border-color: var(--cool); text-align: right; }
.dp .dn { font-size: 26px; color: #fff; } .dp .dm { font-size: 34px; color: var(--gold); }
.dp .dbar { height: 8px; background: #1a2060; margin: 4px 0; } .dp .dbar > div { height: 100%; width: 0; background: var(--hot); }
.dp.right .dbar > div { background: var(--cool); margin-left: auto; }
.dp .ds { font-size: 18px; color: #9fb2ff; min-height: 1.1em; }
#dragBanner { position: absolute; left: 0; right: 0; top: 40%; text-align: center; font-family: 'Press Start 2P', monospace; font-style: italic; font-size: min(8vw, 54px); color: #fff;
  text-shadow: 4px 4px 0 #a0185c, 0 0 20px var(--hot); }
#dragBanner small { display: block; font-size: .38em; margin-top: 12px; color: var(--cool); text-shadow: 2px 2px 0 #000; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > div { border: 2px solid #2a3cff88; padding: 8px 12px; background: #0008; }
.grid2 > div.win { border-color: var(--gold); box-shadow: 0 0 16px #ffb02066; }
.grid2 .nm { font-size: 30px; color: #fff; } .grid2 .et { font-family: 'Press Start 2P', monospace; font-size: 22px; color: var(--gold); margin: 6px 0; }
.grid2 .ln { display: flex; justify-content: space-between; } .grid2 .ln b { font-weight: normal; color: #fff; }

/* segmented pickers (lobby mode, typing track, leaderboard tabs) */
.row.seg { gap: 6px; }
.row.seg button { font-size: 18px; padding: 4px 10px; background: linear-gradient(#1a1f50, #0c0f30); border-color: #4a5cff; }
.row.seg button.sel { background: linear-gradient(#5a3cff, #2a1690); border-color: #fff; }
.center { text-align: center; }
.slots.many { grid-template-columns: 1fr 1fr; }

/* typing race */
#typeHud { position: fixed; inset: 0; pointer-events: none; z-index: 4; text-shadow: 2px 2px 0 #000, 0 0 6px #000; }
#typeHud b { font-weight: normal; color: #fff; }
.tyl { position: absolute; left: 16px; top: 10px; }
.typos { font-family: 'Press Start 2P', monospace; font-style: italic; } .typos b { font-size: 40px; color: var(--hot) !important; }
.tyw { font-size: 30px; } .tyw b { font-family: 'Press Start 2P', monospace; font-size: 34px; color: var(--gold) !important; }
.tyr { position: absolute; right: 16px; top: 10px; text-align: right; font-size: 34px; }
#tyRivals { font-size: 20px; line-height: 1.15; margin-top: 4px; }
#tyRivals .me { color: var(--hot); }
#tyBanner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-family: 'Press Start 2P', monospace; font-style: italic; font-size: min(9vw, 60px); color: #fff; text-shadow: 4px 4px 0 #a0185c, 0 0 20px var(--hot); }
#tyBanner small { display: block; font-size: .36em; margin-top: 12px; color: var(--cool); text-shadow: 2px 2px 0 #000; }
#tyBox { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(820px, 94vw); max-height: 34vh; overflow: hidden; pointer-events: auto; cursor: text;
  background: rgba(6, 8, 28, .9); border: 2px solid var(--edge); box-shadow: 0 0 0 2px #000, 0 0 24px #2a3cff66; padding: 10px 14px; text-shadow: none; }
#tyText { font-size: 27px; line-height: 1.3; color: #8a93c8; white-space: pre-wrap; word-break: break-word; }
#tyText .ok { color: #6fe3ff; }
#tyText .bad { background: #ff2a4a; color: #fff; }
#tyText .cur { border-bottom: 3px solid var(--gold); color: #fff; animation: blink 1s steps(2) infinite; }
.tyhint { text-align: center; color: var(--gold); font-size: 18px; margin-top: 4px; }
#tyBox.focused .tyhint { display: none; }
#tyInput { position: absolute; left: -9999px; top: 0; opacity: 0; }
@media (max-width: 640px) { #tyText { font-size: 21px; } .tyr { font-size: 24px; } .tyw { font-size: 22px; } .tyw b { font-size: 24px; } }
