/* ═══════════════════════════════════════════════════════════════════════════
   Connect 4 — black and green chrome, with the two disc colours doing the
   talking. The board is the interface, so everything around it is quiet: one
   accent green, red and yellow only for the discs, and a hint/threat highlight
   that reads as an outline rather than as another disc.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --font-display: 'Bebas Neue', 'DM Sans', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --bg: #000000;
  --surface: #0b0b0b;
  --surface2: #131313;
  --surface3: #1c1c1c;
  --border: #232323;
  --border2: #2f2f2f;

  --text: #f5f5f5;
  --muted: #8a8a8a;

  --green: #1db954;
  --green-bright: #1ed760;
  --green-dim: #0f5c2a;
  --red: #e91429;

  /* The board and the two disc colours. */
  --board-bg: #0a1a2f;
  --board-hole: #060d18;
  --disc-one: #e91429;
  --disc-one-light: #ff4a5e;
  --disc-two: #f5c518;
  --disc-two-light: #ffe066;
}

html[data-theme='light'] {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface2: #f0f3f0;
  --surface3: #e6eae6;
  --border: #d8ded8;
  --border2: #c6cec6;
  --text: #101410;
  --muted: #5c665c;
  --board-bg: #dbe6f2;
  --board-hole: #f4f6f4;
  --disc-one: #c8102e;
  --disc-two: #d9a400;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.shell { max-width: 1080px; margin: 0 auto; padding: 14px 16px 44px; }

/* ── Header ────────────────────────────────────────────────────────────── */

.header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.home-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em;
  color: var(--muted); text-decoration: none; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  transition: color .15s, border-color .15s;
}
.home-btn svg { width: 14px; height: 14px; }
.home-btn:hover { color: var(--green); border-color: var(--green-dim); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { font-size: 20px; color: var(--green); line-height: 1; }
.brand-text { font-family: var(--font-display); font-size: 22px; letter-spacing: .12em; }
.header-right { display: flex; align-items: center; gap: 8px; }
.user-badge { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  transition: color .15s, border-color .15s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--green); border-color: var(--green-dim); }

/* ── Screens ───────────────────────────────────────────────────────────── */

.screen { display: none; padding-top: 18px; }
.screen.active { display: block; }

.screen-title {
  font-family: var(--font-display); font-size: 40px; letter-spacing: .04em;
  margin: 0 0 6px;
}
.screen-sub { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 0 18px; max-width: 70ch; }

/* ── Buttons and fields ────────────────────────────────────────────────── */

.btn {
  font-family: var(--font-display); font-size: 16px; letter-spacing: .08em;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border2); border-radius: 10px;
  padding: 9px 16px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { border-color: var(--green); color: var(--green); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #04140a; font-weight: 700; }
.btn-primary:hover { background: var(--green-bright); color: #04140a; }
.btn-sm { font-size: 13px; padding: 6px 11px; border-radius: 8px; }
.btn-danger:hover { border-color: var(--red); color: var(--red); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field-label, .field label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em;
  color: var(--muted); text-transform: uppercase;
}
.field input, .field select, select, input[type="text"], input[type="number"] {
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 8px;
  color: var(--text); padding: 8px 10px; font-family: var(--font-body); font-size: 14px;
}
.field input:focus, select:focus, input:focus { outline: none; border-color: var(--green); }
.checkbox-row { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; margin-bottom: 10px; }

/* ── Menu ──────────────────────────────────────────────────────────────── */

.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.mode-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .18s, background .18s;
}
.mode-card:hover { border-color: var(--green-dim); background: var(--surface2); }
.mode-icon { font-size: 26px; line-height: 1; }
.mode-name { font-family: var(--font-display); font-size: 22px; letter-spacing: .04em; }
.mode-desc { color: var(--muted); font-size: 13px; line-height: 1.5; flex: 1; }
.mode-form { display: flex; flex-direction: column; gap: 8px; }
.join-row { display: flex; gap: 8px; }
.join-row input { width: 5.5rem; letter-spacing: .18em; text-align: center; font-family: var(--font-mono); }
.join-row .btn { flex: 1; }

.record {
  margin-top: 18px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 13px;
}

/* ── Game HUD ──────────────────────────────────────────────────────────── */

.hud {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); margin-bottom: 12px;
}
.hud-left { display: flex; align-items: center; gap: 10px; }
.turn-dot {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--disc-one); box-shadow: inset 0 -3px 0 rgba(0,0,0,.28);
  transition: background .2s;
}
.turn-dot.two { background: var(--disc-two); }
.hud-turns { display: flex; flex-direction: column; }
.hud-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.hud-value { font-family: var(--font-display); font-size: 22px; letter-spacing: .04em; }
.hud-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.hud-stat { display: flex; flex-direction: column; gap: 1px; }
.hud-mode { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.hud-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.online-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 12px; border-radius: 10px;
  border: 1px solid var(--green-dim); background: var(--surface2);
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
}
.online-strip strong { font-family: var(--font-display); font-size: 20px; letter-spacing: .18em; color: var(--green); }

