:root {
  --blue: #3b8cff; --blue-d: #1d4fa8;
  --red: #ff5a4a; --red-d: #a82a1d;
  --ink: #10141c; --panel: rgba(16, 20, 28, .86); --line: #000;
  --text: #f4f6fa; --muted: #a9b3c4; --gold: #ffcf3a;
  --font: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7ec0ee; color: var(--text); font-family: var(--font); font-weight: 700; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- menus ---------- */
#ui { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
#ui.ingame .screen, #ui.ingame #ad-menu { display: none !important; }
.screen { pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; max-height: 100vh; overflow-y: auto; padding: 16px; }
.logo { margin: 0; font-size: clamp(40px, 9vw, 92px); letter-spacing: 4px; line-height: 1; text-shadow: 4px 4px 0 #000, 8px 8px 0 rgba(0,0,0,.35); }
.logo span:first-child { color: var(--blue); }
.logo span:last-child { color: var(--red); }
.tag { margin: 0; font-size: 16px; text-shadow: 2px 2px 0 #000; }
.panel { background: var(--panel); border: 4px solid var(--line); box-shadow: inset 0 0 0 3px rgba(255,255,255,.08), 6px 6px 0 rgba(0,0,0,.4); padding: 18px; }
.col { display: flex; flex-direction: column; gap: 10px; width: min(92vw, 440px); }
.center { align-items: center; text-align: center; }
.row { display: flex; gap: 10px; width: 100%; }
.row > * { flex: 1; min-width: 0; }
h2 { margin: 0; font-size: 24px; letter-spacing: 2px; }
h3 { margin: 0 0 6px; font-size: 14px; }
label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
select { font: inherit; font-size: 14px; color: var(--text); background: #0a0d13; border: 3px solid #000; outline: 2px solid #3a4558; outline-offset: -5px; padding: 8px 10px; }
select:disabled { opacity: .6; }
.matchlen { justify-content: space-between; }
input { flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text); background: #0a0d13; border: 3px solid #000; outline: 2px solid #3a4558; outline-offset: -5px; padding: 10px 12px; text-transform: none; }
#joincode { text-transform: uppercase; letter-spacing: 4px; text-align: center; }
button { font: inherit; font-size: 14px; color: var(--text); background: #46546b; border: 3px solid #000; padding: 11px 10px; cursor: pointer; box-shadow: inset -3px -3px 0 rgba(0,0,0,.35), inset 3px 3px 0 rgba(255,255,255,.18); }
button:hover { filter: brightness(1.15); }
button:active { box-shadow: inset 3px 3px 0 rgba(0,0,0,.35); transform: translateY(1px); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
button:disabled { opacity: .5; cursor: default; }
button.big { font-size: 20px; padding: 16px 10px; }
button.blue { background: var(--blue-d); }
button.red { background: var(--red-d); }
button.danger { background: #6b2b2b; }
.keys { margin: 0; font-size: 11px; line-height: 1.5; color: var(--muted); font-weight: 400; }
.err { margin: 0; min-height: 16px; font-size: 13px; color: #ff9d8f; }
.conn { margin: 0; font-size: 12px; text-shadow: 1px 1px 0 #000; }
.code { font-size: 44px; letter-spacing: 10px; color: var(--gold); text-shadow: 3px 3px 0 #000; }
.teamlist { background: rgba(0,0,0,.35); border: 3px solid #000; padding: 8px; min-height: 86px; }
.teamlist.blue h3 { color: var(--blue); } .teamlist.red h3 { color: var(--red); }
.teamlist ul { list-style: none; margin: 0; padding: 0; font-size: 13px; text-align: left; }
.teamlist li { padding: 3px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.teamlist li.empty { color: #66728a; font-weight: 400; }
.spinner { display: grid; grid-template-columns: 18px 18px; gap: 4px; }
.spinner i { width: 18px; height: 18px; background: var(--blue); animation: blk 1s infinite steps(1); }
.spinner i:nth-child(2) { animation-delay: .25s; background: var(--red); }
.spinner i:nth-child(4) { animation-delay: .5s; }
.spinner i:nth-child(3) { animation-delay: .75s; background: var(--red); }
@keyframes blk { 0% { opacity: 1; } 50% { opacity: .2; } }
#resultscore { font-size: 40px; text-shadow: 3px 3px 0 #000; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 4px 6px; text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 400; }
tr.t0 td:first-child { color: var(--blue); } tr.t1 td:first-child { color: var(--red); }
tr.me td { background: rgba(255,255,255,.1); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 2px 2px 0 #000; }
#scorebar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; border: 4px solid #000; box-shadow: 4px 4px 0 rgba(0,0,0,.4); }
#scorebar .team { display: flex; align-items: center; gap: 12px; padding: 6px 14px; font-size: 30px; min-width: 120px; }
#scorebar .team.blue { background: var(--blue-d); justify-content: flex-end; }
#scorebar .team.red { background: var(--red-d); }
#scorebar .tname { font-size: 12px; opacity: .85; }
#clock { background: var(--ink); padding: 6px 16px; font-size: 30px; min-width: 110px; text-align: center; font-variant-numeric: tabular-nums; }
#clock.ot { color: var(--gold); }
#banner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); font-size: clamp(28px, 6vw, 64px); text-align: center; text-shadow: 4px 4px 0 #000; white-space: nowrap; }
#banner small { display: block; font-size: .4em; margin-top: 6px; }
#banner.t0 { color: #8fc0ff; } #banner.t1 { color: #ff9d8f; }
#countdown { position: absolute; top: 34%; left: 50%; transform: translateX(-50%); font-size: 120px; text-shadow: 6px 6px 0 #000; }
#chatfeed { position: absolute; left: 12px; top: 80px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
#chatfeed div { background: rgba(0,0,0,.45); padding: 3px 8px; width: fit-content; }
#chatfeed .t0 b { color: #8fc0ff; } #chatfeed .t1 b { color: #ff9d8f; }
#boost { position: absolute; right: 18px; bottom: 18px; width: 120px; height: 120px; border: 4px solid #000; background: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; box-shadow: 4px 4px 0 rgba(0,0,0,.4); }
#boostfill { position: absolute; left: 0; right: 0; bottom: 0; height: 34%; background: linear-gradient(#ffcf3a, #ff7a1a); }
#boostnum { position: relative; font-size: 40px; }
#boost small { position: relative; font-size: 11px; }
#hint { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 400; opacity: .8; white-space: nowrap; }
#ping { position: absolute; top: 10px; right: 12px; font-size: 11px; font-weight: 400; opacity: .8; }
#scoreboard, #pausemenu { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(92vw, 460px); pointer-events: auto; text-shadow: none; }
#pausemenu { display: flex; flex-direction: column; gap: 10px; text-align: center; }
#touch { position: absolute; inset: 0; pointer-events: none; }
#stick { position: absolute; left: 24px; bottom: 24px; width: 130px; height: 130px; border: 4px solid rgba(0,0,0,.6); background: rgba(255,255,255,.15); pointer-events: auto; touch-action: none; }
#knob { position: absolute; left: 41px; top: 41px; width: 40px; height: 40px; background: rgba(255,255,255,.7); border: 3px solid #000; }
#touch button { position: absolute; width: 84px; height: 84px; pointer-events: auto; touch-action: none; opacity: .8; font-size: 13px; }
#tjump { right: 24px; bottom: 150px; }
#tboost { right: 118px; bottom: 150px; background: #a8641d; }

/* ---------- ads ---------- */
.adslot { pointer-events: auto; background: rgba(10, 13, 19, .8); border: 3px solid #000; overflow: hidden; position: relative; }
.adslot:empty { display: none; }
.adslot::before { content: "AD"; position: absolute; top: 0; right: 0; font-size: 9px; font-weight: 400; padding: 1px 4px; background: rgba(0,0,0,.6); color: #c9d1de; z-index: 2; }
.adslot a, .adslot img { display: block; width: 100%; height: 100%; }
.adslot img { object-fit: cover; image-rendering: pixelated; }
.ad-rect { width: 300px; height: 250px; flex: none; }
#ad-menu { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); }
.ad-corner { position: fixed; z-index: 5; width: 300px; height: 100px; }
.ad-corner.bottom-left { left: 12px; bottom: 12px; }
.ad-corner.bottom-right { right: 12px; bottom: 12px; }
.ad-corner.top-left { left: 12px; top: 12px; }
.ad-corner.top-right { right: 12px; top: 12px; }
body.playing .ad-corner { opacity: .82; transform-origin: bottom left; }
body.playing .ad-corner:hover { opacity: 1; }
body.playing .ad-corner.bottom-right { bottom: 150px; }
body.playing .ad-corner.top-left { top: 80px; }
body.playing .ad-corner.top-right { top: 34px; }

@media (max-width: 1100px) { #ad-menu { display: none; } }
@media (max-width: 1250px) { #hint { display: none; } }
@media (max-width: 760px) {
  .ad-corner { width: 234px; height: 60px; }
  #hint { display: none; }
  #scorebar .team { min-width: 76px; font-size: 22px; padding: 4px 8px; }
  #clock { font-size: 22px; min-width: 80px; }
  #boost { width: 84px; height: 84px; right: 12px; bottom: 12px; }
  #boostnum { font-size: 26px; }
  body.playing .ad-corner.bottom-left { left: 50%; bottom: auto; top: 62px; transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) { .spinner i { animation: none; } }
body.playing.no-ingame-ad .ad-corner { display: none; }
#results { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; }
body.on-results .ad-corner { display: none; }
