/* Omega Schach - Night-Lounge Design & 4 Brett-Themes */
:root {
  --bg: #0b0e14;
  --bg-card: #131823;
  --bg-elev: #1a2130;
  --border: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(234, 179, 8, 0.35);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --gold: #eab308;
  --gold-bright: #facc15;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #38bdf8;

  /* Default Theme: Walnuss-Gold */
  --sq-light: #e7d3b1;
  --sq-dark: #8c5a3c;
  --board-frame: #3a2214;
  --sq-last: rgba(234, 179, 8, 0.42);
  --sq-sel: rgba(56, 189, 248, 0.48);
  --sq-premove: rgba(168, 85, 247, 0.48);
  --sq-mark: rgba(239, 68, 68, 0.52);
}

body.theme-obsidian {
  --sq-light: #334155;
  --sq-dark: #111827;
  --board-frame: #020617;
  --sq-last: rgba(56, 189, 248, 0.36);
}

body.theme-emerald {
  --sq-light: #ebecd0;
  --sq-dark: #4f7d52;
  --board-frame: #1c3520;
  --sq-last: rgba(250, 204, 21, 0.46);
}

body.theme-marble {
  --sq-light: #d6dde6;
  --sq-dark: #5b697c;
  --board-frame: #1e2530;
  --sq-last: rgba(234, 179, 8, 0.44);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at top center, #141c2b 0%, var(--bg) 62%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.gold { color: var(--gold-bright); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.74rem; }
.full-w { width: 100%; }

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(11, 14, 20, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.28), 0 0 10px rgba(234, 179, 8, 0.25);
}

.brand-title {
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 0.98rem;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--gold);
  opacity: 0.85;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  margin-left: 8px;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.nav-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: #111827;
  background: var(--gold);
  border-color: var(--gold-bright);
}

.player-name-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 8px;
}

.label-mini {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-name-box input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  width: 125px;
  outline: none;
}

.select-compact {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.84rem;
  outline: none;
  cursor: pointer;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.icon-btn-sm {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.icon-btn:hover, .icon-btn-sm:hover {
  border-color: var(--border-gold);
}

/* BUTTONS */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 15px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active { transform: scale(0.98); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; border-radius: 7px; }

.btn-gold {
  background: linear-gradient(135deg, #facc15, #d97706);
  color: #111827;
}
.btn-gold:hover { filter: brightness(1.08); }

.btn-outline {
  background: transparent;
  border-color: var(--border-gold);
  color: var(--gold-bright);
}
.btn-outline:hover { background: rgba(234, 179, 8, 0.12); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.28); }

/* VIEWS & CARDS */
.view {
  display: none;
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px 20px 36px;
}
.view.active { display: block; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.compact-card { padding: 12px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 700; }

.hero-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.12), rgba(19, 24, 35, 0.95) 55%);
  border: 1px solid var(--border-gold);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.hero-strip h1 { font-size: 1.45rem; margin-bottom: 4px; }
.hero-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* LOBBY */
.lobby-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  align-items: start;
}

.sidebar-stack { display: flex; flex-direction: column; gap: 16px; }
.list-stack { display: flex; flex-direction: column; gap: 10px; }

.room-item, .tourney-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: border-color 0.15s ease;
}

.room-item:hover, .tourney-item:hover {
  border-color: var(--border-gold);
}

.item-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.badge-row, .meta-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.badge-gold { background: rgba(234, 179, 8, 0.2); color: var(--gold-bright); border: 1px solid var(--border-gold); }
.badge-green { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.badge-red { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-blue { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; }

.empty-state {
  text-align: center;
  padding: 28px 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.join-code-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.join-code-row.compact { margin-top: 0; }

.join-code-row input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  outline: none;
}

.join-code-row input:focus { border-color: var(--gold); }

.quick-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 10px;
}

.quick-mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 11px;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.quick-mode-btn:hover { border-color: var(--border-gold); transform: translateY(-1px); }
.quick-mode-btn span { font-size: 1.4rem; }
.quick-mode-btn strong { display: block; font-size: 0.86rem; }
.quick-mode-btn small { color: var(--muted); font-size: 0.74rem; }

/* TOURNAMENT DETAIL */
.tourney-header-card {
  margin-bottom: 16px;
  border-color: var(--border-gold);
}

.tourney-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.tourney-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.arena-timer {
  background: rgba(234, 179, 8, 0.16);
  border: 1px solid var(--border-gold);
  color: var(--gold-bright);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 1rem;
}

.champion-banner {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.25), rgba(217, 119, 6, 0.1));
  border: 1px solid var(--gold);
  font-weight: 800;
  font-size: 1rem;
  color: var(--gold-bright);
}

.tourney-body-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
  align-items: start;
}

.bracket-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.bracket-round {
  min-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bracket-round-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gold);
  font-weight: 800;
  margin-bottom: 4px;
}

.bracket-match {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.84rem;
}

.bracket-match.playing { border-color: var(--green); }
.bracket-match.finished { opacity: 0.88; }

.bracket-slot {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.bracket-slot.winner { color: var(--gold-bright); font-weight: 800; }

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

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

.standings-table th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

/* GAME LAYOUT */
.waiting-banner, .puzzle-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid var(--border-gold);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.waiting-left { display: flex; align-items: center; gap: 10px; }
.puzzle-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pulse-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.7);
  animation: pulseGold 1.6s infinite;
}

