:root {
  --bg: #0b1020;
  --bg2: #121a33;
  --panel: #16203d;
  --board: #1d4ed8;
  --board-dark: #1736a8;
  --hole: #0b1020;
  --red: #ef4444;
  --red-glow: #f87171;
  --yellow: #facc15;
  --yellow-glow: #fde047;
  --text: #e8edf7;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --good: #22c55e;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 800px at 50% -10%, #1b2a52 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Discs ---------- */
.disc {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.35), inset 0 3px 5px rgba(255,255,255,.25);
}
.disc.small { width: 20px; height: 20px; }
.disc.red { background: radial-gradient(circle at 35% 30%, var(--red-glow), var(--red)); }
.disc.yellow { background: radial-gradient(circle at 35% 30%, var(--yellow-glow), var(--yellow)); }

/* ---------- Buttons ---------- */
.btn {
  border: none; cursor: pointer;
  font-size: 1rem; font-weight: 700;
  padding: 14px 22px; border-radius: 12px;
  color: #fff; transition: transform .08s ease, filter .15s ease, opacity .15s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); box-shadow: 0 6px 18px rgba(37,99,235,.4); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: #334155; }
.btn-ghost { background: rgba(255,255,255,.08); color: var(--text); }
.btn-lg { font-size: 1.15rem; padding: 16px 28px; width: 100%; }

/* ---------- Landing ---------- */
.landing { display: flex; }
.hero {
  min-height: 100dvh; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.hero-card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 24px; box-shadow: var(--shadow);
  padding: 32px 26px; max-width: 460px; width: 100%; text-align: center;
}
.logo-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.hero h1 { font-size: 2.2rem; margin: .2em 0; letter-spacing: -.5px; }
.tagline { color: var(--muted); line-height: 1.5; margin: 0 0 22px; }
.tagline strong { color: var(--text); }
.name-field { text-align: left; margin-bottom: 16px; }
.name-field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.name-field input, .invite-row input {
  width: 100%; padding: 13px 14px; border-radius: 11px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.25);
  color: var(--text); font-size: 1rem;
}
.name-field input:focus, .invite-row input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.features { list-style: none; padding: 0; margin: 22px 0 0; color: var(--muted); font-size: .92rem; line-height: 2; text-align: left; }
.how { margin-top: 18px; text-align: left; color: var(--muted); }
.how summary { cursor: pointer; font-weight: 600; color: var(--text); }
.how p { line-height: 1.6; font-size: .92rem; }
.hero-foot { margin-top: 22px; color: var(--muted); font-size: .8rem; }
.error-msg { color: var(--red-glow); margin-top: 12px; font-size: .9rem; }
.or-sep { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 16px 0; font-size: .85rem; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.12); }
.sub-hint { color: var(--muted); font-size: .82rem; margin: 8px 0 0; }
.local-hint { text-align: center; color: var(--muted); font-size: .85rem; background: rgba(255,255,255,.05); border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; }

/* ---------- Game page ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,.07);
  position: sticky; top: 0; background: rgba(11,16,32,.85); backdrop-filter: blur(8px); z-index: 10;
}
.brand { color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: -.3px; }
.badge { background: rgba(255,255,255,.08); padding: 6px 12px; border-radius: 999px; font-size: .82rem; color: var(--muted); }

.game-wrap { max-width: 560px; margin: 0 auto; padding: 16px 14px 40px; }

.status {
  text-align: center; font-size: 1.25rem; font-weight: 800;
  padding: 14px; border-radius: 14px; margin-bottom: 14px;
  transition: background .25s, color .25s;
}
.status-neutral { background: rgba(255,255,255,.06); color: var(--muted); }
.status-your { background: rgba(34,197,94,.16); color: #86efac; box-shadow: 0 0 0 1px rgba(34,197,94,.3) inset; }
.status-wait { background: rgba(56,189,248,.12); color: var(--accent); }
.status-win { background: rgba(34,197,94,.22); color: #bbf7d0; }
.status-lose { background: rgba(239,68,68,.18); color: #fca5a5; }
.status-draw { background: rgba(250,204,21,.16); color: var(--yellow-glow); }

.players { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 14px; }
.pcard {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid rgba(255,255,255,.07);
  padding: 10px 12px; border-radius: 12px; min-width: 0;
}
.pcard.active { box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(56,189,248,.4); }
.pcard.p2 { flex-direction: row-reverse; text-align: right; }
.pname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.pstate { font-size: .72rem; color: var(--muted); }
.vs { color: var(--muted); font-weight: 800; font-size: .9rem; }

.invite-panel {
  background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.25);
  border-radius: 14px; padding: 16px; margin-bottom: 16px; text-align: center;
}
.invite-panel p { margin: 0 0 12px; color: var(--accent); font-weight: 600; }
.invite-row { display: flex; gap: 8px; }
.invite-row input { flex: 1; font-size: .85rem; }
.shareBtn { margin-top: 10px; }

/* ---------- Board ---------- */
.board-frame { display: flex; justify-content: center; }
.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(5px, 1.6vw, 10px);
  background: linear-gradient(160deg, var(--board), var(--board-dark));
  padding: clamp(8px, 2.4vw, 16px);
  border-radius: 18px;
  box-shadow: var(--shadow), inset 0 2px 8px rgba(255,255,255,.12);
  width: 100%; max-width: 460px;
  touch-action: manipulation;
}
.cell {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  background: var(--hole);
  border-radius: 50%;
  box-shadow: inset 0 4px 8px rgba(0,0,0,.6);
  cursor: pointer; overflow: hidden;
}
.cell.disabled { cursor: default; }
.board.playable .cell:hover::after {
  content: ""; position: absolute; inset: 14%;
  border-radius: 50%; background: rgba(255,255,255,.08);
}
.token {
  position: absolute; inset: 6%;
  border-radius: 50%;
  animation: drop .42s cubic-bezier(.34, 1.3, .64, 1);
  box-shadow: inset 0 -4px 8px rgba(0,0,0,.4), inset 0 4px 6px rgba(255,255,255,.3);
}
.token.p1 { background: radial-gradient(circle at 35% 30%, var(--red-glow), var(--red)); }
.token.p2 { background: radial-gradient(circle at 35% 30%, var(--yellow-glow), var(--yellow)); }
.cell.win .token { animation: pulse 0.9s ease-in-out infinite; box-shadow: 0 0 14px 3px rgba(255,255,255,.6); }

@keyframes drop {
  0% { transform: translateY(-560%); }
  70% { transform: translateY(0); }
  82% { transform: translateY(-9%); }
  100% { transform: translateY(0); }
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1e293b; color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.1); font-weight: 600;
  z-index: 50; max-width: 90vw; text-align: center;
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 380px) {
  .hero h1 { font-size: 1.9rem; }
  .status { font-size: 1.1rem; }
}
