* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1d2e; color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none; }
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#hud { pointer-events: none; }
#gl { touch-action: none; }

#score { position: fixed; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 4px 14px; border-radius: 10px;
  background: rgba(5, 15, 25, .72); font-weight: 800; font-size: 18px; pointer-events: none; }
#score .team { font-size: 13px; padding: 2px 8px; border-radius: 6px; }
#score .t0 { background: #ffd400; color: #12306b; }
#score .t1 { background: #d62828; color: #fff; }
#score .x { opacity: .6; font-weight: 600; }
#clock { margin-left: 8px; font-variant-numeric: tabular-nums; font-size: 15px; opacity: .9; }

#msg { position: fixed; top: 28%; left: 0; right: 0; text-align: center; font-size: 54px; font-weight: 900;
  letter-spacing: 2px; text-shadow: 0 4px 0 rgba(0,0,0,.45); pointer-events: none; opacity: 0; transition: opacity .2s; }
#msg.show { opacity: 1; }

#pauseBtn { position: fixed; top: max(6px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: rgba(5,15,25,.6); color: #fff; font-weight: 900; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 12, 22, .78); z-index: 10; padding: 12px; }
.overlay.hidden { display: none; }
.card { max-width: 640px; width: 100%; max-height: 100%; overflow: auto; text-align: center;
  background: #10273d; border-radius: 16px; padding: 16px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.card h1 { margin: 0 0 4px; font-size: 28px; }
.sub { margin: 0 0 12px; opacity: .75; }
.big { display: block; width: 100%; margin: 8px 0; padding: 12px; border: 0; border-radius: 12px; font-size: 18px;
  font-weight: 800; background: #ffd400; color: #12306b; }
.big.ghost { background: #234563; color: #cfe3f5; }
.big:disabled { opacity: .5; }
.help { text-align: left; font-size: 13px; line-height: 1.4; opacity: .85; margin-top: 8px; }
.help div { margin: 6px 0; }

#rotate { display: none; z-index: 20; }
@media (orientation: portrait) { #rotate { display: flex; } }

.big.blue { background: #2f7de1; color: #fff; }
.big.hidden, .sub.hidden { display: none; }
input, select { user-select: text; -webkit-user-select: text; touch-action: manipulation; font: inherit; font-size: 16px;
  padding: 10px 12px; border-radius: 10px; border: 2px solid #2a4c6d; background: #0b1d2e; color: #fff; width: 100%; }
.field { display: block; text-align: left; margin: 8px 0; font-size: 13px; opacity: .9; }
.field input, .field select { margin-top: 4px; }
.row { display: flex; gap: 8px; margin: 8px 0; }
.row input { flex: 1; text-transform: uppercase; }
.mid { padding: 10px 14px; border: 0; border-radius: 10px; font-weight: 800; background: #ffd400; color: #12306b; white-space: nowrap; }
.err { color: #ffb4b4; min-height: 1em; margin: 4px 0; font-size: 14px; }
.lt { text-align: left; margin: 10px 0 4px; font-size: 15px; }
.rooms { list-style: none; padding: 0; margin: 0; text-align: left; max-height: 30vh; overflow: auto; }
.rooms li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; margin: 4px 0;
  background: #173450; border-radius: 10px; }
.rooms li span { display: flex; flex-direction: column; }
.rooms li small { opacity: .7; }
.rooms li.empty { opacity: .6; display: block; }
.code { font-size: 22px; letter-spacing: 3px; color: #ffd400; }
.teams { display: flex; gap: 10px; margin: 8px 0; }
.tcol { flex: 1; background: #173450; border-radius: 12px; padding: 8px; }
.tcol h3 { margin: 0 0 6px; font-size: 16px; }
.tcol.t0 h3 { color: #ffd400; } .tcol.t1 h3 { color: #ff6b6b; }
.tcol ul { list-style: none; padding: 0; margin: 0 0 8px; text-align: left; }
.tcol li { padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.06); margin: 3px 0; font-weight: 700; }
.tcol li.me { outline: 2px solid #4dff88; }
.tcol li.empty { opacity: .45; font-weight: 400; font-style: italic; }
.tcol li small { font-size: 10px; opacity: .7; margin-left: 4px; }
.tcol .mid { width: 100%; }
.hint { font-size: 12px; opacity: .7; margin: 6px 0; }

.big.green { background: #2e9d4a; color: #fff; }
#score.hidden, #trainBar.hidden { display: none; }
#trainBar { position: fixed; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 10px; border-radius: 10px; background: rgba(5,15,25,.72);
  font-weight: 700; font-size: 14px; white-space: nowrap; z-index: 5; }
#trainBar .tag { background: #2e9d4a; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 900; }
#newBallBtn { border: 0; border-radius: 8px; padding: 8px 12px; font-weight: 900; background: #ffd400; color: #12306b; }
