/* ==========================================================================
   Futbol Arena — UI
   ========================================================================== */

:root {
  --bg: #060912;
  --panel: rgba(11, 17, 31, 0.76);
  --panel-solid: #0d1424;
  --panel-2: rgba(22, 31, 52, 0.78);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.15);
  --text: #eef2f8;
  --muted: #8e9ab4;
  --dim: #5f6b85;
  --lime: #b6ff3b;
  --lime-2: #6dff8a;
  --cyan: #3ee6ff;
  --red: #ff4757;
  --blue: #3d8bff;
  --gold: #ffcc33;
  --team0: #e8303f;
  --team1: #2f7bff;
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
  --display: 'Russo One', 'Arial Black', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
input, button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 1em; height: 1em; flex: none; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.9em; height: 1.75em; padding: 0 .45em; margin: 0 .12em;
  font: 600 11px/1 var(--body); color: var(--text);
  background: linear-gradient(#232d45, #182033);
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

#game { position: fixed; inset: 0; display: block; z-index: 0; touch-action: none; }

.menu-shade {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(182, 255, 59, 0.08), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, rgba(62, 230, 255, 0.07), transparent 60%),
    linear-gradient(180deg, rgba(6, 9, 18, 0.55), rgba(6, 9, 18, 0.82));
  backdrop-filter: blur(2.5px) saturate(1.1);
  -webkit-backdrop-filter: blur(2.5px) saturate(1.1);
  transition: opacity .5s ease;
}
body.in-game .menu-shade { opacity: 0; }

