/* Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2330;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --red: #e34c4c;
  --red-dark: #c03030;
  --blue: #4c8fe3;
  --blue-dark: #2f6ec0;
  --gold: #f0c040;
  --gold-dark: #c89a1a;
  --ice: #cce8f5;
  --radius: 10px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

/* Screens */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* Logo */
.logo {
  text-align: center;
  margin-bottom: 8px;
  line-height: 1;
}
.logo-zealot {
  display: block;
  font-family: Impact, Arial Black, sans-serif;
  font-size: 3.5rem;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #fff 0%, var(--ice) 50%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-hockey {
  display: block;
  font-family: Impact, Arial Black, sans-serif;
  font-size: 1.6rem;
  letter-spacing: 8px;
  color: var(--muted);
}
.tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 32px;
}
.welcome-msg {
  text-align: center;
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 1rem;
}
.welcome-msg span { color: var(--gold); font-weight: 600; }

.menu-footer {
  margin-top: 12px;
  margin-bottom: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.9;
  letter-spacing: 0.03em;
}

/* Cards */
.center-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; }
input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus { border-color: var(--blue); }
input[type="text"]::placeholder { color: var(--muted); }

.error-msg { color: var(--red); font-size: 0.85rem; min-height: 18px; }

/* Buttons */
.btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 12px 20px;
  text-transform: uppercase;
  transition: filter 0.15s, transform 0.1s;
  width: 100%;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-2px); }
.btn:active { transform: translateY(0); filter: brightness(0.9); }