@keyframes pulseGold {
  0% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.65); }
  70% { box-shadow: 0 0 0 10px rgba(250, 204, 21, 0); }
  100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0); }
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(320px, 640px) minmax(290px, 1fr);
  gap: 20px;
  align-items: start;
  justify-content: center;
}

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

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 8px 13px;
}

.player-bar.active-turn {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(234, 179, 8, 0.14);
}

.player-bar-left, .player-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-gold);
}
.color-dot.white { background: #f8fafc; }
.color-dot.black { background: #1e293b; }

.player-bar-name { font-weight: 700; font-size: 0.94rem; }

.captured-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 16px;
  font-size: 0.78rem;
  color: var(--muted);
}

.mat-adv {
  margin-left: 5px;
  color: var(--gold-bright);
  font-weight: 800;
  font-size: 0.78rem;
}

.check-badge {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 800;
}

.clock-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.18rem;
  font-weight: 800;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 8px;
  min-width: 82px;
  text-align: center;
}

.clock-box.low-time {
  background: rgba(239, 68, 68, 0.22);
  border-color: var(--red);
  color: #fecaca;
}

/* CHESSBOARD */
.board-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 8px;
  background: var(--board-frame);
  border-radius: 14px;
  border: 2px solid var(--border-gold);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
  user-select: none;
  touch-action: none;
}

.chess-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 6px;
  overflow: hidden;
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last-move::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--sq-last);
  pointer-events: none;
}
.sq.selected::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--sq-sel);
  pointer-events: none;
}
.sq.premove-sq::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--sq-premove);
  pointer-events: none;
}
.sq.marked-sq::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--sq-mark);
  pointer-events: none;
}
.sq.koth-center {
  box-shadow: inset 0 0 0 2px rgba(250, 204, 21, 0.55);
}
.sq.in-check {
  background: radial-gradient(circle, #ef4444 0%, #991b1b 70%, var(--sq-dark) 100%) !important;
}

.sq-coord-rank {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.65rem;
  font-weight: 800;
  opacity: 0.68;
  pointer-events: none;
}

.sq-coord-file {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.65rem;
  font-weight: 800;
  opacity: 0.68;
  pointer-events: none;
}

.sq.light .sq-coord-rank, .sq.light .sq-coord-file { color: #3a2214; }
.sq.dark .sq-coord-rank, .sq.dark .sq-coord-file { color: #f1e5d1; }

.legal-dot {
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.38);
  pointer-events: none;
  z-index: 3;
}

.legal-capture-ring {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 5px solid rgba(15, 23, 42, 0.42);
  pointer-events: none;
  z-index: 3;
}

.piece-wrap {
  width: 90%;
  height: 90%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease;
}

.piece-wrap:hover { transform: scale(1.04); }
.chess-piece-svg { width: 100%; height: 100%; pointer-events: none; }

.arrow-overlay {
  position: absolute;
  inset: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  pointer-events: none;
  z-index: 6;
}

.board-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* SIDE PANEL */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.opening-box {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.opening-box span { color: var(--gold-bright); font-weight: 600; }

.status-banner {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-elev);
  font-weight: 700;
  font-size: 0.88rem;
  text-align: center;
}

.moves-card {
  display: flex;
  flex-direction: column;
}

.replay-btns { display: flex; gap: 4px; }

.move-list {
  max-height: 185px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  gap: 2px 6px;
  font-size: 0.84rem;
  padding-right: 4px;
}

.move-num { color: var(--muted); font-size: 0.78rem; padding: 4px 2px; }
.move-cell {
  padding: 4px 7px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}
.move-cell:hover { background: rgba(255, 255, 255, 0.08); }
.move-cell.active { background: var(--gold); color: #111827; }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

/* CHAT */
.chat-card {
  display: flex;
  flex-direction: column;
}

.chat-messages {
  height: 175px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.chat-msg { line-height: 1.35; word-break: break-word; }
.chat-msg.system { color: var(--gold-bright); font-style: italic; font-size: 0.78rem; }
.chat-sender { font-weight: 700; color: #7dd3fc; margin-right: 5px; }

.quick-chat-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.quick-chat-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.quick-chat-chip:hover { color: var(--text); border-color: var(--border-gold); }

.chat-form { display: flex; gap: 6px; }
.chat-form input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
}
.chat-form input:focus { border-color: var(--gold); }

/* MODALS */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 470px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-header h2 { font-size: 1.08rem; }

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.modal-form input[type="text"], .modal-form select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
}

.modal-form input:focus, .modal-form select:focus { border-color: var(--gold); }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox-row { display: flex; flex-direction: column; gap: 7px; }
.check-inline {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  color: var(--text) !important;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.promo-box { max-width: 340px; text-align: center; }
.promo-choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.promo-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
}
.promo-btn:hover { background: rgba(234, 179, 8, 0.2); }

/* TOASTS */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

/* RESPONSIVE */
@media (max-width: 960px) {
  .lobby-grid, .tourney-body-grid, .game-layout {
    grid-template-columns: 1fr;
  }
  .board-column { max-width: 560px; width: 100%; margin: 0 auto; }
}