/* ---------- Buttons & fields ---------- */
.btn {
  --b: var(--panel-2);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  height: 46px; padding: 0 20px;
  border: 1px solid var(--line-2); border-radius: 14px;
  background: var(--b);
  font-weight: 700; letter-spacing: .01em;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease, opacity .2s;
  white-space: nowrap;
}
.btn svg { font-size: 18px; }
.btn:hover { background: rgba(36, 48, 78, 0.92); border-color: rgba(255, 255, 255, 0.26); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.btn.primary {
  color: #0b1404; border-color: transparent;
  background: linear-gradient(135deg, #d7ff5a, #8dff4d 55%, #43f0a2);
  box-shadow: 0 10px 30px -10px rgba(160, 255, 80, 0.65), 0 1px 0 rgba(255, 255, 255, 0.55) inset;
}
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 14px 36px -10px rgba(160, 255, 80, 0.8), 0 1px 0 rgba(255, 255, 255, 0.55) inset; }
.btn.accent { background: linear-gradient(135deg, #3ee6ff, #3d8bff); color: #031322; border-color: transparent; }
.btn.danger { background: rgba(255, 71, 87, 0.16); border-color: rgba(255, 71, 87, 0.45); color: #ffb3ba; }
.btn.ghost { background: transparent; }
.btn.xl { height: 58px; font-size: 18px; font-family: var(--display); font-weight: 400; letter-spacing: .04em; border-radius: 16px; text-transform: uppercase; }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.small svg { font-size: 15px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--panel);
  color: var(--text); font-size: 19px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background .2s, transform .12s, border-color .2s;
}
.icon-btn:hover { background: rgba(36, 48, 78, 0.92); border-color: rgba(255, 255, 255, 0.26); }
.icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 20px; height: 20px; }
body.muted [data-toggle="mute"] .wave, body:not(.muted) [data-toggle="mute"] .mute-x { display: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field input, .input {
  height: 46px; padding: 0 14px; width: 100%;
  border-radius: 12px; border: 1px solid var(--line-2);
  background: rgba(5, 9, 18, 0.65);
  outline: none; transition: border-color .2s, box-shadow .2s;
  user-select: text;
}
.field input:focus, .input:focus { border-color: rgba(182, 255, 59, 0.7); box-shadow: 0 0 0 4px rgba(182, 255, 59, 0.12); }
.field.grow { flex: 1; }
.field.num { width: 76px; }
.field.num input { text-align: center; font-family: var(--display); font-size: 18px; }
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 99px;
  background: var(--panel); border: 1px solid var(--line-2);
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.badge {
  display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px;
  border-radius: 99px; background: rgba(182, 255, 59, 0.14); color: var(--lime);
  font-size: 12px; font-weight: 800; vertical-align: middle;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.card-head h2, .card-head h3 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: .04em; text-transform: uppercase; }
.card-head h2 { font-size: 18px; }
.card-head h3 { font-size: 13px; color: var(--muted); }
.card-head.slim { padding: 14px 16px 8px; }

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  padding: calc(18px + var(--safe-t)) 24px calc(18px + var(--safe-b));
  overflow-y: auto; overflow-x: hidden;
  animation: screen-in .45s cubic-bezier(.2, .8, .2, 1);
}
@keyframes screen-in { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1180px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 18px; letter-spacing: .06em; }
.brand b { color: var(--lime); font-weight: 400; }
.brand-ball { width: 30px; height: 30px; animation: spin 8s linear infinite; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5)); }
@keyframes spin { to { transform: rotate(360deg); } }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.conn { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line-2); font-size: 12px; font-weight: 600; color: var(--muted); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.conn[data-s="open"] i { background: var(--lime); box-shadow: 0 0 10px var(--lime); }
.conn[data-s="closed"] i, .conn[data-s="offline"] i { background: var(--red); box-shadow: 0 0 10px var(--red); }
.conn[data-s="connecting"] i { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* Home */
.home-grid {
  flex: 1 0 auto; display: grid; grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: 22px;
  max-width: 1180px; width: 100%; margin: 22px auto; align-items: stretch; min-height: 0;
}
.hero { padding: 30px 30px 26px; display: flex; flex-direction: column; gap: 22px; position: relative; overflow: hidden; }
.hero::before {
  content: ''; position: absolute; inset: -40% -30% auto auto; width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, rgba(182, 255, 59, 0.22), transparent 65%);
  pointer-events: none;
}
.kicker { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--lime); }
.hero h1 {
  margin: 8px 0 10px; font-family: var(--display); font-weight: 400;
  font-size: clamp(44px, 6vw, 64px); line-height: .92; letter-spacing: .02em;
  text-shadow: 0 10px 40px rgba(0, 0, 0, .6);
}
.hero h1 span {
  background: linear-gradient(100deg, var(--lime), #5dffb0 50%, var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 0; color: var(--muted); max-width: 40ch; }
.profile { display: flex; align-items: flex-end; gap: 12px; }
.jersey { position: relative; width: 64px; height: 64px; flex: none; display: grid; place-items: center; }
.jersey svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: url(#none); }
.jersey svg { color: var(--team0); filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .5)); }
.jersey svg use { fill: currentColor; }
.jersey span { position: relative; top: 7px; font-family: var(--display); font-size: 20px; color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, .4); }
.cta { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: flex; gap: 12px; }
.row2 > .btn { flex: 1; }
.join { display: flex; gap: 10px; }
.join input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.25); background: rgba(5, 9, 18, 0.55);
  font-family: var(--display); letter-spacing: .3em; text-transform: uppercase; text-align: center; font-size: 17px;
  outline: none; user-select: text;
}
.join input:focus { border-style: solid; border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(62, 230, 255, 0.12); }

.rooms { display: flex; flex-direction: column; min-height: 340px; overflow: hidden; }
.rooms-list { flex: 1; overflow-y: auto; padding: 4px 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.room-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line); transition: background .2s, border-color .2s, transform .15s;
  animation: row-in .35s ease both;
}
.room-row:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--line-2); transform: translateX(2px); }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } }
.room-row .rr-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-family: var(--display); font-size: 13px; background: linear-gradient(135deg, rgba(232, 48, 63, .35), rgba(47, 123, 255, .35)); }
.room-row .rr-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-row .rr-sub { font-size: 12px; color: var(--muted); }
.room-row .rr-count { font-variant-numeric: tabular-nums; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .06em; }
.status-dot.lobby { background: rgba(182, 255, 59, 0.12); color: var(--lime); }
.status-dot.playing { background: rgba(255, 204, 51, 0.12); color: var(--gold); }
.slots { display: flex; gap: 3px; }
.slots i { width: 6px; height: 14px; border-radius: 2px; background: rgba(255, 255, 255, .12); }
.slots i.on { background: var(--lime); }
.empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 30px; color: var(--muted); }
.empty .ball-anim { width: 64px; height: 64px; margin: 0 auto 14px; animation: bounce 1.4s cubic-bezier(.3, 0, .7, 1) infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-16px); } }
.empty b { color: var(--text); display: block; font-size: 16px; margin-bottom: 4px; }

