:root {
  color-scheme: dark;
  --bg: #080913;
  --panel: rgba(20, 22, 42, .88);
  --text: #f7f8ff;
  --muted: #9da3c7;
  --red: #ff3b6a;
  --blue: #26c6ff;
  --purple: #a86cff;
  --green: #54efb1;
  --line: rgba(255,255,255,.13);
  font-family: "Arial Narrow", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; overflow-x: hidden; }
button, input, select { font: inherit; }
button, input, select, .tap-target { min-height: 44px; }
button { border: 0; cursor: pointer; }
button:active:not(:disabled) { filter: brightness(.88); }
button:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.ambient { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle at 15% 10%, rgba(255,59,106,.18), transparent 35%), radial-gradient(circle at 90% 70%, rgba(38,198,255,.16), transparent 38%); }
.app-shell { position: relative; width: min(100%, 560px); min-height: 100dvh; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.brand { margin: 8px 0 22px; text-align: center; font-size: clamp(32px, 9vw, 52px); font-stretch: condensed; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; text-shadow: 0 0 24px rgba(255,59,106,.7); }
.brand span { color: var(--blue); text-shadow: 0 0 24px rgba(38,198,255,.75); }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h2 { font-size: 25px; letter-spacing: .03em; }
.card { padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: 0 18px 60px rgba(0,0,0,.4), inset 0 1px rgba(255,255,255,.05); backdrop-filter: blur(18px); }
.card + .card { margin-top: 14px; }
.subtle { color: var(--muted); line-height: 1.65; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
label { display: grid; gap: 7px; color: #d9dcf2; font-size: 14px; font-weight: 700; }
input, select { width: 100%; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #0e1020; color: var(--text); }
.btn { min-height: 48px; padding: 0 18px; border-radius: 13px; background: linear-gradient(135deg, var(--red), #ff6946); color: #fff; font-weight: 900; letter-spacing: .04em; box-shadow: 0 8px 25px rgba(255,59,106,.25); }
.btn.blue { background: linear-gradient(135deg, #0074d9, var(--blue)); box-shadow: 0 8px 25px rgba(38,198,255,.2); }
.btn.ghost { border: 1px solid var(--line); background: rgba(255,255,255,.05); box-shadow: none; color: var(--text); }
.btn:disabled { cursor: not-allowed; opacity: .42; filter: grayscale(.3); }
.tiny { min-height: 44px; padding: 0 12px; font-size: 13px; }
.divider { height: 1px; margin: 18px 0; background: var(--line); }
.room-code { display: block; margin: 8px 0; color: #fff; font: 900 42px/1 ui-monospace, monospace; letter-spacing: .16em; text-align: center; text-shadow: 0 0 18px var(--blue); }
.qr-wrap { display: grid; justify-items: center; gap: 8px; }
#room-qr, #invite-qr { width: 205px; height: 205px; padding: 0; border: 8px solid #fff; border-radius: 12px; background: #fff; image-rendering: pixelated; }
.player-list { display: grid; gap: 8px; padding: 0; list-style: none; }
.player { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.035); }
.dot { width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%; background: #555; }
.dot.online { background: var(--green); box-shadow: 0 0 12px var(--green); }
.team0 { color: #ff7796; } .team1 { color: #6ddaff; } .team2 { color: #c59bff; }
.game { display: grid; gap: 12px; }
.scorebar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.ffa-score { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.score { padding: 10px; border-radius: 13px; background: rgba(255,255,255,.05); text-align: center; }
.score.red { border-bottom: 3px solid var(--red); } .score.blue { border-bottom: 3px solid var(--blue); }
.turn { padding: 8px 10px; border-radius: 999px; color: #080913; background: #fff; font-weight: 900; font-size: 12px; text-align: center; }
.table-wrap { position: relative; isolation: isolate; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: #080a18; box-shadow: 0 22px 60px #000; }
.table-wrap.red-side { box-shadow: 0 18px 60px rgba(255,59,106,.18); }
.table-wrap.blue-side { box-shadow: 0 18px 60px rgba(38,198,255,.16); }
#game-canvas { position: relative; z-index: 0; display: block; width: 100%; height: min(59dvh, 560px); touch-action: none; }
.game-canvas-3d { position: absolute; z-index: 1; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.render-mode { position: absolute; z-index: 3; top: 12px; left: 12px; min-height: 24px; padding: 5px 8px; border: 1px solid rgba(255,255,255,.24); border-radius: 999px; background: rgba(4,6,14,.76); color: #d9dcf2; font: 800 10px/1.2 ui-monospace, monospace; letter-spacing: .08em; pointer-events: none; }
.render-mode.three-ready { border-color: rgba(84,239,177,.58); color: var(--green); }
.gesture-hint { position: absolute; z-index: 3; left: 50%; bottom: 14px; transform: translateX(-50%); width: max-content; max-width: 90%; padding: 8px 12px; border-radius: 999px; background: rgba(5,6,14,.82); color: #f0f2ff; font-size: 12px; text-align: center; pointer-events: none; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.controls .wide { grid-column: 1 / -1; }
.sound-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.sound-icon { display: inline-flex; width: 22px; height: 22px; }
.sound-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.status { min-height: 24px; margin: 0; color: var(--muted); text-align: center; }
.invite-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.invite-item:last-child { border-bottom: 0; }
.toast { position: fixed; z-index: 9; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 140%); width: min(calc(100% - 32px), 520px); padding: 13px 16px; border-radius: 13px; background: #fff; color: #111; font-weight: 800; text-align: center; transition: transform .22s ease; }
.toast:empty { display: none; }
.toast.show { transform: translate(-50%, 0); }
.loading { margin-top: 24dvh; text-align: center; }
.spinner { display: inline-block; width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 390px) { .app-shell { padding-inline: 12px; } .card { padding: 18px; } .room-code { font-size: 36px; } }
@media (orientation: landscape) and (max-height: 620px) {
  .app-shell { width: min(100%, 820px); padding-top: max(8px, env(safe-area-inset-top)); }
  .brand { margin: 0 0 8px; font-size: 28px; }
  .game { grid-template-columns: minmax(0, 1fr) minmax(190px, .42fr); align-items: start; }
  .scorebar, .ffa-score { grid-column: 1 / -1; }
  .table-wrap { grid-row: 2 / span 3; }
  #game-canvas { height: min(68dvh, 420px); }
  .controls { grid-column: 2; }
  .game > .status { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
