:root {
  --bg: #070a1a;
  --bg-2: #0c1130;
  --panel: rgba(17, 24, 56, 0.62);
  --panel-solid: #111838;
  --line: rgba(140, 170, 255, 0.14);
  --line-strong: rgba(140, 170, 255, 0.28);
  --text: #eaf0ff;
  --muted: #8d97c2;
  --cyan: #22e3ff;
  --cyan-2: #0ea5c6;
  --pink: #ff3dac;
  --pink-2: #c21d7c;
  --gold: #ffd166;
  --danger: #ff6b81;
  --radius: 18px;
  --display: 'Exo 2', 'Segoe UI', system-ui, sans-serif;
  --logo: 'Orbitron', 'Exo 2', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }

/* ------------------------------------------------------------ backdrop */

.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(76, 60, 200, 0.28), transparent 60%),
    linear-gradient(180deg, #070a1a 0%, #0a0d24 55%, #120a2a 100%);
  z-index: 0;
}

.orb {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.32;
  animation: drift 22s ease-in-out infinite alternate;
}
.orb-a { background: var(--cyan-2); left: -14vmax; top: 10vh; }
.orb-b { background: var(--pink-2); right: -16vmax; bottom: -10vh; animation-delay: -11s; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(6vmax, -4vmax) scale(1.12); }
}

.grid-floor {
  position: absolute;
  left: -50%;
  right: -50%;
  bottom: -10%;
  height: 55%;
  background-image:
    linear-gradient(rgba(34, 227, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 61, 172, 0.18) 1px, transparent 1px);
  background-size: 64px 64px;
  transform: perspective(420px) rotateX(62deg);
  transform-origin: 50% 0;
  mask-image: linear-gradient(to bottom, transparent, #000 35%, #000);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 35%, #000);
  animation: floor 3.5s linear infinite;
  opacity: 0.55;
}
@keyframes floor { to { background-position: 0 64px, 0 0; } }

body.in-game .backdrop .grid-floor,
body.in-game .backdrop .orb { animation-play-state: paused; }
body.in-game .grid-floor { opacity: 0.18; }

/* ------------------------------------------------------------ screens */

.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.screen.active { display: flex; animation: screen-in 0.45s cubic-bezier(.2, .8, .2, 1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(12px) scale(0.99); } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 22px;
}

h2, h3 { margin: 0 0 14px; font-weight: 700; letter-spacing: 0.01em; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 0.95rem; color: var(--text); text-transform: uppercase; letter-spacing: 0.12em; font-family: var(--display); font-weight: 600; }

.field { display: block; }
.field-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

input[type='text'] {
  width: 100%;
  background: rgba(5, 8, 24, 0.7);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type='text']:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(34, 227, 255, 0.14), 0 0 24px rgba(34, 227, 255, 0.18);
}
.panel-join input[type='text']:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(255, 61, 172, 0.14), 0 0 24px rgba(255, 61, 172, 0.18);
}

.code-input {
  font-family: var(--display) !important;
  font-size: 1.4rem !important;
  letter-spacing: 0.4em;
  text-align: center;
  text-transform: uppercase;
  padding-left: calc(15px + 0.4em) !important;
}

/* ------------------------------------------------------------ buttons */

