:root {
    --bg: #0f172a;
    --bg-soft: #111827;
    --card: rgba(15, 23, 42, 0.8);
    --panel: #111827;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --primary: #60a5fa;
    --primary-strong: #2563eb;
    --success: #22c55e;
    --warning: #fbbf24;
    --danger: #f87171;
    --border: rgba(148, 163, 184, 0.2);
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: linear-gradient(180deg, #111827 0%, #020817 100%);
    color: var(--text);
}
body[data-theme="light"] {
    --bg: #f8fafc;
    --bg-soft: #e2e8f0;
    --card: #ffffff;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: rgba(15, 23, 42, 0.12);
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}

a { color: inherit; text-decoration: none; }
.container { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; }
.topbar {
    position: sticky; top: 0; z-index: 10;
    backdrop-filter: blur(16px);
    background: rgba(15, 23, 42, 0.7);
    border-bottom: 1px solid var(--border);
}
body[data-theme="light"] .topbar { background: rgba(255,255,255,0.8); }
.nav-wrap { display: flex; align-items: center; justify-content: space-between; min-height: 68px; }
.brand { font-size: 1.2rem; font-weight: 800; letter-spacing: 0.04em; }
.nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.nav-link { color: var(--muted); font-size: 0.96rem; }
.nav-link.active, .nav-link:hover { color: var(--text); }
.theme-toggle { background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 999px; width: 42px; height: 42px; cursor: pointer; }
.page-shell { padding: 3rem 0 4rem; }
.hero {
    display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 1.5rem; align-items: center;
    margin-bottom: 2.5rem;
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; color: var(--primary); font-weight: 700; }
.hero h1, .page-title h1 { font-size: clamp(2rem, 4vw, 4rem); margin: 0.5rem 0 1rem; line-height: 1.1; }
.lead { color: var(--muted); font-size: 1.05rem; line-height: 1.7; max-width: 52ch; }
.hero-actions { display: flex; gap: 0.8rem; margin-top: 1.2rem; flex-wrap: wrap; }
.button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0.8rem 1.25rem; border-radius: 12px; border: 1px solid transparent; font-weight: 700; cursor: pointer; transition: 0.2s ease;
}
.button.primary { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: white; }
.button.secondary { background: transparent; border-color: var(--border); color: var(--text); }
.stat-panel, .game-grid, .stats-grid, .dashboard-grid { display: grid; gap: 1rem; }
.stat-panel { grid-template-columns: repeat(2, minmax(0,1fr)); }
.stat-box, .panel, .game-card, .metric { background: rgba(17,24,39,0.8); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
body[data-theme="light"] .stat-box, body[data-theme="light"] .panel, body[data-theme="light"] .game-card, body[data-theme="light"] .metric { background: var(--card); }
.stat-box { padding: 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.stat-box strong { font-size: 1.5rem; }
.stat-box span { color: var(--muted); }
.game-grid { grid-template-columns: repeat(2, minmax(0,1fr)); margin-top: 1.5rem; }
.game-card { padding: 1.5rem; }
.pill { display: inline-block; padding: 0.35rem 0.7rem; border-radius: 999px; background: rgba(96,165,250,0.15); color: #93c5fd; font-weight: 700; font-size: 0.75rem; }
.pill.alt { background: rgba(34,197,94,0.12); color: #86efac; }
.game-card h2 { margin: 1rem 0 0.5rem; }
.game-card p { color: var(--muted); line-height: 1.7; }
.page-title { margin-bottom: 1.25rem; }
.game-shell { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.6fr); gap: 1.25rem; }
.panel { padding: 1.4rem; }
.status-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.label { color: var(--muted); }
.board { display: grid; grid-template-columns: repeat(5, minmax(40px, 1fr)); gap: .55rem; margin: 1rem 0 1.5rem; }
.cell {
    width: 100%; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 800; text-transform: uppercase; background: transparent; transition: transform 0.15s ease, background 0.2s ease;
}
.cell.fill { border-color: rgba(96,165,250,0.5); }
.cell.correct { background: var(--success); border-color: var(--success); }
.cell.present { background: var(--warning); border-color: var(--warning); }
.cell.absent { background: rgba(148,163,184,0.25); border-color: rgba(148,163,184,0.2); }
.keyboard { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.key {
    padding: 0.7rem 0.7rem; border-radius: 10px; background: rgba(148,163,184,0.18); border: 1px solid var(--border); font-weight: 700; cursor: pointer; min-width: 2.3rem; text-transform: uppercase;
}
.key.correct { background: var(--success); }
.key.present { background: var(--warning); }
.key.absent { background: rgba(148,163,184,0.25); }
.guess-form { display: flex; gap: 0.8rem; margin-top: 1rem; }
.guess-form input, .setup-form input, .stack-form input, .stack-form textarea, .stack-form select {
    width: 100%; border-radius: 12px; border: 1px solid var(--border); background: rgba(15, 23, 42, 0.35); padding: 0.85rem 1rem; color: var(--text); font: inherit;
}
body[data-theme="light"] .guess-form input, body[data-theme="light"] .setup-form input, body[data-theme="light"] .stack-form input, body[data-theme="light"] .stack-form textarea, body[data-theme="light"] .stack-form select { background: #f8fafc; }
.guess-form input { max-width: 250px; }
.message { margin-top: 1rem; min-height: 1.5rem; color: var(--muted); }
.sidebar ul { margin: 0; padding-left: 1.1rem; color: var(--muted); line-height: 1.7; }
.text-panel { line-height: 1.8; color: var(--muted); }
.stats-grid { grid-template-columns: repeat(4, minmax(0,1fr)); margin-top: 1rem; }
.stat-card { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.3rem; }
.not-found { text-align: center; }
.footer { border-top: 1px solid var(--border); padding: 1.1rem 0 2rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: var(--muted); }
.footer-inner > div { display: flex; gap: 1rem; }
.admin-body { background: #020817; }
.admin-shell { display: grid; grid-template-columns: 220px minmax(0,1fr); min-height: 100vh; }
.admin-sidebar { background: rgba(15,23,42,0.9); border-right: 1px solid var(--border); padding: 2rem 1rem; }
.admin-sidebar h2 { margin-top: 0; }
.admin-sidebar nav { display: flex; flex-direction: column; gap: 0.8rem; }
.admin-sidebar a, .admin-sidebar button { background: transparent; color: var(--text); border: 0; text-align: left; padding: 0.7rem 0.8rem; border-radius: 10px; cursor: pointer; }
.admin-sidebar a:hover, .admin-sidebar button:hover { background: rgba(148,163,184,0.1); }
.admin-main { padding: 2rem; }
.login-panel { max-width: 440px; margin: 2rem auto; }
.stack-form { display: flex; flex-direction: column; gap: 1rem; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.success-box, .error-box { border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.success-box { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); }
.error-box { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.25); }
.table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.table th, .table td { padding: 0.7rem; border-bottom: 1px solid var(--border); text-align: left; }
.metric { padding: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }
.metric span { color: var(--muted); }
.metric strong { font-size: 2rem; }
@media (max-width: 860px) {
    .hero, .game-shell, .grid-two, .stats-grid, .game-grid, .admin-shell { grid-template-columns: 1fr; }
    .nav { display: none; }
    .guess-form { flex-direction: column; }
    .guess-form input { max-width: none; }
    .topbar { position: static; }
    .admin-main { padding: 1rem; }
}