.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.btn-gold { background: var(--gold); color: #111; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-small { font-size: 0.8rem; padding: 8px 14px; width: auto; }
.btn-red { background: var(--red); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-grey { background: #444; color: #ccc; }

/* Browser Screen */
.browser-container {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(700px, 95vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  overflow-x: hidden;
  overflow-y: auto;
}
.browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.browser-header h2 { font-size: 1.2rem; }
.header-actions { display: flex; gap: 8px; }

.lobby-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lobby-list::-webkit-scrollbar { width: 6px; }
.lobby-list::-webkit-scrollbar-track { background: transparent; }
.lobby-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.empty-state { color: var(--muted); text-align: center; padding: 40px 0; }

.lobby-item {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.lobby-item:hover { border-color: var(--blue); background: #1e2940; }
.lobby-item-name { font-weight: 600; font-size: 1rem; }
.lobby-item-info { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.lobby-item-btn { flex-shrink: 0; }

.menu-activity-hint {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  margin: 4px 0 0;
  min-height: 1.2em;
}

.browser-section {
  border-bottom: 1px solid var(--border);
}
.browser-section:last-of-type {
  border-bottom: none;
}
.browser-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 12px 16px 8px;
  margin: 0;
}
.browser-section-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  opacity: 0.85;
  font-size: 0.72rem;
}
.browser-live-note {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 16px 12px;
  margin: 0;
  opacity: 0.9;
}

.active-game-item {
  background: linear-gradient(135deg, #1a2235 0%, #151c2e 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
}
.active-game-item-main { min-width: 0; flex: 1; }
.active-game-score {
  flex-shrink: 0;
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.active-game-score .score-red { color: var(--red); }
.active-game-score .score-blue { color: var(--blue); }
.active-game-score .score-sep {
  color: var(--muted);
  margin: 0 4px;
  font-weight: 600;
}

.browser-container .lobby-list {
  flex: none;
  max-height: min(280px, 38vh);
}

/* Lobby Room Screen */
.lobby-room {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(900px, 95vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  overflow: visible;
}
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.lobby-header h2 { font-size: 1.1rem; }

.teams-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  flex: 1;
  overflow: visible;
}
.team-column {
  padding: 16px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.team-column:last-child { border-right: none; }

.team-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
  color: var(--muted);
}
.team-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.team-dot.red { background: var(--red); }
.team-dot.blue { background: var(--blue); }
.team-dot.grey { background: #555; }

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.player-chip {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.player-chip-bot {
  border-left: 3px solid rgba(255, 220, 60, 0.7);
  background: rgba(255, 220, 60, 0.05);
}
.player-chip-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.chip-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-actions .btn {
  font-size: 0.7rem;
  padding: 4px 10px;
  width: auto;
  direction: ltr;
  unicode-bidi: isolate;
}

.lobby-status {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Game Screen */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  gap: 0;
  background: var(--bg);
  overflow: hidden;
}

#game-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: center center;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  width: min(1100px, 100vw);
  /* More top room and extra right padding so HUD buttons don't overlap scores. */
  padding: 4px 72px 6px 24px;
  position: relative;
}

.btn-fullscreen {
  position: absolute;
  right: 10px;
  /* Place controls in the seam between HUD and rink (not over score text). */
  top: calc(100% + 4px);
  z-index: 20;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  padding: 3px 7px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.btn-fullscreen:hover { color: var(--text); border-color: var(--blue); }
.btn-game-menu {
  position: absolute;
  right: 44px;
  /* Place controls in the seam between HUD and rink (not over score text). */
  top: calc(100% + 4px);
  z-index: 20;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 3px 8px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.btn-game-menu:hover { color: var(--text); border-color: var(--blue); }
.game-menu-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.game-menu-overlay.hidden { display: none; }
.game-menu-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 260px;
  align-items: center;
}
.game-menu-card h2 { font-size: 1.6rem; font-family: Impact, sans-serif; letter-spacing: 3px; margin-bottom: 6px; }
.btn-danger { background: #7a1a1a; border-color: #c0392b; color: #fff; }
.btn-danger:hover { background: #a02020; border-color: #e74c3c; }
.hud-center {
  display: flex;
  align-items: center;
  gap: 0;
}
.hud-scoreboard {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 18px;
}
.hud-clock-block {
  text-align: center;
}
.hud-period-block {
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.team-label {
  font-family: Impact, sans-serif;
  font-size: 1rem;
  letter-spacing: 3px;
}
.team-label.red { color: var(--red); }
.team-label.blue { color: var(--blue); }
.score-num {
  font-family: Impact, sans-serif;
  font-size: 2rem;
  color: var(--text);
  min-width: 28px;
  text-align: center;
}
.score-dash {
  font-family: Impact, sans-serif;
  font-size: 1.6rem;
  color: var(--muted);
  margin: 0 2px;
}
#game-clock {
  font-family: Impact, 'Courier New', monospace;
  font-size: 1.8rem;
  color: var(--gold);
  letter-spacing: 2px;
}
#game-period {
  font-family: Impact, sans-serif;
  font-size: 1rem;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
}
.hud-shot-counter {
  margin-top: 1px;
  font-size: 0.7rem;
  letter-spacing: 0.7px;
  color: #9fb0c7;
}

.canvas-container {
  position: relative;
  width: min(1100px, 100vw);
  flex-shrink: 0;
}
#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0 0 10px 10px;
  cursor: crosshair;
}
#game-canvas:hover { cursor: crosshair; }

/* Goal Banner */
.goal-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: Impact, sans-serif;
  font-size: 3.85rem;
  letter-spacing: 3px;
  text-shadow: 0 0 30px currentColor, 0 4px 12px rgba(0,0,0,0.8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: pre-line;
  line-height: 1.05;
  text-align: center;
}
.goal-banner.show { opacity: 1; animation: goalPop 0.3s ease-out; }
.goal-banner.hidden { display: none; }
.goal-banner.goal-red { color: var(--red); }
.goal-banner.goal-blue { color: var(--blue); }
.goal-banner.goal-own { color: #f07820; }

@keyframes goalPop {
  0% { transform: translate(-50%, -50%) scale(0.5); }
  60% { transform: translate(-50%, -50%) scale(1.1); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* End Overlay */
.end-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 0 10px 10px;
}
.end-overlay.hidden { display: none; }
.end-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 320px;
}
.end-card h2 { font-size: 2rem; font-family: Impact, sans-serif; letter-spacing: 3px; }
.end-score { font-size: 1.1rem; color: var(--muted); }
.end-score strong { color: var(--text); }

/* Period Break Overlay */
.period-break-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 0 10px 10px;
  padding: 14px;
}
.period-break-overlay.hidden { display: none; }
.break-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  width: min(1040px, 96vw);
  box-shadow: 0 16px 60px rgba(0,0,0,0.6);
}
.break-card h2 {
  font-size: 1.6rem;
  font-family: Impact, sans-serif;
  letter-spacing: 3px;
}
.break-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}
.break-teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.break-team {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 8px 5px;
}
.break-team-title {
  font-family: Impact, sans-serif;
  letter-spacing: 3px;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.break-team.break-red .break-team-title { color: var(--red); }
.break-team.break-blue .break-team-title { color: var(--blue); }

.break-player-row {
  display: flex;
  gap: 8px;
  padding: 4px 3px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.break-player-row:first-child { border-top: none; }
.break-player-name {
  width: 98px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.break-leader-crown {
  color: #f0c040;
  font-size: 0.72rem;
  vertical-align: baseline;
}
.break-player-stats {
  flex: 1;
  display: grid;
  /* 13 stats -> compact row for up to 4 players/team */
  grid-template-columns: repeat(13, minmax(27px, 1fr));
  gap: 3px;
}
.break-stat-cell {
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 7px;
  padding: 3px 2px 2px;
  text-align: center;
  position: relative;
  cursor: help;
}
.break-stat-cell::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: rgba(10, 12, 16, 0.98);
  color: #e6edf7;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 0.68rem;
  line-height: 1.2;
  letter-spacing: 0.2px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 5;
}
.break-stat-cell:hover::after {
  opacity: 1;
}
.break-stat-label {
  font-size: 0.50rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  line-height: 1;
}
.break-stat-value {
  margin-top: 1px;
  font-family: Impact, 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1;
  color: var(--text);
}
.break-stat-cell--points {
  border-color: rgba(240, 192, 64, 0.45);
  background: linear-gradient(180deg, rgba(240, 192, 64, 0.18), rgba(0, 0, 0, 0.22));
}
.break-stat-label--points {
  color: #ffd77a;
  font-size: 0.54rem;
  letter-spacing: 0.75px;
}
.break-stat-value--points {
  color: #ffd77a;
  font-size: 0.92rem;
  font-weight: 900;
}
.break-stat-value--best {
  font-weight: 800;
  color: #3fb950;
}
.break-stat-value--worst {
  color: #e34c4c;
}

/* End-game stats section */
.end-stats {
  margin-top: 8px;
}
.end-stats.hidden { display: none; }
.end-stats-teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.end-team {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 8px 5px;
}
.end-team-title {
  font-family: Impact, sans-serif;
  letter-spacing: 3px;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.end-team.end-red .end-team-title { color: var(--red); }
.end-team.end-blue .end-team-title { color: var(--blue); }

@media (max-width: 980px) {
  .break-teams,
  .end-stats-teams {
    grid-template-columns: 1fr;
  }
}

/* Options Modal */
.options-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 18px;
}
.options-overlay.hidden { display: none; }
.options-card {
  width: min(880px, 96vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 22px 80px rgba(0,0,0,0.65);
  padding: 26px 24px;
}
.options-card h2 {
  font-size: 2rem;
  font-family: Impact, sans-serif;
  letter-spacing: 3px;
  margin-bottom: 10px;
}
.options-help {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 18px;
}
.options-section { margin-top: 16px; }
.options-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.options-toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}
.options-slider-row {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.options-slider-label {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
}
.options-slider-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 230px;
}
.options-slider-control input[type="range"] {
  width: 180px;
  accent-color: var(--blue);
}
.options-slider-value {
  min-width: 44px;
  text-align: right;
  color: var(--muted);
  font-weight: 700;
}
.options-section-title {
  font-family: Impact, sans-serif;
  letter-spacing: 3px;
  font-size: 1.05rem;
  color: var(--gold);
  margin-bottom: 10px;
}
.rebind-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.rebind-row {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.rebind-label {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
}
.rebind-key {
  min-width: 64px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  color: var(--text);
  font-family: Impact, 'Courier New', monospace;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, filter 0.15s;
}
.rebind-key:hover {
  border-color: rgba(76,143,227,0.6);
  filter: brightness(1.1);
}
.rebind-key:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  filter: none;
}
.options-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.options-name-label {
  color: var(--muted);
  font-weight: 700;
}
.options-name-input {
  flex: 0 0 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}
.options-name-lock {
  color: var(--muted);
  font-size: 0.85rem;
}
.options-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}
.options-actions .btn { width: auto; }

/* ── Lobby Name Modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: min(420px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 16px 60px rgba(0,0,0,0.7);
}
.modal-title {
  font-family: Impact, Arial Black, sans-serif;
  letter-spacing: 3px;
  font-size: 1.5rem;
  color: var(--gold);
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions .btn { flex: 1; }
.modal-card-wide { width: min(460px, 94vw); }

.lobby-game-info {
  padding: 8px 20px 4px;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}
.lobby-game-mode {
  display: inline-block;
  font-weight: 700;
  color: var(--gold);
  margin-right: 6px;
}
.lobby-game-rules {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text);
}
.lobby-go-mode-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lobby-go-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.95rem;
}
.lobby-practice-rules {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.lobby-practice-rules.hidden { display: none; }
.lobby-go-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 2px;
}
.lobby-rule-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
}

/* ── Customize Screen ────────────────────────────────────────────────────── */
.customize-card {
  max-width: 520px;
  width: min(520px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
}
.customize-card::-webkit-scrollbar { width: 5px; }
.customize-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.customize-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.customize-section-title {
  font-family: Impact, Arial Black, sans-serif;
  letter-spacing: 2px;
  font-size: 1rem;
  color: var(--gold);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.customize-section-sub {
  color: var(--muted);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0;
  font-weight: 400;
  text-transform: none;
}
.customize-name-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.name-lock-msg {
  color: var(--muted);
  font-size: 0.8rem;
}
.name-lock-msg.hidden { display: none; }

/* Horn selection grid */
.horn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.horn-card {
  background: var(--panel2);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.horn-card:hover { border-color: var(--blue); background: #1a2235; }
.horn-card.selected {
  border-color: var(--gold);
  background: rgba(240, 192, 64, 0.07);
}
.horn-card-wide {
  grid-column: span 2;
}
.horn-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.horn-upload-icon {
  width: 22px;
  height: 22px;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.15s;
}
.horn-card:hover .horn-upload-icon { color: var(--blue); }
.horn-card.selected .horn-upload-icon { color: var(--gold); }
.horn-preview-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.65rem;
  height: 28px;
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.horn-preview-btn:hover {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.horn-custom-status {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 9px;
  border-radius: 999px;
  margin-top: 3px;
  display: inline-block;
}
.horn-custom-status:empty { display: none; }
.horn-custom-status.pending { background: rgba(158,106,3,.25); color: #f0c040; border: 1px solid #9e6a03; }
.horn-custom-status.approved { background: rgba(26,71,48,.35); color: #3fb950; border: 1px solid #238636; }
.horn-custom-status.denied { background: rgba(61,20,20,.35); color: #f85149; border: 1px solid #da3633; }

/* Custom upload section */
.custom-horn-section {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.custom-horn-section.hidden { display: none; }
.upload-instructions { color: var(--muted); font-size: 0.82rem; }
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-file-label {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 7px 13px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
.upload-file-label:hover { border-color: var(--blue); }
.upload-file-label input[type="file"] { display: none; }
.horn-file-name {
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.horn-upload-success { color: #3fb950; font-size: 0.85rem; }
.horn-upload-success.hidden { display: none; }

.customize-actions {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}
.customize-actions .btn { flex: 1; }

/* Password section in Customize */
.pw-section { display: flex; flex-direction: column; gap: 10px; }
.pw-show-wrap { display: flex; flex-direction: row; align-items: center; gap: 6px; }
.pw-show-wrap input { flex: 1; }
.btn-show-pw {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.btn-show-pw:hover { color: var(--text); border-color: var(--blue); }
.pw-success { color: #3fb950; font-size: 0.85rem; }
.pw-success.hidden { display: none; }

/* Auth phase (name entry screen) */
.auth-phase { display: flex; flex-direction: column; gap: 10px; }
.auth-phase.hidden { display: none; }
.auth-msg { color: var(--muted); font-size: 0.88rem; text-align: center; }
#confirm-row.hidden { display: none; }

/* Pause Overlay */
.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.pause-overlay.hidden { display: none; }
.pause-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 44px;
  text-align: center;
  min-width: 300px;
  box-shadow: 0 16px 60px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.pause-title {
  font-family: Impact, sans-serif;
  font-size: 2.2rem;
  letter-spacing: 4px;
  color: var(--text);
  margin: 0;
}
.pause-team-label {
  font-size: 0.95rem;
  color: var(--muted);
  letter-spacing: 1px;
}
.pause-countdown {
  font-family: Impact, sans-serif;
  font-size: 3.2rem;
  letter-spacing: 2px;
  color: var(--text);
  line-height: 1;
  min-height: 3.5rem;
}
.pause-countdown.low { color: #e34c4c; }
.pause-expired-msg {
  font-size: 0.88rem;
  color: var(--muted);
}
.pause-expired-msg.hidden { display: none; }
.pause-hint {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.7;
}

/* Custom horn multi-slot */
.custom-slot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}
.custom-slot:first-of-type { border-top: none; margin-top: 4px; }
.custom-slot-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.custom-slot-num {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  letter-spacing: 0.5px;
}

/* ── Horn Picker Row (customize screen) ─────────────────────────────────── */
.horn-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.horn-current-label {
  flex: 1;
  padding: 8px 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  color: var(--text);
}

/* ── Goal Horn Modal ─────────────────────────────────────────────────────── */
.horn-modal-card {
  width: min(720px, 96vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 22px 80px rgba(0,0,0,0.65);
  padding: 28px 26px 24px;
}
.horn-modal-header {
  margin-bottom: 16px;
}
.horn-modal-title {
  font-size: 1.9rem;
  font-family: Impact, sans-serif;
  letter-spacing: 3px;
  margin-bottom: 4px;
}
.horn-modal-sub {
  color: var(--muted);
  font-size: 0.88rem;
}
.horn-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

/* ── Boost Skin Modal ────────────────────────────────────────────────────── */
.boost-modal-card {
  width: min(780px, 96vw);
}
.boost-skin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.boost-skin-card {
  background: var(--panel2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.boost-skin-card:hover { border-color: var(--blue); background: #1a2235; }
.boost-skin-card.selected {
  border-color: var(--gold);
  background: rgba(240, 192, 64, 0.07);
}
.boost-skin-preview {
  width: 120px;
  height: 70px;
  border-radius: 6px;
  background: #080e1a;
  display: block;
}
.boost-skin-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  text-align: center;
}

/* ── Lobby Chat ─────────────────────────────────────────────────────────── */
.lobby-chat {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lobby-chat-messages {
  max-height: 110px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
  color: var(--text);
  scrollbar-width: thin;
}
.lobby-chat-messages .chat-msg {
  line-height: 1.4;
  word-break: break-word;
}
.lobby-chat-messages .chat-msg .chat-sender {
  font-weight: 700;
  margin-right: 4px;
}
.lobby-chat-messages .chat-msg .chat-sender.team-red  { color: var(--red); }
.lobby-chat-messages .chat-msg .chat-sender.team-blue { color: var(--blue); }
.lobby-chat-messages .chat-msg .chat-sender.team-spectator { color: var(--muted); }
.lobby-chat-input-row {
  display: flex;
  gap: 6px;
}
.lobby-chat-input {
  flex: 1;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font-size: 0.85rem;
  outline: none;
}
.lobby-chat-input:focus { border-color: var(--blue); }

/* ── In-game Chat Overlay ────────────────────────────────────────────────── */
#game-chat-overlay {
  position: absolute;
  left: 10px;
  bottom: 52px;
  width: 340px;
  pointer-events: none;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#game-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 160px;
  overflow: hidden;
  justify-content: flex-end;
}
.gchat-msg {
  font-size: 0.8rem;
  line-height: 1.35;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.52);
  color: #e8f0f8;
  word-break: break-word;
  transition: opacity 1s ease;
  max-width: 100%;
}
.gchat-msg.fading { opacity: 0; }
.gchat-msg .gchat-sender { font-weight: 700; margin-right: 4px; }
.gchat-msg .gchat-sender.team-red  { color: #f07070; }
.gchat-msg .gchat-sender.team-blue { color: #70a8f0; }
.gchat-msg .gchat-scope-all { color: rgba(255,220,60,0.75); font-size: 0.72rem; margin-right: 3px; }
#game-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.68);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 8px;
  pointer-events: auto;
}
#game-chat-input-bar.hidden { display: none; }
#game-chat-scope-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
#game-chat-scope-badge.chat-scope-team {
  background: rgba(76,143,227,0.25);
  color: #70a8f0;
  border: 1px solid rgba(76,143,227,0.4);
}
#game-chat-scope-badge.chat-scope-all {
  background: rgba(240,192,64,0.2);
  color: #f0c040;
  border: 1px solid rgba(240,192,64,0.4);
}
#game-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e8f0f8;
  font-size: 0.83rem;
  font-family: inherit;
  caret-color: #f0c040;
}

/* ── Shot Clock Bar ─────────────────────────────────────────────────────── */
.shot-clock-bar {
  display: flex;
  width: min(1100px, 100vw);
  height: 6px;
  gap: 2px;
  flex-shrink: 0;
}
.sc-half {
  flex: 1;
  background: #1c2330;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.sc-half-red { border-radius: 3px 3px 3px 3px; }
.sc-half-blue { border-radius: 3px 3px 3px 3px; }
/* Red fill drains right→left; blue fill drains left→right */
.sc-fill-red {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 100%;
  background: #4c8fe3;
  border-radius: 3px;
  transform-origin: left center;
  transition: width 0.12s linear, background-color 0.3s;
}
.sc-fill-blue {
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  width: 100%;
  background: #4c8fe3;
  border-radius: 3px;
  transform-origin: right center;
  transition: width 0.12s linear, background-color 0.3s;
}
.sc-fill-red.sc-urgent, .sc-fill-blue.sc-urgent {
  background: #e34c4c;
}
.sc-fill-red.sc-inactive, .sc-fill-blue.sc-inactive {
  opacity: 0.25;
}

/* ── Loading Screen ──────────────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 32px;
  min-width: 380px;
  max-width: 520px;
  width: 90vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}
.loading-logo {
  font-family: Impact, Arial Black, sans-serif;
  font-size: 2.4rem;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #fff 0%, var(--ice) 50%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.loading-logo span {
  background: linear-gradient(135deg, var(--ice) 0%, var(--blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.loading-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.loading-spinner-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.loading-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  animation: loadingBounce 1.2s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; background: var(--ice); }
.loading-dot:nth-child(3) { animation-delay: 0.4s; background: var(--gold); }
@keyframes loadingBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1.1); opacity: 1; }
}
.loading-players-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 4px;
}
.loading-player-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.loading-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}
.loading-player-name {
  font-weight: 600;
  color: var(--text);
}
.loading-player-status {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.loading-player-status.ready {
  color: #3fb950;
}
.loading-bar-track {
  width: 100%;
  height: 8px;
  background: var(--panel2);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.loading-bar-fill {
  height: 100%;
  border-radius: 4px;
  width: 0%;
  transition: width 0.4s ease;
  background: linear-gradient(90deg, var(--blue-dark), var(--blue), var(--ice));
}
.loading-bar-fill.ready {
  width: 100%;
  background: linear-gradient(90deg, #2ea043, #3fb950, #7ee787);
}
.loading-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 6px;
}
.loading-status-text {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Loading Leave Confirm */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-backdrop.hidden { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 28px 24px;
  width: 90vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}
