:root {
  --bg-void: #07090d;
  --bg-panel: #0c0f16;
  --bg-surface: #141925;
  --bg-surface-hover: #1b2232;
  --border-hairline: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;
  --accent-crimson: #ef4444;
  --font-display: 'Chakra Petch', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

/* ================= AUTH SPLASH SCREEN ================= */

.splash-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 35%, #131926 0%, #07090d 72%);
  z-index: 100;
}

.splash-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 28px;
}

.splash-header {
  text-align: center;
  margin-bottom: 22px;
}

.splash-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.splash-subtitle {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: var(--bg-void);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  margin-bottom: 18px;
}

.auth-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease;
}

.auth-tab:hover {
  color: var(--text-primary);
}

.auth-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
}

.auth-form input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-void);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
}

.field-hint {
  margin: 2px 0 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.primary-btn {
  appearance: none;
  border: none;
  background: var(--accent-amber);
  color: #0b0d12;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  padding: 11px 16px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  margin-top: 6px;
  transition: filter 150ms ease, transform 120ms ease;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.primary-btn:active {
  transform: scale(0.99);
}

.auth-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 8px;
  color: #fecaca;
  font-size: 13px;
}

.splash-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.subtle-link {
  color: var(--text-secondary);
  text-decoration: underline;
  white-space: nowrap;
}

.subtle-link:hover {
  color: var(--text-primary);
}

/* ================= 3-COLUMN WIDESCREEN LAYOUT ================= */

.game-shell {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr) 332px;
  width: 100vw;
  height: 100vh;
  background: var(--bg-void);
}

.side-panel {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding: 14px;
  gap: 14px;
}

.left-panel {
  border-right: 1px solid var(--border-hairline);
}

.right-panel {
  border-left: 1px solid var(--border-hairline);
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-hairline);
}

.user-identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease;
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* Ready Button + X/Y READY */

.ready-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ready-btn {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.ready-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ready-btn.state-not-ready {
  background: rgba(245, 158, 11, 0.16);
  border-color: var(--accent-amber);
  color: #fde68a;
}

.ready-btn.state-not-ready:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.25);
}

.ready-btn.state-ready {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #052e16;
}

.ready-counter {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

/* Color Grid */

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.color-swatch {
  position: relative;
  height: 40px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease, border-color 120ms ease;
}

.color-swatch:hover:not(:disabled) {
  transform: scale(1.04);
  border-color: #ffffff;
}

.color-swatch.selected-self {
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 2px #000000 inset;
}

.color-swatch.taken-other {
  cursor: not-allowed;
  opacity: 0.85;
}

.color-swatch.taken-other::before,
.color-swatch.taken-other::after {
  content: '';
  position: absolute;
  width: 74%;
  height: 4px;
  background: #000000;
  border-radius: 2px;
}

.color-swatch.taken-other::before {
  transform: rotate(45deg);
}

.color-swatch.taken-other::after {
  transform: rotate(-45deg);
}

/* Players & Spectators Lists */

.list-section {
  min-height: 0;
  flex: 1 1 auto;
}

.roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.roster-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
}

.roster-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.roster-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.roster-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roster-name.uncolored {
  color: #8b95a7;
}

.roster-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-secondary);
}

.ready-mark {
  color: var(--accent-emerald);
  font-weight: 700;
}

.spectators-list .roster-row {
  background: rgba(20, 25, 37, 0.55);
}

.empty-roster {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 2px;
}

.panel-footer {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-hairline);
}

.secondary-btn {
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease;
}

.secondary-btn:hover {
  background: var(--bg-surface-hover);
}

/* ================= CENTRAL GAME VIEWPORT ================= */

.arena-stage {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  background: #05070a;
  padding: 10px 14px 14px;
  gap: 8px;
}

.arena-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  min-height: 36px;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.hud-mode {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--accent-amber);
}

.hud-mode.is-match {
  color: var(--accent-emerald);
}

.hud-sep {
  color: var(--text-muted);
}

.hud-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text-primary);
}

.hud-notice {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-canvas {
  display: block;
  background: #142417;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Victory Overlay */

.victory-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 10, 0.78);
  padding: 20px;
  z-index: 20;
}

.victory-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-panel);
  border: 1px solid var(--accent-amber);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.victory-kicker {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-amber);
}

.victory-winner {
  margin: 6px 0 4px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}

.victory-subtitle {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.victory-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
  font-size: 13px;
}

.victory-table th,
.victory-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-hairline);
  text-align: left;
}

.victory-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.victory-table td:not(:first-child),
.victory-table th:not(:first-child) {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ================= RIGHT PANEL: HALL OF FAME ================= */

.panel-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-hairline);
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.panel-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.hof-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  padding-right: 2px;
}

.hof-card {
  width: 100%;
  text-align: left;
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.hof-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.hof-card-name {
  text-align: center;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-amber);
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: 4px;
}

.hof-metrics {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--text-primary);
}

.hof-line {
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hof-sublist {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.hof-sublist strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ================= MODALS ================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 80;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 86vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-wide {
  max-width: 820px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-hairline);
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  padding: 10px 12px;
}

.stat-box-label {
  font-size: 11px;
  color: var(--text-muted);
}

.stat-box-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-hairline);
  text-align: left;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.match-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.match-winner {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-amber);
}

.match-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.match-highlights {
  font-size: 12px;
  color: var(--text-secondary);
}
