/* ===========================================================================
 *  Shared shell styling for admin / player / bracket.
 *  (spectator.html is deliberately self-contained — it must stay transparent.)
 * ========================================================================= */
:root {
  --bg: #070a18;
  --panel: #0e1330;
  --panel-2: #141a3d;
  --line: #232a55;
  --ink: #eef1ff;
  --muted: #8d97c8;
  --p1: #e8384f;
  --p2: #ffc531;
  --ok: #35d07f;
  --warn: #ffc531;
  --danger: #ff5470;
  --radius: 14px;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(232, 56, 79, 0.14), transparent 60%),
    radial-gradient(900px 500px at 88% -10%, rgba(255, 197, 49, 0.12), transparent 60%);
  background-attachment: fixed;
}

a { color: #9fb4ff; }

/* ---- layout ------------------------------------------------------------ */
.wrap { max-width: 1400px; margin: 0 auto; padding: 24px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 26, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand { font-weight: 800; letter-spacing: 0.02em; font-size: 15px; }
.brand span { color: var(--p2); }
.spacer { flex: 1; }

.tabs { display: flex; gap: 6px; }
.tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--panel-2); border-color: var(--line); color: var(--ink); }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.side { grid-template-columns: 380px 1fr; }
@media (max-width: 1080px) {
  .grid.cols-2, .grid.side { grid-template-columns: 1fr; }
}

.card {
  background: linear-gradient(180deg, var(--panel), rgba(14, 19, 48, 0.7));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

/* ---- controls ---------------------------------------------------------- */
button, .btn {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.25); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.primary { background: #2b3a7a; border-color: #3d51a8; }
button.p1 { background: rgba(232, 56, 79, 0.18); border-color: var(--p1); color: #ffd6dc; }
button.p2 { background: rgba(255, 197, 49, 0.16); border-color: var(--p2); color: #fff0c2; }
button.ghost { background: transparent; }
button.danger { background: rgba(255, 84, 112, 0.14); border-color: var(--danger); color: #ffc9d3; }
button.wide { width: 100%; }

input, select {
  font: inherit;
  font-size: 13px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #080c1e;
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid #3d51a8; outline-offset: -1px; }
label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; }
.row > .fit { flex: 0 0 auto; }

/* ---- bits -------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.live { color: #ffb9c3; border-color: var(--p1); background: rgba(232, 56, 79, 0.14); }
.pill.ok { color: #b6f2d5; border-color: var(--ok); background: rgba(53, 208, 127, 0.12); }
.pill.warn { color: #ffe9ae; border-color: var(--warn); background: rgba(255, 197, 49, 0.12); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; background: #1b2247; border: 1px solid var(--line);
  flex: 0 0 auto;
}
.avatar.lg { width: 52px; height: 52px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; gap: 10px; }
.hidden { display: none !important; }

.list { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid transparent;
}
.list-item:hover { border-color: var(--line); }
.list-item .name { font-weight: 600; font-size: 14px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 12px 20px; border-radius: 12px; font-size: 13px; font-weight: 600;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.toast.show { opacity: 1; }
.toast.err { border-color: var(--danger); color: #ffc9d3; }

.banner {
  border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
  border: 1px solid var(--warn); background: rgba(255, 197, 49, 0.12); color: #ffeec0;
  font-weight: 600; font-size: 14px;
}
.banner.danger { border-color: var(--danger); background: rgba(255, 84, 112, 0.12); color: #ffd3db; }

.log { font-size: 12px; max-height: 220px; overflow-y: auto; }
.log div { padding: 5px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.07); color: var(--muted); }
.log time { color: #5f6aa0; margin-right: 8px; }

/* ---- Connect 4 board (admin preview + player view) --------------------- */
.board {
  --cell: 76px;
  --gap: 10px;
  display: flex;
  gap: var(--gap);
  padding: var(--gap);
  background: linear-gradient(180deg, #1a2358, #101740);
  border: 1px solid #2b3573;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  user-select: none;
}
.board.small { --cell: 40px; --gap: 6px; }

.cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: 50%;
  background: #080d22;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.75);
  position: relative;
}
.cell .disc {
  position: absolute; inset: 0; border-radius: 50%;
  transform: scale(0);
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cell.f1 .disc { background: var(--p1); transform: scale(1); }
.cell.f2 .disc { background: var(--p2); transform: scale(1); }
.cell.drop .disc { animation: c4drop 0.34s cubic-bezier(0.4, 0, 0.6, 1); }
.cell.win .disc { box-shadow: 0 0 0 4px #fff, 0 0 26px rgba(255, 255, 255, 0.75); }
.cell.ghost .disc { transform: scale(1); opacity: 0.28; }

@keyframes c4drop {
  0% { transform: translateY(calc(-6 * (var(--cell) + var(--gap)))) scale(1); }
  100% { transform: translateY(0) scale(1); }
}

/* One flex column per board column — the whole column is the hit target. */
.col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 4px;
  margin: -4px;
  border-radius: 16px;
}
.board.playable .col { cursor: pointer; }
.board.playable .col:hover { background: rgba(255, 255, 255, 0.07); }
.board.playable .col.full { cursor: not-allowed; background: none; }

@media (prefers-reduced-motion: reduce) {
  .cell .disc, .cell.drop .disc { transition: none; animation: none; }
}