.keys-strip {
  max-width: 1180px; width: 100%; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 10px 22px; justify-content: center;
  font-size: 12px; color: var(--muted);
}
.keys-strip span { display: inline-flex; align-items: center; gap: 2px; }

/* Room */
.room-head { display: flex; align-items: center; gap: 16px; max-width: 1240px; width: 100%; margin: 0 auto; }
.room-title { flex: 1; min-width: 0; }
.room-title h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 24px; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-meta { display: flex; gap: 10px; align-items: center; margin-top: 2px; font-size: 13px; }
.room-code { display: flex; align-items: center; gap: 10px; }
.code-chip {
  display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px;
  border-radius: 12px; border: 1px dashed rgba(182, 255, 59, 0.5); background: rgba(182, 255, 59, 0.06); color: var(--lime);
}
.code-chip span { font-size: 10px; font-weight: 800; letter-spacing: .12em; color: var(--muted); }
.code-chip b { font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: .22em; }
.code-chip svg { font-size: 16px; }
#screen-room { overflow: hidden; }
.room-grid {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: minmax(0, 1fr); gap: 20px;
  max-width: 1240px; width: 100%; margin: 16px auto; min-height: 0;
}
.teams-wrap { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; overflow-y: auto; padding-bottom: 4px; }
.teams { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 14px; align-items: stretch; }
.vs { display: grid; place-items: center; }
.vs span {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-size: 18px; letter-spacing: .04em;
  background: radial-gradient(circle at 30% 30%, #26324d, #0c1222); border: 1px solid var(--line-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.team-card {
  --tc: var(--team0); --tc2: #a3172a;
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 22%, transparent), rgba(11, 17, 31, 0.82) 42%);
  border: 1px solid color-mix(in srgb, var(--tc) 40%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: flex; flex-direction: column; min-height: 290px;
  transition: border-color .3s, background .3s;
}
.team-card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--tc), var(--tc2));
}
.team-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 10px; }
.team-badge {
  width: 46px; height: 46px; border-radius: 14px; flex: none; position: relative; overflow: hidden;
  background: var(--tc); box-shadow: 0 8px 20px -6px var(--tc), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.team-badge::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 7px, var(--tc2) 7px 12px); opacity: var(--stripes, 0); }
