:root {
  --bg: #0b0d12; --panel: #12151d; --panel2: #191d28; --line: #2b3142; --text: #d6dbe6; --dim: #7c8499;
  --accent: #2bf3ff; --pink: #ff2bd6; --gold: #ffd700; --red: #ff4b4b; --green: #5dff8a; --yellow: #ffe02b;
  --mono: "Cascadia Mono", "Consolas", "DejaVu Sans Mono", "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--mono); overflow: hidden; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
#game canvas { display: block; position: fixed; inset: 0; }
.hidden { display: none !important; }
button { font-family: var(--mono); cursor: pointer; }
.dim { color: var(--dim); }
.warn { color: var(--yellow); }
.ok { color: var(--green); }
.c-red { color: var(--red); } .c-gold { color: var(--gold); } .c-pink { color: var(--pink); } .c-cyan { color: var(--accent); } .c-yellow { color: var(--yellow); }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- windows ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(20,10,40,0.55), rgba(0,0,0,0.85)); z-index: 20; }
.win { background: var(--panel); border: 1px solid var(--line); box-shadow: 0 0 0 1px #000, 0 20px 60px rgba(0,0,0,0.7), 0 0 40px rgba(43,243,255,0.08);
  max-width: 100%; max-height: 100%; overflow: auto; }