.btn {
  --c: rgba(140, 170, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: var(--c);
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s, opacity 0.2s, filter 0.2s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: rgba(140, 170, 255, 0.24); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .step:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #3bf0ff, #1b9cff);
  color: #031425;
  box-shadow: 0 8px 26px -8px rgba(34, 227, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #6af4ff, #3aaeff); box-shadow: 0 10px 34px -8px rgba(34, 227, 255, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.btn-pink {
  border-color: transparent;
  background: linear-gradient(135deg, #ff5ec0, #d61f8a);
  color: #fff;
  box-shadow: 0 8px 26px -8px rgba(255, 61, 172, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-pink:hover:not(:disabled) { background: linear-gradient(135deg, #ff7dcd, #e2379a); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(140, 170, 255, 0.1); }
.btn-sm { padding: 8px 13px; font-size: 0.86rem; border-radius: 10px; }
.btn-lg { padding: 15px 22px; font-size: 1.05rem; width: 100%; font-family: var(--display); letter-spacing: 0.08em; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(17, 24, 56, 0.6);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s;
  flex: none;
}
.icon-btn:hover { background: rgba(60, 80, 150, 0.5); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  flex: 1;
  min-width: 48px;
  padding: 10px 0;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(5, 8, 24, 0.55);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.18s;
}
.chip:hover { border-color: var(--cyan); }
.chip.on {
  border-color: var(--cyan);
  background: rgba(34, 227, 255, 0.14);
  color: var(--cyan);
  box-shadow: 0 0 18px rgba(34, 227, 255, 0.25), inset 0 0 12px rgba(34, 227, 255, 0.12);
}
.chips-sm .chip { padding: 7px 0; font-size: 0.85rem; }
.chips:has(.chip:disabled) .chip { cursor: default; }
.chip:disabled:not(.on) { opacity: 0.35; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-cyan { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.dot-pink { background: var(--pink); box-shadow: 0 0 12px var(--pink); }

.error { color: var(--danger); min-height: 1.3em; margin: 14px 0 0; font-size: 0.92rem; text-align: center; }
.hint { color: var(--muted); font-size: 0.86rem; margin: 10px 0 0; line-height: 1.45; }
.center { text-align: center; }

/* ------------------------------------------------------------ home */

#screen-home { align-items: center; justify-content: center; }
.home-wrap { width: min(760px, 100%); margin: auto; }

.brand { text-align: center; margin-bottom: 28px; position: relative; }
.logo {
  font-family: var(--logo);
  font-weight: 900;
  font-size: clamp(2.6rem, 9vw, 5.2rem);
  margin: 0;
  line-height: 1;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: center;
  gap: 0.25em;
  flex-wrap: wrap;
}
.logo .l1 {
  color: #d9fbff;
  text-shadow: 0 0 6px var(--cyan), 0 0 22px var(--cyan), 0 0 60px rgba(34, 227, 255, 0.6);
}
.logo .l2 {
  color: #ffe1f3;
  text-shadow: 0 0 6px var(--pink), 0 0 22px var(--pink), 0 0 60px rgba(255, 61, 172, 0.6);
  animation: flicker 6s infinite;
}
@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.55; }
  94% { opacity: 1; }
  96% { opacity: 0.7; }
}
.tagline { color: var(--muted); margin: 14px 0 0; letter-spacing: 0.04em; }

.logo-puck {
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #b5f7ff, var(--cyan) 45%, #064663 100%);
  box-shadow: 0 0 30px rgba(34, 227, 255, 0.7), 0 0 80px rgba(34, 227, 255, 0.35);
  display: grid;
  place-items: center;
  animation: bob 3.2s ease-in-out infinite;
}
.logo-puck span { width: 42%; height: 42%; border-radius: 50%; background: #0b1a33; border: 3px solid #e0fbff; }
@keyframes bob { 50% { transform: translateY(-8px); } }

.home-card { padding: 26px; }
.home-card > .field { margin-bottom: 22px; }
.split { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: stretch; }
.panel { display: flex; flex-direction: column; }
.panel .btn { margin-top: auto; }
.panel .code-input { margin-bottom: 18px; }
.divider { display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; }
.divider::before, .divider::after { content: ''; flex: 1; width: 1px; background: var(--line); }
.divider span { padding: 10px 0; }

.home-invite .panel-host { opacity: 0.55; }
.home-invite .panel-join h2::after {
  content: 'Invited!';
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--pink);
  border: 1px solid var(--pink);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: auto;
  box-shadow: 0 0 12px rgba(255, 61, 172, 0.35);
}

.footnote { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 18px; opacity: 0.8; }

@media (max-width: 640px) {
  .split { grid-template-columns: 1fr; gap: 6px; }
  .divider { flex-direction: row; }
  .divider::before, .divider::after { height: 1px; width: auto; }
  .divider span { padding: 0 12px; }
  .home-card { padding: 20px; }
}

/* ------------------------------------------------------------ lobby */

#screen-lobby { justify-content: center; }
.lobby-wrap { width: min(880px, 100%); margin: 0 auto; padding-bottom: 20px; }
.lobby-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

.code-card { text-align: center; padding: 22px 22px 18px; }
.code-display {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  line-height: 1.1;
  background: linear-gradient(90deg, #8ff6ff, #fff, #ff9ad6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(34, 227, 255, 0.35));
  user-select: all;
}
.code-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.invite-link { margin-top: 10px; color: var(--muted); font-size: 0.82rem; word-break: break-all; }

.versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin: 18px 0; }
.vs {
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.6rem;
  color: #fff;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.5);
  font-style: italic;
}
.player-card {
  --pc: var(--cyan);
  position: relative;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--pc) 45%, transparent);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--pc) 22%, transparent), transparent 60%),
    var(--panel);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 92px;
  box-shadow: 0 0 30px -10px var(--pc);
  transition: all 0.3s;
  overflow: hidden;
}
.player-card.opp { --pc: var(--pink); flex-direction: row-reverse; text-align: right; }
.player-card.empty { --pc: rgba(140, 170, 255, 0.35); border-style: dashed; box-shadow: none; }
.player-card.away { opacity: 0.55; }
.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.3rem;
  color: #061020;
  background: radial-gradient(circle at 38% 32%, #fff, var(--pc) 55%, color-mix(in srgb, var(--pc) 50%, #000) 100%);
  box-shadow: 0 0 18px var(--pc);
}
.empty .avatar { background: transparent; border: 2px dashed var(--line-strong); box-shadow: none; animation: pulse-ring 1.6s ease-in-out infinite; }
@keyframes pulse-ring { 50% { border-color: rgba(140, 170, 255, 0.6); transform: scale(1.05); } }
.pc-info { min-width: 0; }
.pc-name { font-weight: 700; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.opp .pc-tags { justify-content: flex-end; }
.tag {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}
.tag.host { color: var(--gold); border-color: rgba(255, 209, 102, 0.5); }
.tag.you { color: var(--pc); border-color: color-mix(in srgb, var(--pc) 60%, transparent); }
.tag.warn { color: var(--danger); border-color: rgba(255, 107, 129, 0.5); }

.lobby-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 16px; }
@media (max-width: 720px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .versus { grid-template-columns: 1fr; gap: 10px; }
  .vs { text-align: center; font-size: 1.2rem; }
  .player-card.opp { flex-direction: row; text-align: left; }
  .opp .pc-tags { justify-content: flex-start; }
}

.target-control { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.step {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(5, 8, 24, 0.55);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.15s;
}
.step:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.step:disabled { opacity: 0.3; cursor: default; }
.target-value { flex: 1; text-align: center; }
.target-value span {
  display: block;
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.6rem;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 18px rgba(34, 227, 255, 0.55);
}
.target-value small { color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.7rem; }
.settings-card .btn-lg { margin-top: 6px; }
.settings-card.locked .target-control .step { visibility: hidden; }

/* ------------------------------------------------------------ leaderboard */

.board { display: flex; flex-direction: column; gap: 8px; }
.board-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(5, 8, 24, 0.45);
  border: 1px solid var(--line);
  animation: row-in 0.4s both;
}
.board-row.me { border-color: rgba(34, 227, 255, 0.4); background: rgba(34, 227, 255, 0.07); }
.board-row.gone { opacity: 0.55; }
@keyframes row-in { from { opacity: 0; transform: translateX(-8px); } }
.rank {
  font-family: var(--display);
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}
.board-row:first-child .rank { color: var(--gold); text-shadow: 0 0 10px rgba(255, 209, 102, 0.6); }
.b-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-sub { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 500; margin-top: 2px; }
.b-wins { text-align: right; }
.b-wins b { font-family: var(--display); font-size: 1.35rem; font-weight: 800; }
.b-wins small { display: block; font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.board-empty { color: var(--muted); font-size: 0.9rem; padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.board-compact .board-row { padding: 8px 12px; }
.board-compact .b-wins b { font-size: 1.1rem; }

/* ------------------------------------------------------------ connection pill */

.conn { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.conn::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 10px #4ade80; }
.conn.slow::before { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.conn.bad::before { background: var(--danger); box-shadow: 0 0 10px var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

/* ------------------------------------------------------------ game */

#screen-game {
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 0 auto 8px;
  width: min(100%, 980px);
  flex: none;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hud-right { justify-content: flex-end; }
.hud-code { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.hud-code b { font-family: var(--display); color: var(--text); letter-spacing: 0.15em; }

.scorebar {
  display: flex;
  align-items: stretch;
  background: rgba(10, 14, 36, 0.8);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
}
.sb-side { display: flex; align-items: center; gap: 12px; padding: 6px 14px; }
.sb-you { background: linear-gradient(90deg, rgba(34, 227, 255, 0.16), transparent); }
.sb-opp { background: linear-gradient(270deg, rgba(255, 61, 172, 0.16), transparent); }
.sb-name { font-weight: 600; font-size: 0.9rem; max-width: 18vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-score { font-family: var(--display); font-weight: 900; font-size: 1.7rem; min-width: 1.2em; text-align: center; }
.sb-you .sb-score { color: var(--cyan); text-shadow: 0 0 14px rgba(34, 227, 255, 0.7); }
.sb-opp .sb-score { color: var(--pink); text-shadow: 0 0 14px rgba(255, 61, 172, 0.7); }
.sb-score.bump { animation: bump 0.6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { 30% { transform: scale(1.6); } }
.sb-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 12px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); font-family: var(--display); font-weight: 800; }
.sb-first { white-space: nowrap; font-family: var(--body); font-weight: 600; font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 640px) {
  .hud { grid-template-columns: auto 1fr auto; gap: 8px; }
  .hud-code { display: none; }
  .scorebar { justify-self: center; }
  .sb-side { padding: 5px 9px; gap: 7px; }
  .sb-name { font-size: 0.78rem; max-width: 20vw; }
  .sb-score { font-size: 1.35rem; }
  .hud-right .conn { display: none; }
}

.stage { position: relative; flex: 1; min-height: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
body.playing #game { cursor: none; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  z-index: 2;
}
.overlay.show { opacity: 1; visibility: visible; }
.overlay.dim { inset: 0 -10px -10px; background: rgba(7, 10, 26, 0.68); pointer-events: auto; }

.count {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(5rem, 22vmin, 11rem);
  color: #fff;
  text-shadow: 0 0 20px var(--cyan), 0 0 60px var(--cyan), 0 0 120px rgba(34, 227, 255, 0.5);
}
.count.tick { animation: count 0.9s cubic-bezier(.2, .9, .2, 1) both; }
.count.go { color: #fffbe6; text-shadow: 0 0 20px var(--gold), 0 0 60px var(--gold); }
@keyframes count {
  from { transform: scale(2.2); opacity: 0; filter: blur(8px); }
  35% { transform: scale(1); opacity: 1; filter: blur(0); }
  to { transform: scale(0.85); opacity: 0.2; }
}

.goal-banner { text-align: center; }
.goal-word {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(4rem, 18vmin, 9rem);
  letter-spacing: 0.1em;
  color: #fff;
  font-style: italic;
  --gc: var(--cyan);
  text-shadow: 0 0 16px var(--gc), 0 0 50px var(--gc), 0 0 110px var(--gc);
}
.goal-who { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.1em; text-transform: uppercase; margin-top: 4px; color: var(--text); text-shadow: 0 2px 10px #000; }
#ov-goal.opp .goal-word { --gc: var(--pink); }
#ov-goal.show .goal-word { animation: goal-in 0.7s cubic-bezier(.2, 1.4, .3, 1) both; }
#ov-goal.show .goal-who { animation: fade-up 0.5s 0.2s both; }
@keyframes goal-in {
  from { transform: scale(0.3) skewX(-12deg); opacity: 0; letter-spacing: 0.6em; }
  to { transform: none; opacity: 1; }
}
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }

.mini-card { text-align: center; max-width: 320px; }
.spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 3px solid rgba(140, 170, 255, 0.2);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.over-card { width: min(400px, calc(100% - 24px)); text-align: center; animation: pop 0.5s cubic-bezier(.2, 1.3, .3, 1) both; max-height: calc(100% - 24px); overflow-y: auto; }
#ov-over:not(.show) .over-card { animation: none; }
@keyframes pop { from { transform: scale(0.85) translateY(20px); opacity: 0; } }
.over-kicker { color: var(--muted); text-transform: uppercase; letter-spacing: 0.2em; font-size: 0.74rem; font-weight: 700; }
.over-title {
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.3rem;
  margin: 6px 0 4px;
  color: #fff;
  text-shadow: 0 0 18px var(--oc, var(--cyan)), 0 0 44px var(--oc, var(--cyan));
}
.over-card.lost { --oc: var(--pink); }
.over-score { font-family: var(--display); font-weight: 800; font-size: 1.2rem; color: var(--muted); margin-bottom: 18px; }
.over-score .y { color: var(--cyan); }
.over-score .o { color: var(--pink); }
.over-card .board { text-align: left; margin-bottom: 18px; }
.over-actions { display: flex; flex-direction: column; gap: 10px; }
.over-actions .btn:not(.btn-lg) { width: 100%; }

/* ------------------------------------------------------------ toasts */

#toasts {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 50;
  pointer-events: none;
  width: calc(100% - 32px);
}
.toast {
  background: rgba(17, 24, 56, 0.92);
  border: 1px solid var(--line-strong);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7);
  animation: toast-in 0.3s cubic-bezier(.2, 1.2, .3, 1) both;
  backdrop-filter: blur(12px);
  max-width: 100%;
}
.toast.out { animation: toast-out 0.3s both; }
.toast.err { border-color: rgba(255, 107, 129, 0.6); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* Phones held sideways: squeeze the HUD so the table gets the height. */
@media (max-height: 520px) {
  #screen-game { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .hud { margin-bottom: 4px; }
  .icon-btn { width: 32px; height: 32px; }
  .sb-side { padding: 3px 10px; }
  .sb-score { font-size: 1.25rem; }
  .sb-first { display: none; }
  .hud-code { display: none; }
  .over-card { padding: 16px; }
  .over-title { font-size: 1.7rem; }
  .brand { margin-bottom: 16px; }
  .logo-puck { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