.team-name { font-family: var(--display); font-size: 20px; letter-spacing: .04em; text-transform: uppercase; }
.team-sub { font-size: 12px; color: var(--muted); }
.kit-picker { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 8px; }
.kit-swatch {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid transparent; padding: 0;
  background: var(--k); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); transition: transform .15s;
}
.kit-swatch:hover { transform: scale(1.15); }
.kit-swatch.on { border-color: #fff; }
.kit-swatch:disabled { opacity: .25; cursor: not-allowed; transform: none; }
.slots-list { display: flex; flex-direction: column; gap: 8px; padding: 6px 14px 14px; flex: 1; }
.pslot {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
  animation: row-in .3s ease both;
}
.pslot.me { border-color: rgba(182, 255, 59, 0.55); background: rgba(182, 255, 59, 0.07); }
.pslot.empty-slot { border-style: dashed; color: var(--dim); background: transparent; justify-content: center; font-size: 13px; }
.pslot .num {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--tc); color: #fff; font-family: var(--display); font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}
.pslot .pname { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pslot .ping { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pslot .host { color: var(--gold); font-size: 15px; }
.pslot .kick-btn { width: 26px; height: 26px; border-radius: 8px; border: none; background: transparent; color: var(--dim); display: grid; place-items: center; }
.pslot .kick-btn:hover { background: rgba(255, 71, 87, .18); color: var(--red); }
.pslot.bot-slot { color: var(--muted); background: rgba(255, 255, 255, 0.02); border-style: dashed; }
.pslot.bot-slot svg { font-size: 16px; }
.team-foot { padding: 0 14px 14px; }
.team-foot .btn { width: 100%; }

.spectators .chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 16px 16px; min-height: 30px; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.chip.me { border-color: rgba(182, 255, 59, .55); }

.side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.side .settings { flex: 0 1 auto; min-height: 120px; display: flex; flex-direction: column; overflow: hidden; }
.settings-body { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 11px; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.set-row { display: flex; flex-direction: column; gap: 6px; }
.set-row > label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.set-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; padding: 3px; gap: 3px; border-radius: 11px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); }
.seg button {
  flex: 1; height: 29px; border: none; border-radius: 8px; background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 700; transition: background .2s, color .2s; padding: 0 6px; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: linear-gradient(135deg, #2b3a5f, #1e2945); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 2px 8px rgba(0, 0, 0, .3); }
.seg.lime button.on { background: var(--lime); color: #0b1404; }
.seg.disabled { pointer-events: none; opacity: .75; }
.toggle { position: relative; width: 46px; height: 26px; border-radius: 99px; border: 1px solid var(--line-2); background: rgba(0, 0, 0, .35); transition: background .2s; padding: 0; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #c8d0e0; transition: transform .2s, background .2s; }
.toggle.on { background: rgba(182, 255, 59, 0.25); border-color: rgba(182, 255, 59, 0.6); }
.toggle.on::after { transform: translateX(20px); background: var(--lime); }
.toggle:disabled { opacity: .6; cursor: default; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; }

.chat { flex: 1 1 210px; display: flex; flex-direction: column; min-height: 190px; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 16px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; user-select: text; }
.chat-log .msg b { font-weight: 700; margin-right: 6px; }
.chat-log .sys { color: var(--muted); font-size: 12px; font-style: italic; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px 12px; }
.chat-form input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line-2); background: rgba(5, 9, 18, .6); outline: none; user-select: text; }
.chat-form input:focus { border-color: rgba(182, 255, 59, .6); }

.room-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1240px; width: 100%; margin: 0 auto; }
.room-hint { color: var(--muted); font-size: 14px; }
.room-hint b { color: var(--text); }
.room-foot .btn.xl { min-width: 240px; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.hud button, .hud form, .hud input, .hud .spectate-bar, .hud .emote-bar { pointer-events: auto; }

.scoreboard {
  position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, .6));
}
.sb-main {
  display: flex; align-items: stretch; height: 46px; border-radius: 14px; overflow: hidden;
  background: rgba(8, 12, 22, 0.86); border: 1px solid var(--line-2);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.sb-team { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-width: 116px; font-family: var(--display); font-size: 16px; letter-spacing: .06em; }
.sb-team.left { justify-content: flex-end; }
.sb-kit { width: 14px; height: 26px; border-radius: 5px; background: var(--k, #888); box-shadow: 0 0 14px var(--k, #888); }
.sb-score {
  display: flex; align-items: center; gap: 2px; padding: 0 14px;
  background: linear-gradient(180deg, #1d2742, #121a2e); font-family: var(--display); font-size: 26px; font-variant-numeric: tabular-nums;
}
.sb-score span { min-width: 22px; text-align: center; display: inline-block; }
.sb-score span.bump { animation: bump .7s cubic-bezier(.2, 2, .4, 1); color: var(--lime); }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.6); } 100% { transform: scale(1); } }
.sb-sep { width: 8px; height: 3px; border-radius: 2px; background: var(--dim); margin: 0 6px; }
.sb-sub { display: flex; gap: 6px; margin-top: -1px; }
.sb-clock {
  padding: 3px 14px 4px; border-radius: 0 0 10px 10px; background: rgba(8, 12, 22, 0.9); border: 1px solid var(--line-2); border-top: none;
  font-family: var(--display); font-size: 14px; letter-spacing: .08em; font-variant-numeric: tabular-nums;
}
.sb-clock.low { color: var(--red); animation: blink 1s infinite; }
.sb-tag { padding: 3px 10px 4px; border-radius: 0 0 10px 10px; background: var(--gold); color: #251a00; font-size: 11px; font-weight: 800; letter-spacing: .1em; }

.hud-tr { position: absolute; top: calc(12px + var(--safe-t)); right: 14px; display: flex; gap: 8px; align-items: center; }
.hud-tr .icon-btn { width: 38px; height: 38px; }

.feed { position: absolute; top: calc(12px + var(--safe-t)); left: 14px; display: flex; flex-direction: column; gap: 6px; width: min(320px, 36vw); }
.feed-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px;
  background: rgba(8, 12, 22, 0.8); border: 1px solid var(--line); border-left: 3px solid var(--fc, var(--lime));
  font-size: 13px; font-weight: 600; animation: feed-in .35s cubic-bezier(.2, .9, .3, 1.2) both;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.feed-item.out { animation: feed-out .4s ease forwards; }
.feed-item.foul { --fc: var(--gold); }
.feed-item.info { --fc: var(--cyan); }
@keyframes feed-in { from { opacity: 0; transform: translateX(-20px); } }
@keyframes feed-out { to { opacity: 0; transform: translateX(-20px); } }

.hud-chat { position: absolute; left: 14px; bottom: calc(14px + var(--safe-b)); width: min(380px, 60vw); display: flex; flex-direction: column; gap: 8px; }
.hud-chat-log { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.hud-chat-log .msg { align-self: flex-start; padding: 5px 10px; border-radius: 10px; background: rgba(8, 12, 22, 0.66); text-shadow: 0 1px 2px #000; transition: opacity 1s; max-width: 100%; overflow-wrap: anywhere; }
.hud-chat-log .msg.fade { opacity: 0; }
.hud-chat-log .msg b { margin-right: 6px; }
.hud-chat-log .sys { color: var(--muted); font-style: italic; }
.hud-chat-form input { width: 100%; height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid rgba(182, 255, 59, .55); background: rgba(5, 9, 18, .85); outline: none; user-select: text; }
.minimap { position: absolute; right: 14px; bottom: calc(14px + var(--safe-b)); width: 200px; height: 112px; border-radius: 12px; border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }

.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 140px; color: #fff; text-shadow: 0 10px 50px rgba(0, 0, 0, .8), 0 0 40px rgba(182, 255, 59, .5); pointer-events: none; }
.countdown span {
  display: grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 50%; line-height: 1;
  font-size: 110px; padding-top: .06em;
  background: radial-gradient(circle, rgba(6, 9, 18, .55) 55%, rgba(6, 9, 18, 0) 72%);
  box-shadow: inset 0 0 0 6px rgba(182, 255, 59, .85), 0 0 40px rgba(182, 255, 59, .35);
  animation: count .7s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes count { 0% { opacity: 0; transform: scale(1.9); } 22% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.85); } }

.banner { position: absolute; left: 0; right: 0; top: 34%; display: grid; place-items: center; pointer-events: none; }
.banner .bn {
  text-align: center; padding: 16px 60px; animation: bn 2s cubic-bezier(.2, .9, .3, 1) both;
  background: linear-gradient(90deg, transparent, rgba(8, 12, 22, .85) 20%, rgba(8, 12, 22, .85) 80%, transparent);
}
.banner .bn h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 52px; letter-spacing: .08em; color: var(--lime); text-shadow: 0 0 30px rgba(182, 255, 59, .45); }
.banner .bn p { margin: 4px 0 0; font-weight: 600; color: var(--muted); }
@keyframes bn { 0% { opacity: 0; transform: scaleX(.3); } 15% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

.goal-banner { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; overflow: hidden; }
.goal-banner .gb { position: relative; width: 100%; display: grid; place-items: center; animation: gb-wrap 1.7s ease both; }
.goal-banner .gb-stripe {
  position: absolute; left: -10%; right: -10%; height: 170px; transform: skewY(-4deg);
  background: linear-gradient(90deg, var(--gc2), var(--gc) 30%, var(--gc) 70%, var(--gc2));
  box-shadow: 0 0 80px var(--gc);
  animation: gb-stripe 1.7s cubic-bezier(.2, .9, .3, 1) both;
}
.goal-banner .gb-stripe::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255,255,255,.08) 0 30px, transparent 30px 60px); animation: slide 1s linear infinite; }
@keyframes slide { to { background-position: 60px 0; } }
.goal-banner .gb-text { position: relative; text-align: center; color: #fff; }
.goal-banner h1 {
  margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(64px, 12vw, 150px); line-height: 1; letter-spacing: .04em;
  text-shadow: 0 6px 0 rgba(0, 0, 0, .25), 0 20px 50px rgba(0, 0, 0, .5);
  animation: gb-title 1.7s cubic-bezier(.2, 1.6, .4, 1) both;
}
.goal-banner .gb-who { font-size: 20px; font-weight: 800; letter-spacing: .03em; animation: gb-sub 1.7s ease both; text-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.goal-banner .gb-who small { display: block; font-size: 14px; font-weight: 600; opacity: .85; }
.goal-banner .gb-score { font-family: var(--display); font-size: 26px; margin-top: 4px; animation: gb-sub 1.7s ease both; }
@keyframes gb-stripe { 0% { transform: skewY(-4deg) scaleX(0); } 12% { transform: skewY(-4deg) scaleX(1); } 85% { opacity: 1; transform: skewY(-4deg) scaleX(1); } 100% { opacity: 0; transform: skewY(-4deg) scaleX(1.1); } }
@keyframes gb-title { 0% { opacity: 0; transform: scale(3); } 14% { opacity: 1; transform: scale(1); } 85% { opacity: 1; transform: scale(1.04); } 100% { opacity: 0; transform: scale(1.2); } }
@keyframes gb-sub { 0%, 15% { opacity: 0; transform: translateY(10px); } 25% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes gb-wrap { 0%, 100% { opacity: 1; } }

.pop { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); pointer-events: none; }
.pop span { display: block; font-family: var(--display); font-size: 34px; letter-spacing: .06em; color: var(--gold); text-shadow: 0 0 20px rgba(255, 204, 51, .6), 0 4px 10px #000; animation: pop 1.3s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { 0% { opacity: 0; transform: scale(.4) rotate(-6deg); } 20% { opacity: 1; transform: scale(1.1) rotate(-3deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px) rotate(-3deg); } }

.replay-badge {
  position: absolute; top: calc(10% + 6px); left: 22px; display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-size: 22px; letter-spacing: .12em; color: #fff; text-shadow: 0 2px 10px #000;
}
.replay-badge i { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red); animation: blink 1s infinite; }
.replay-badge small { font-family: var(--body); font-size: 12px; letter-spacing: 0; color: var(--muted); font-weight: 600; margin-left: 6px; }

.spectate-bar {
  position: absolute; bottom: calc(18px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-radius: 14px;
  background: rgba(8, 12, 22, .88); border: 1px solid var(--line-2); font-weight: 700; font-size: 13px;
}
.emote-bar { position: absolute; bottom: calc(16px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; opacity: .0; transition: opacity .3s; }
body.show-emotes .emote-bar, .emote-bar:hover { opacity: 1; }
.emote-bar button { height: 30px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-2); background: rgba(8, 12, 22, .8); font-size: 12px; font-weight: 700; }
.emote-bar button kbd { margin-right: 4px; height: 1.5em; min-width: 1.5em; font-size: 10px; }

.scores-overlay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(720px, 92vw);
  padding: 18px; border-radius: var(--radius); background: rgba(8, 12, 22, .92); border: 1px solid var(--line-2);
  box-shadow: var(--shadow); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.hint { position: absolute; left: 50%; bottom: calc(64px + var(--safe-b)); transform: translateX(-50%); pointer-events: none; }
.hint div { padding: 10px 16px; border-radius: 12px; background: rgba(8, 12, 22, .85); border: 1px solid var(--line-2); font-size: 13px; font-weight: 600; animation: feed-in .4s ease both; white-space: nowrap; }
.hint div.out { animation: feed-out .4s ease forwards; }

/* Stats tables (scores overlay + end screen) */
.stats-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stats-team h4 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 400; letter-spacing: .05em; font-size: 15px; text-transform: uppercase; }
.stats-team h4 i { width: 10px; height: 18px; border-radius: 4px; background: var(--k); }
table.stats { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.stats th { text-align: right; font-size: 10.5px; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 4px 6px; text-transform: uppercase; }
table.stats th:first-child, table.stats td:first-child { text-align: left; }
table.stats td { text-align: right; padding: 7px 6px; border-top: 1px solid var(--line); }
table.stats td .pn { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
table.stats td .pn em { font-style: normal; color: var(--muted); font-size: 11px; }
table.stats tr.me td { color: var(--lime); }
table.stats .rating { display: inline-block; min-width: 34px; padding: 2px 6px; border-radius: 6px; font-weight: 800; text-align: center; background: rgba(255, 255, 255, .06); }
table.stats .rating.hi { background: rgba(182, 255, 59, .18); color: var(--lime); }

/* ---------- Modals ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px;
  background: rgba(3, 5, 10, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 36px); overflow-y: auto;
  background: linear-gradient(180deg, rgba(20, 28, 48, .96), rgba(10, 15, 27, .97));
  border: 1px solid var(--line-2); border-radius: 22px; box-shadow: 0 40px 100px -20px rgba(0, 0, 0, .8);
  animation: modal-in .35s cubic-bezier(.2, .9, .3, 1.15);
}
.modal.wide { width: min(860px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 6px; }
.modal-head h2 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: .04em; font-size: 22px; text-transform: uppercase; }
.modal-body { padding: 12px 22px 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 22px 22px; }
.modal-foot .btn { min-width: 130px; }
.range { width: 100%; accent-color: var(--lime); }

.menu-list { display: flex; flex-direction: column; gap: 10px; }
.menu-list .btn { width: 100%; justify-content: flex-start; height: 50px; }
.menu-teams { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 26px; }
.help-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.help-item span:last-child { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
.help-section h3 { margin: 4px 0 6px; font-size: 12px; letter-spacing: .1em; color: var(--lime); text-transform: uppercase; }
.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.tips b { color: var(--text); }

/* End screen */
.end-hero { text-align: center; padding: 26px 22px 4px; position: relative; }
.end-hero .result { font-size: 12px; font-weight: 800; letter-spacing: .2em; color: var(--muted); text-transform: uppercase; }
.end-hero .winner { font-family: var(--display); font-size: clamp(30px, 5vw, 44px); letter-spacing: .04em; margin: 6px 0 14px; text-transform: uppercase; }
.end-score { display: flex; align-items: center; justify-content: center; gap: 22px; }
.end-team { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 140px; }
.end-team .team-badge { width: 60px; height: 60px; border-radius: 18px; }
.end-team span { font-family: var(--display); letter-spacing: .05em; text-transform: uppercase; font-size: 14px; }
.end-num { font-family: var(--display); font-size: 64px; line-height: 1; font-variant-numeric: tabular-nums; }
.end-num.dash { color: var(--dim); font-size: 40px; }
.poss { margin: 18px auto 0; max-width: 460px; }
.poss-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: #222; }
.poss-bar i { display: block; height: 100%; transition: width 1s ease; }
.poss-labels { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 6px; }
.mvp {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 204, 51, .16), rgba(255, 204, 51, .03)); border: 1px solid rgba(255, 204, 51, .4);
}
.mvp .mvp-badge { font-family: var(--display); font-size: 12px; letter-spacing: .1em; color: #251a00; background: var(--gold); padding: 6px 10px; border-radius: 9px; }
.mvp .mvp-name { font-weight: 800; font-size: 17px; }
.mvp .mvp-sub { font-size: 12px; color: var(--muted); }
.mvp .mvp-rating { margin-left: auto; font-family: var(--display); font-size: 30px; color: var(--gold); }

/* ---------- Touch ---------- */
.touch { position: fixed; inset: 0; z-index: 7; pointer-events: none; }
.touch-zone { position: absolute; left: 0; top: 60px; bottom: 0; width: 50%; pointer-events: auto; touch-action: none; }
.stick { position: absolute; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; background: rgba(255, 255, 255, .04); border: 1.5px solid rgba(255, 255, 255, .22); pointer-events: none; opacity: var(--touch-alpha, .6); }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; border-radius: 50%; transform: translate(-50%, -50%); background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.85), rgba(185,195,214,.55)); box-shadow: 0 4px 12px rgba(0, 0, 0, .35); }
.touch-buttons {
  --ts: 1;
  position: absolute; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + var(--safe-b));
  width: calc(84px * var(--ts)); height: calc(84px * var(--ts)); pointer-events: none;
  opacity: var(--touch-alpha, .6); transition: opacity .25s ease;
}
.touch.pressing .touch-buttons { opacity: min(1, calc(var(--touch-alpha, .6) + .25)); }
.tbtn {
  position: absolute; inset: 0; pointer-events: auto; padding: 0; border-radius: 50%;
  border: 2px solid rgba(182, 255, 59, .6); background: rgba(182, 255, 59, .1);
  font-family: var(--display); font-size: calc(16px * var(--ts)); letter-spacing: .04em; color: rgba(255, 255, 255, .95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8); touch-action: none;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}
.tbtn.on { background: rgba(182, 255, 59, .35); border-color: var(--lime); transform: scale(.92); }

.toasts { position: fixed; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 11px 18px; border-radius: 12px; background: rgba(16, 22, 38, .95); border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; box-shadow: var(--shadow); animation: toast 3s ease forwards; }
.toast.err { border-color: rgba(255, 71, 87, .5); color: #ffc2c8; }
.toast.ok { border-color: rgba(182, 255, 59, .5); }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px); } 10% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

