:root {
  color-scheme: dark;
  --bg: #050608;
  --panel: #0d1015;
  --panel-2: #12161d;
  --text: #f6f7f9;
  --muted: #89909c;
  --blue: #2878e8;
  --green: #39d353;
  --red: #f12b2b;
  --yellow: #e5ce27;
  --line: rgba(255,255,255,.09);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overscroll-behavior: none; }
body { min-height: 100dvh; background: radial-gradient(circle at 50% 15%, rgba(40,120,232,.12), transparent 34%), #050608; }
button, input { font: inherit; }
button { color: inherit; }

.shell { width: min(100%, 620px); min-height: 100dvh; margin: 0 auto; position: relative; padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); }
.topbar { height: 46px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 9px; align-items: center; font-weight: 900; font-size: 13px; letter-spacing: .14em; }
.brand-dot { width: 11px; height: 11px; border: 2px solid var(--blue); border-radius: 50%; box-shadow: 0 0 10px var(--blue); }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; font-weight: 900; }

.screen { display: none; animation: enter .2s ease both; }
.screen.active { display: flex; }
.center-screen { min-height: calc(100dvh - 80px); flex-direction: column; justify-content: center; align-items: stretch; text-align: center; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.loader { width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 50%; border: 3px solid #1b2330; border-top-color: var(--blue); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.eyebrow { margin-bottom: 10px; color: var(--blue); font-size: 11px; font-weight: 900; letter-spacing: .18em; }
h1, h2 { margin: 0; line-height: 1.04; letter-spacing: -.045em; }
h1 { font-size: clamp(36px, 10vw, 58px); }
h2 { font-size: clamp(31px, 8vw, 46px); }
h1 em { color: var(--green); font-style: normal; }
.subtext { max-width: 430px; margin: 16px auto 24px; color: var(--muted); line-height: 1.5; font-size: 14px; }

.hero-puck { width: 94px; height: 94px; border-radius: 50%; margin: 0 auto 25px; padding: 11px; background: #e7e7e5; border: 5px solid #c8ae20; box-shadow: 0 0 42px rgba(229,206,39,.18); transform: rotate(-11deg); }
.hero-puck span { display: block; width: 100%; height: 100%; border-radius: inherit; border: 2px solid rgba(0,0,0,.15); }

.primary-button, .secondary-button, .small-button { width: 100%; min-height: 54px; border-radius: 15px; border: 1px solid transparent; font-weight: 900; letter-spacing: .04em; cursor: pointer; transition: transform .12s, opacity .12s, background .12s; }
.primary-button { color: #fff; background: linear-gradient(135deg, #2469d1, #3288f1); box-shadow: 0 12px 30px rgba(40,120,232,.2); }
.secondary-button { margin-top: 10px; background: var(--panel); border-color: var(--line); }
.primary-button:active, .secondary-button:active, .small-button:active { transform: scale(.98); }
button:disabled { opacity: .42; cursor: not-allowed; }
.text-button { align-self: center; margin: 17px auto 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }

.player-card { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 12px; border: 1px solid var(--line); background: rgba(13,16,21,.86); border-radius: 18px; text-align: left; }
.player-card.compact { margin: 28px 0 16px; }
.player-card > div:nth-child(2) { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.player-card strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-card small { margin-top: 3px; color: var(--muted); }
.avatar, .mini-avatar { flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: linear-gradient(145deg, #253045, #121722); color: #fff; font-weight: 900; }
.avatar { width: 49px; height: 49px; }
.avatar img, .mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mini-avatar { width: 31px; height: 31px; font-size: 11px; }
.online-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }

.join-form { margin-top: 17px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); text-align: left; }
.join-form.hidden { display: none; }
.join-form label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .15em; }
.join-row { display: grid; grid-template-columns: 1fr 102px; gap: 9px; }
.join-row input { width: 100%; min-width: 0; height: 50px; padding: 0 16px; border-radius: 12px; border: 1px solid #29303b; outline: 0; background: #080a0e; color: white; text-transform: uppercase; font-size: 20px; font-weight: 900; letter-spacing: .18em; }
.join-row input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(40,120,232,.15); }
.small-button { min-height: 50px; border-radius: 12px; background: var(--blue); }
.error-text { min-height: 20px; margin: 12px 0 0; color: #ff6868; font-size: 13px; }

.code-button { display: inline-block; padding: 3px 9px; border: 1px dashed rgba(255,255,255,.26); background: #0e1218; border-radius: 10px; color: var(--yellow); font-weight: 900; letter-spacing: .11em; vertical-align: .14em; }
.versus-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 25px 0 18px; }
.versus { margin: -3px auto; position: relative; z-index: 2; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #1b1f26; border: 3px solid var(--bg); font-size: 11px; font-weight: 1000; }
.blue-card { border-left: 3px solid var(--blue); }
.green-card { border-left: 3px solid var(--green); }
.player-card.empty { opacity: .62; }
.ready-badge { border: 1px solid #3b424d; padding: 5px 7px; border-radius: 8px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.ready-badge.yes { border-color: rgba(57,211,83,.45); color: var(--green); background: rgba(57,211,83,.08); }

.game-screen.active { flex-direction: column; min-height: calc(100dvh - 60px); }
.scoreboard { min-height: 46px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 9px; }
.score-player { min-width: 0; display: flex; align-items: center; gap: 7px; color: #b8bec8; font-size: 12px; font-weight: 800; }
.score-player.mine { justify-content: flex-end; color: white; }
.score-player span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score { display: flex; align-items: center; gap: 7px; font-size: 24px; }
.score span { color: #4f5660; }
.latency { align-self: center; margin: 1px 0 6px; color: var(--green); font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.latency.bad { color: #ff685f; }
.arena { position: relative; width: min(100%, calc((100dvh - 145px) * .5844)); max-height: calc(100dvh - 145px); margin: 0 auto; aspect-ratio: 720 / 1232; overflow: hidden; border-radius: 12px; background: #020202; box-shadow: 0 18px 50px rgba(0,0,0,.42); touch-action: none; contain: strict; }
.arena canvas { display: block; width: 100%; height: 100%; touch-action: none; transform: translateZ(0); }
.game-message { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: 180px; padding: 9px 13px; border: 1px solid rgba(255,255,255,.17); border-radius: 10px; background: rgba(0,0,0,.76); text-align: center; font-size: 11px; font-weight: 900; letter-spacing: .08em; opacity: 0; pointer-events: none; transition: opacity .15s; }
.game-message.show { opacity: 1; }
.game-note { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: 10px; }

.result-icon { width: 84px; height: 84px; display: grid; place-items: center; margin: 0 auto 23px; border-radius: 50%; background: rgba(57,211,83,.1); color: var(--green); border: 2px solid rgba(57,211,83,.45); font-size: 42px; box-shadow: 0 0 35px rgba(57,211,83,.13); }
.result-score { margin: 18px 0 30px; font-size: 42px; font-weight: 1000; letter-spacing: .12em; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 18px); max-width: calc(100% - 32px); padding: 10px 14px; border: 1px solid var(--line); border-radius: 11px; background: #171b22; box-shadow: 0 15px 35px rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: .2s; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 690px) {
  .center-screen { justify-content: flex-start; padding-top: 22px; }
  .hero-puck { width: 68px; height: 68px; margin-bottom: 15px; }
  h1 { font-size: 34px; }
  .player-card.compact { margin-top: 18px; }
}
