:root {
  color-scheme: dark;
  --bg: #10141d;
  --panel: #191f2b;
  --panel-soft: #1e2634;
  --line: #2a3445;
  --text: #f1f5fb;
  --muted: #9aa8bb;
  --accent: #84e2b2;
  --accent-strong: #38c886;
  --danger: #ff8291;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 15% 0, #1a2832 0, transparent 38rem), var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
.topbar { height: 68px; padding: 0 max(22px, calc((100% - 1180px)/2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #ffffff0d; background: #10141dcc; }
.brand { color: var(--text); font-size: 1.35rem; font-weight: 850; letter-spacing: -.06em; text-decoration: none; }
.brand span { color: var(--accent); }
.account { display: flex; align-items: center; gap: 12px; }
main { max-width: 1180px; margin: auto; padding: 34px 22px 18px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 8px 0 30px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.05; letter-spacing: -.055em; }
h2 { margin-bottom: 3px; font-size: 1.35rem; letter-spacing: -.025em; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 8px; color: var(--accent); font-size: .7rem; font-weight: 800; letter-spacing: .14em; }
.status-card { display: flex; align-items: center; gap: 11px; min-width: 165px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.status-card strong, .status-card small { display: block; }
.status-card small { color: var(--muted); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 0 5px #38c8861b; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, #1b2230, #171d28); }
.auth-panel { display: grid; grid-template-columns: minmax(210px, .7fr) 1.3fr; align-items: center; gap: 24px; margin-bottom: 28px; }
.auth-copy p:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 6px; color: #c3ccda; font-size: .82rem; font-weight: 650; }
input { width: 100%; min-width: 0; padding: 11px 12px; color: var(--text); border: 1px solid #364153; border-radius: 10px; background: #111722; outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #84e2b21b; }
.button-row, .game-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 13px; }
.button { min-height: 39px; padding: 8px 13px; color: var(--text); border: 1px solid #3b4658; border-radius: 10px; background: #252e3d; font-weight: 700; }
.button:hover { border-color: #68778c; background: #2c3748; }
.button.primary { color: #0e2218; border-color: var(--accent); background: var(--accent); }
.button.primary:hover { background: #a5edc7; }
.button.subtle { background: transparent; }
.message { min-height: 1.3em; margin: 9px 0 0; color: var(--danger); font-size: .85rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.main-column { display: grid; gap: 26px; min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title .eyebrow { margin-bottom: 2px; }
.game-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 13px; }
.game-card { display: flex; flex-direction: column; min-height: 160px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.game-card.coming-soon { border-style: dashed; opacity: .76; }
.game-icon { display: grid; place-items: center; width: 43px; height: 43px; margin-bottom: 14px; border-radius: 13px; color: var(--accent); background: #84e2b215; font-size: 1.5rem; }
.game-card h3 { margin-bottom: 5px; font-size: 1.1rem; }
.game-card p { margin-bottom: 15px; color: var(--muted); font-size: .9rem; }
.game-card .button { margin-top: auto; }
.active-games { display: grid; gap: 9px; }
.active-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.active-item small { display: block; color: var(--muted); }
.empty-state { color: var(--muted); font-size: .9rem; }
.lobby-panel { position: sticky; top: 16px; }
.online-list { padding: 13px 0; margin-bottom: 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.online-list h3 { display: flex; justify-content: space-between; margin: 0 0 8px; }
.online-list h3 span { color: var(--accent); }
#online-users { display: flex; flex-wrap: wrap; gap: 6px; }
.online-user { padding: 3px 8px; color: #c5d0df; border-radius: 99px; background: #252e3c; font-size: .76rem; }
.chat-messages { display: flex; flex-direction: column; gap: 8px; min-height: 80px; max-height: 315px; overflow-y: auto; padding: 6px 1px 12px; }
.lobby-messages { min-height: 260px; max-height: 440px; }
.chat-entry { position: relative; padding: 8px 10px; border-radius: 10px; background: #222b38; overflow-wrap: anywhere; }
.chat-entry strong { display: block; margin-bottom: 2px; color: var(--accent); font-size: .78rem; }
.chat-entry span { font-size: .9rem; white-space: pre-wrap; }
.chat-delete { float: right; padding: 0 5px; color: var(--danger); border: 0; background: none; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }
.game-panel { padding: 22px; }
.game-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.turn-label { margin: 14px 0; color: var(--muted); }
.board { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; width: min(100%, 520px); margin: auto; padding: 5px; border: 1px solid #3d705d; border-radius: 11px; background: #16543f; aspect-ratio: 1; }
.cell { position: relative; display: grid; place-items: center; padding: 0; border: 0; border-radius: 3px; background: #21835e; }
.cell:hover { background: #2b986d; }
.cell.last-move { box-shadow: inset 0 0 0 3px #ffd166; }
.cell.legal::after { width: 18%; height: 18%; border-radius: 50%; background: #ffffff55; content: ""; }
.disc { width: 77%; height: 77%; border-radius: 50%; box-shadow: inset 0 2px 3px #ffffff38, 0 2px 4px #0008; }
.disc.black { background: #111820; }
.disc.white { background: #f3f5e9; }
.score { display: flex; justify-content: center; gap: 20px; margin: 13px; color: var(--muted); }
.score strong { color: var(--text); }
.game-chat { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.game-chat h3 { margin-bottom: 8px; }
.stats-panel, .admin-panel { margin-top: 26px; }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat { min-width: 85px; color: var(--muted); }
.stat strong { display: block; color: var(--text); font-size: 1.3rem; }
.admin-user { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.admin-user small { color: var(--muted); }
.admin-user select { padding: 6px; color: var(--text); background: #111722; border: 1px solid var(--line); border-radius: 7px; }
.admin-form { display: flex; align-items: end; gap: 10px; margin-top: 15px; }
.admin-form label { flex: 1; }
footer { display: flex; justify-content: space-between; gap: 10px; padding: 30px 2px 5px; color: #738197; font-size: .77rem; }
.hidden { display: none !important; }

@media (max-width: 850px) {
  main { padding: 24px 16px; }
  .layout { grid-template-columns: 1fr; }
  .lobby-panel { position: static; }
  .lobby-messages { min-height: 150px; max-height: 260px; }
}
@media (max-width: 580px) {
  .topbar { height: 58px; padding: 0 15px; }
  main { padding: 21px 13px; }
  .hero { display: block; margin-bottom: 21px; }
  .status-card { margin-top: 18px; }
  .panel { padding: 15px; border-radius: 15px; }
  .auth-panel { grid-template-columns: 1fr; gap: 15px; }
  .field-row { grid-template-columns: 1fr; }
  .button-row .button { flex: 1 1 42%; }
  .game-cards { grid-template-columns: 1fr; }
  .game-card { min-height: auto; }
  .game-heading { align-items: start; }
  .game-heading .button { min-height: 34px; padding: 6px 8px; font-size: .82rem; }
  .admin-form { align-items: stretch; flex-wrap: wrap; }
  .admin-form label { min-width: 100px; }
  footer { flex-direction: column; padding-top: 22px; }
}