.rotate-hint { display: none; }
@media (pointer: coarse) and (orientation: portrait) and (max-width: 600px) {
  body.in-game .rotate-hint {
    display: flex; position: fixed; inset: 0; z-index: 50; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: rgba(6, 9, 18, .94); text-align: center; padding: 30px; font-weight: 600;
  }
  body.in-game .rotate-hint svg { width: 64px; height: 64px; color: var(--lime); animation: rot 2s ease-in-out infinite; }
}
@keyframes rot { 50% { transform: rotate(-90deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1000px), (max-height: 640px) {
  #screen-room { overflow-y: auto; }
  .room-grid { flex: 1 0 auto; grid-template-columns: 1fr; grid-template-rows: auto; }
  .teams-wrap { overflow: visible; }
  .side { display: grid; grid-template-columns: 1fr 1fr; }
  .side .settings { overflow: visible; }
  .settings-body { overflow: visible; }
}
@media (max-width: 1100px) {
  .feed { top: calc(84px + var(--safe-t)); }
}
@media (max-width: 900px) {
  .hud-tr .pill { display: none !important; }
  .hud-tr { gap: 6px; right: 10px; }
  .hud-tr .icon-btn { width: 34px; height: 34px; }
  .hud-tr .icon-btn svg { width: 17px; height: 17px; }
}
body.touch-ui .minimap, body.touch-ui .emote-bar { display: none; }
body.touch-ui .hint { top: calc(92px + var(--safe-t)); bottom: auto; }
body.touch-ui .hud-chat { left: auto; right: 10px; bottom: auto; top: calc(56px + var(--safe-t)); width: min(280px, 36vw); align-items: flex-end; }
body.touch-ui .hud-chat-log .msg { align-self: flex-end; }
body.touch-ui .spectate-bar { bottom: auto; top: calc(92px + var(--safe-t)); }
@media (max-width: 860px) {
  .home-grid { grid-template-columns: 1fr; }
  .rooms { min-height: 260px; }
  .keys-strip { display: none; }
  .screen { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 700px) {
  .teams { grid-template-columns: 1fr; }
  .vs { display: none; }
  .team-card { min-height: 0; }
  .side { grid-template-columns: 1fr; }
  .room-head { flex-wrap: wrap; }
  .room-code { width: 100%; }
  .room-code .code-chip { flex: 1; justify-content: center; }
  .room-foot { flex-direction: column; align-items: stretch; }
  .room-foot .btn.xl { min-width: 0; }
  .hero { padding: 22px 18px; }
  .sb-team { min-width: 0; padding: 0 10px; font-size: 13px; }
  .sb-team .sb-name { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .feed { top: calc(76px + var(--safe-t)); width: 60vw; }
  .help-grid, .stats-teams { grid-template-columns: 1fr; }
  .minimap { display: none; }
}
@media (max-height: 520px) {
  .hud-chat { display: none; }
  .countdown span { font-size: 72px; }
  .goal-banner .gb-stripe { height: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