.titlebar { display: flex; justify-content: space-between; gap: 12px; background: linear-gradient(90deg, #0a2a6a, #1060c0); color: #fff; padding: 5px 10px; font-size: 13px; position: sticky; top: 0; z-index: 2; }
.titlebar .tb-btns { letter-spacing: 6px; opacity: 0.8; }
#netState { font-weight: normal; }
#netState.ok { color: #9dffb8; } #netState.warn { color: #ffe9a0; }
button.big { display: block; width: 100%; padding: 12px 16px; margin: 8px 0 0; background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-size: 15px; }
button.big:hover { border-color: var(--accent); color: #fff; }
button.big.go { background: linear-gradient(180deg, #0f6a3a, #0a4a28); border-color: #1fb060; color: #eaffef; font-weight: bold; }
button.big.go:hover { background: linear-gradient(180deg, #13854a, #0c5a30); }

/* connect */
.connectwin { width: 520px; }
.logo { text-align: center; margin: 22px 0 6px; }
.logo .l1 { display: inline-block; margin: 0; text-align: left; white-space: pre; letter-spacing: 0; font-weight: bold;
  font-family: "Cascadia Mono", Consolas, "DejaVu Sans Mono", "Liberation Mono", Menlo, "Courier New", monospace;
  font-size: 17px; line-height: 1.15; color: #bff9ff; text-shadow: 0 0 6px var(--accent), 0 0 14px var(--accent); }
.logo .l1 .rc { color: var(--pink); text-shadow: 0 0 8px rgba(255,43,214,0.8); }
.logo .l1 .vr { color: var(--dim); font-weight: normal; text-shadow: none; }
.logo .l2 { font-size: 20px; font-weight: bold; color: var(--pink); letter-spacing: 6px; margin-top: 6px; text-shadow: 0 0 10px rgba(255,43,214,0.7); }
.logo .l2 span { font-size: 11px; letter-spacing: 0; color: var(--dim); text-shadow: none; }
.logo .l3 { font-size: 11px; color: var(--yellow); margin-top: 6px; }
.tag { text-align: center; color: var(--pink); margin: 4px 16px 12px; font-size: 13px; }
#connectForm { padding: 0 24px; }
#connectForm label { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; }
#connectForm input { flex: 1; background: #05070b; color: var(--green); border: 1px solid var(--line); padding: 9px 10px; font-family: var(--mono); font-size: 16px; outline: none; }
#connectForm input:focus { border-color: var(--accent); }
#connectForm input:disabled { color: var(--dim); }
.err { color: var(--red); min-height: 18px; font-size: 13px; }
.fine { color: var(--dim); font-size: 12px; text-align: center; padding: 0 20px 16px; }

/* lobby */
.lobbywin { width: min(1180px, 100%); height: min(760px, 100%); display: flex; flex-direction: column; }
.lobbygrid { flex: 1; display: grid; grid-template-columns: 290px 1fr 300px; min-height: 0; }
.col { border-right: 1px solid var(--line); padding: 10px; overflow: auto; min-height: 0; }
.col:last-child { border-right: 0; }
h3 { margin: 0 0 8px; font-size: 13px; color: var(--accent); font-weight: normal; }
h4 { color: var(--yellow); margin: 16px 0 6px; font-size: 13px; }
.chan, .car { display: block; width: 100%; text-align: left; background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 10px; margin-bottom: 8px; font-size: 12px; }
.chan:hover, .car:hover { border-color: #4a5370; }
.chan.sel, .car.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 0 16px rgba(43,243,255,0.15); }
.cn { font-size: 16px; font-weight: bold; color: #fff; display: flex; justify-content: space-between; align-items: center; }
.cd { color: var(--dim); margin: 4px 0; }
.cb { color: var(--yellow); }
.theme { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: normal; text-transform: uppercase; }
.t-day { background: #3a7bd5; } .t-sunset { background: #d56a3a; } .t-night { background: #2a2a6a; } .t-toxic { background: #3a7a1a; }
.carname { font-size: 15px; font-weight: bold; }
.carblurb { color: var(--dim); margin: 4px 0 8px; }
.stats { display: grid; grid-template-columns: 50px 1fr; gap: 3px 8px; align-items: center; }
.stats label { color: var(--dim); font-size: 11px; }
.sb { display: block; height: 7px; background: #05070b; border: 1px solid var(--line); }
.sb span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--pink)); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -10px -10px 10px; padding: 6px 10px 0; background: var(--panel2); }
.tabs button { background: transparent; border: 1px solid transparent; border-bottom: 0; color: var(--dim); padding: 6px 12px; font-size: 12px; }
.tabs button.sel { background: var(--panel); border-color: var(--line); color: #fff; margin-bottom: -1px; }
.tabpane { font-size: 13px; line-height: 1.5; }
#motd div { color: #c9d0e0; }
.rules { padding-left: 18px; margin: 0; }
.rules li { margin-bottom: 5px; }
.helplist div { display: flex; gap: 12px; margin: 4px 0; }
kbd { display: inline-block; min-width: 110px; background: #05070b; border: 1px solid var(--line); padding: 2px 8px; color: var(--yellow); font-family: var(--mono); font-size: 12px; }
#scoreList table { width: 100%; border-collapse: collapse; margin-top: 6px; }
#scoreList th { text-align: left; color: var(--dim); font-weight: normal; border-bottom: 1px solid var(--line); padding: 3px 6px; }
#scoreList td { padding: 3px 6px; border-bottom: 1px solid #1a1e2a; }
#scoreList tr.me td { color: var(--green); }
#scoreList td:nth-child(3) { color: var(--yellow); }
#feed .ts, #log .ts { color: var(--dim); }
#feed .sys { color: var(--accent); margin-bottom: 6px; }
.lobbybar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel2); }
.lobbybar button { background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 8px 12px; font-size: 13px; }
.lobbybar button.big { width: auto; margin: 0; padding: 12px 34px; font-size: 17px; }
.lobbybar .spacer { flex: 1; }

/* pause/results */
.win.small { width: 440px; padding: 0 0 16px; }
.win.small > *:not(.titlebar) { margin-left: 20px; margin-right: 20px; }
.win.small button.big { width: calc(100% - 40px); }
.results h2 { font-size: 28px; margin-top: 16px; margin-bottom: 4px; text-align: center; letter-spacing: 2px; }
.results h2.win { color: var(--gold); text-shadow: 0 0 20px rgba(255,215,0,0.6); }
.results h2.lose { color: var(--red); text-shadow: 0 0 20px rgba(255,60,60,0.5); }
#resSub { text-align: center; }
#resStats div { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #232838; font-size: 13px; }
#resStats b { color: var(--yellow); }
.final { text-align: center; font-size: 18px; margin-top: 14px; }
.final b { display: block; font-size: 36px; color: var(--green); text-shadow: 0 0 18px rgba(93,255,138,0.5); }
#resRank { text-align: center; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-size: 13px; }
#topic { position: absolute; top: 0; left: 0; right: 0; background: rgba(10,12,18,0.82); border-bottom: 1px solid var(--line); padding: 5px 220px 5px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #c0c8d8; }
#topicChan { color: var(--accent); }
#timer { position: absolute; top: 0; right: 0; width: 200px; background: rgba(10,12,18,0.9); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; padding: 3px 0 6px; }
#timer .lbl { font-size: 10px; color: var(--dim); letter-spacing: 2px; }
#timeVal { font-size: 34px; font-weight: bold; color: #fff; line-height: 1; text-shadow: 0 0 10px rgba(43,243,255,0.5); }
#timeVal.low { color: var(--red); animation: blink 0.6s steps(2) infinite; text-shadow: 0 0 12px rgba(255,60,60,0.8); }
#arrow { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); text-align: center; }
#arrowIcon { font-size: 30px; color: var(--accent); text-shadow: 0 0 10px var(--accent), 0 0 2px #000; transition: transform 0.08s linear; }
#arrowLbl { font-size: 11px; color: var(--accent); text-shadow: 0 1px 2px #000; }
#nicklist { position: absolute; top: 76px; right: 0; width: 200px; background: rgba(10,12,18,0.72); border: 1px solid var(--line); border-right: 0; }
#nicklist .hdr { background: rgba(16,96,192,0.5); padding: 3px 8px; font-size: 11px; color: #fff; }
#nlBody { padding: 4px 8px; }
#nlBody .n { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 1px 0; }
#nlBody .n.split span:first-child { text-decoration: line-through; opacity: 0.5; }
#nlBody .n i { color: var(--dim); font-size: 10px; }
#nlBody .n.me { color: var(--green); }
#nlBody .n.dim { color: var(--dim); }
.hb { width: 60px; height: 6px; background: #000; border: 1px solid #333; display: inline-block; }
.hb span { display: block; height: 100%; }
#effects { position: absolute; top: 76px; left: 10px; width: 220px; }
#effects .fx { background: rgba(10,12,18,0.8); border: 1px solid var(--yellow); color: var(--yellow); padding: 3px 8px; margin-bottom: 4px; font-size: 12px; }
#effects .fx.bad { border-color: var(--red); color: var(--red); }
#effects .bar { display: block; height: 3px; background: #222; margin-top: 2px; }
#effects .bar span { display: block; height: 100%; background: currentColor; }
#log { position: absolute; left: 0; bottom: 26px; width: min(640px, 60vw); background: rgba(10,12,18,0.68); border: 1px solid var(--line); border-left: 0; padding: 4px 8px; font-size: 12.5px; line-height: 1.4; }
#log .l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: fadein 0.25s; }
@keyframes fadein { from { opacity: 0; transform: translateX(-8px); } }
#log .join { color: var(--green); } #log .sys { color: #8a96b0; } #log .quit { color: #6ab0ff; } #log .quit.gold { color: var(--gold); }
#log .quit.pink { color: var(--pink); } #log .quit.dim { color: #4a6080; } #log .kick { color: var(--red); } #log .notice { color: #ff9a40; }
#log .bad { color: var(--red); } #log .spam { color: #ff70e0; } #log .chat { color: #e8e8e8; } #log .taunt { color: #fff; } #log .action { color: #d070ff; }
#log .netsplit { color: var(--yellow); font-weight: bold; }
#status { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(16,32,80,0.92); border-top: 1px solid #2a4a9a; padding: 4px 8px; white-space: nowrap; overflow: hidden; font-size: 12.5px; color: #c8d4f0; }
#status span { margin-right: 8px; }
#status .me { color: var(--green); } #status .cr { color: var(--yellow); }
#status .ok { color: var(--green); } #status .warn { color: var(--yellow); } #status .crit { color: var(--red); animation: blink 0.5s steps(2) infinite; }
#status i { color: #304060; font-style: normal; }
#speedo { position: absolute; right: 204px; bottom: 34px; text-align: right; font-weight: bold; text-shadow: 0 2px 6px #000; }
#spd { font-size: 46px; color: #fff; font-style: italic; }
#speedo small { font-size: 12px; color: var(--dim); margin-left: 4px; }
#minimap { position: absolute; right: 6px; bottom: 32px; width: 190px; height: 190px; opacity: 0.92; border: 1px solid var(--line); background: #000; }
#center { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font-family: Impact, "Arial Black", sans-serif; font-size: 58px; letter-spacing: 2px; color: #fff; text-shadow: 0 0 20px rgba(0,0,0,0.9), 0 4px 0 #000; }
#center small { display: block; font-family: var(--mono); font-size: 16px; letter-spacing: 0; margin-top: 6px; color: #eee; }
#center.pop > div { animation: pop 0.35s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }
#center .count { font-size: 120px; color: var(--accent); }
#center .go { color: var(--green); }
#center .nsplit { color: var(--yellow); text-shadow: 0 0 30px rgba(255,224,43,0.8), 0 4px 0 #000; }
#center .kickc { color: var(--red); } #center .gold { color: var(--gold); } #center .spamc { color: var(--pink); text-shadow: 0 0 30px rgba(255,43,214,0.8), 0 4px 0 #000; }
#center .pickc { color: var(--yellow); font-size: 42px; } #center .badc { color: var(--red); font-size: 42px; } #center .cpc { color: var(--accent); font-size: 40px; }
#center .winc { color: var(--gold); } #center .losec { color: var(--red); }
#combo { position: absolute; top: calc(28% + 110px); left: 0; right: 0; text-align: center; font-size: 22px; font-weight: bold; color: var(--yellow); text-shadow: 0 2px 4px #000; }
#combo.bump { animation: pop 0.2s; }
#dmg { position: absolute; inset: 0; box-shadow: inset 0 0 160px 40px rgba(255,0,0,0.9); opacity: 0; transition: opacity 0.25s; }
#ftexts { position: absolute; inset: 0; overflow: hidden; }
.ftext { position: absolute; left: 0; top: 0; font-weight: bold; font-size: 18px; color: var(--green); text-shadow: 0 2px 3px #000, 0 0 2px #000; white-space: nowrap; }
.ftext.gold { color: var(--gold); font-size: 24px; } .ftext.pink { color: var(--pink); } .ftext.cyan { color: var(--accent); }

#loading { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; align-items: center; justify-content: center; color: var(--green); font-size: 18px; }
#fatal { position: fixed; inset: 0; z-index: 40; background: #000; color: var(--red); padding: 40px; font-size: 16px; }

/* touch */
#touch { position: fixed; inset: auto 0 34px 0; z-index: 15; display: flex; justify-content: space-between; padding: 0 12px; pointer-events: none; }
#touch .tl, #touch .tr { display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
#touch button { width: 74px; height: 74px; border-radius: 50%; background: rgba(20,30,50,0.55); border: 2px solid rgba(43,243,255,0.5); color: #fff; font-size: 26px; }
#touch button.sm { width: 56px; height: 56px; font-size: 11px; }
#touch button.on { background: rgba(43,243,255,0.4); }

@media (max-width: 900px) {
  .lobbygrid { grid-template-columns: 1fr; grid-auto-rows: max-content; overflow: auto; }
  .lobbywin { height: 100%; }
  .col { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  #log { width: 100vw; font-size: 11px; bottom: 140px; }
  #log .l:nth-child(-n+6) { display: none; }
  #nicklist, #effects { display: none; }
  #minimap { width: 120px; height: 120px; top: 76px; bottom: auto; }
  #speedo { right: auto; left: 10px; top: 70px; bottom: auto; }
  #spd { font-size: 30px; }
  #center { font-size: 34px; }
  #center .count { font-size: 80px; }
  #topic { padding-right: 130px; font-size: 11px; }
  #timer { width: 120px; } #timeVal { font-size: 24px; }
  .logo .l1 { font-size: 13px; }
}