/* ── The board ─────────────────────────────────────────────────────────── */

.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* A row of chevrons above the board: the obvious thing to click, and it keeps
   the board itself a clean grid of holes. */
.drop-row { display: grid; gap: 6px; width: 100%; }
.drop-btn {
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 0; cursor: pointer;
  transition: color .12s, background .12s, border-color .12s;
}
.drop-btn:hover:not(:disabled) { color: var(--green); background: var(--surface2); border-color: var(--green-dim); }
.drop-btn:disabled { opacity: .25; cursor: not-allowed; }
.drop-btn.marked { color: var(--green); }
.drop-btn.warn { color: var(--disc-two); }

.board {
  display: grid; gap: 6px; width: 100%;
  background: var(--board-bg);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 8px;
  touch-action: manipulation;
}
.cell {
  position: relative; background: var(--board-hole); border-radius: 50%;
  aspect-ratio: 1 / 1; overflow: hidden;
}
.cell.playable { cursor: pointer; }
.cell.playable:hover { box-shadow: inset 0 0 0 2px var(--green-dim); }
.disc {
  position: absolute; inset: 8%; border-radius: 50%;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.3);
}
.disc.one { background: radial-gradient(circle at 35% 30%, var(--disc-one-light), var(--disc-one)); }
.disc.two { background: radial-gradient(circle at 35% 30%, var(--disc-two-light), var(--disc-two)); }
.board.no-anim .disc.dropping { animation: none; }
.disc.dropping { animation: drop .3s cubic-bezier(.35, 0, .85, .6); }
@keyframes drop {
  from { transform: translateY(calc(-1 * var(--drop-from, 220px))); }
  to { transform: translateY(0); }
}

/* The winning four, and the threat outlines. */
.cell.win .disc { box-shadow: inset 0 -4px 0 rgba(0,0,0,.3), 0 0 0 3px var(--green-bright), 0 0 14px rgba(29,185,84,.65); }
.cell.hint { box-shadow: inset 0 0 0 3px var(--green); }
.cell.opp-threat { box-shadow: inset 0 0 0 3px var(--disc-two); }

/* ── Banners and overlay ───────────────────────────────────────────────── */

.banner {
  margin: 12px 0; padding: 10px 12px; border-radius: 9px; font-size: 13px;
  border: 1px solid var(--border2); background: var(--surface2); color: var(--muted);
}
.banner.ok { border-color: var(--green-dim); color: var(--green); }
.banner.bad { border-color: var(--red); color: var(--red); }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.82);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.overlay.open { display: flex; }
.overlay-card {
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 14px;
  padding: 24px; max-width: 430px; width: 100%; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.overlay-title { font-family: var(--font-display); font-size: 32px; letter-spacing: .05em; color: var(--green); margin: 0 0 6px; }
.overlay-body { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 14px; }
.overlay-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ── Settings ──────────────────────────────────────────────────────────── */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.panel-title { font-family: var(--font-display); font-size: 18px; letter-spacing: .06em; color: var(--green); margin: 0 0 10px; }
.settings-grid .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.settings-grid .field { flex: 1; }

/* ── Utility ───────────────────────────────────────────────────────────── */

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
