:root {
    --bg: #f6f7fb;
    --card: #ffffff;
    --accent: #2563eb;
    --accent-2: #0ea5e9;
    --text: #0f172a;
    --muted: #6b7280;
    --danger: #b91c1c;
    --success: #15803d;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
}

.theme-dark {
    --bg: #0f172a;
    --card: #111827;
    --accent: #22d3ee;
    --accent-2: #a855f7;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --danger: #fca5a5;
    --success: #22c55e;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body.page {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #fdfdfd 0%, #eef2f7 100%);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}
.theme-dark.page {
    background: radial-gradient(120% 120% at 20% 20%, rgba(34, 211, 238, 0.12), transparent),
                radial-gradient(90% 90% at 80% 0%, rgba(168, 85, 247, 0.18), transparent),
                var(--bg);
}
@media (max-width: 900px) {
    body.page {
        padding: 12px;
    }
}

.card {
    background: var(--card);
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.theme-dark .card {
    border-color: #1f2937;
}

.landing {
    max-width: 960px;
    width: 100%;
}

.brand {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.brand span { color: var(--accent); }

.subtitle {
    margin: 6px 0 20px;
    color: var(--muted);
    line-height: 1.5;
}

.forms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    align-items: start;
}

.form-block h3 { margin: 0 0 8px; }
.form-block label { display: block; color: var(--muted); margin-top: 10px; font-size: 14px; }
.form-block input {
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: var(--text);
}
.form-block select {
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: var(--text);
}
.form-block button {
    margin-top: 14px;
    width: 100%;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 700;
    color: #ffffff;
    transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.1s ease;
}
button:active { transform: translateY(1px); }
.primary {
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.25);
}
.secondary {
    background: linear-gradient(135deg, var(--accent-2), #38bdf8);
    box-shadow: 0 10px 30px rgba(14, 165, 233, 0.25);
}
.small { padding: 10px 12px; font-size: 13px; }

.divider {
    text-align: center;
    color: var(--muted);
    font-weight: 700;
}

.message {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #eef2ff;
    color: #4338ca;
}
.theme-dark .message { background: rgba(255,255,255,0.08); color: #c7d2fe; }
.message.error { color: #991b1b; background: #fee2e2; }
.theme-dark .message.error { color: #fecdd3; background: rgba(239,68,68,0.12); }
.message.success { color: #166534; background: #dcfce7; }
.theme-dark .message.success { color: #bbf7d0; background: rgba(34,197,94,0.12); }
.message.info { background: #e0f2fe; color: #075985; }
.theme-dark .message.info { background: rgba(14,165,233,0.1); color: #7dd3fc; }

.game-shell { width: 1100px; max-width: 100%; }
.game-shell.mobile {
    width: 100%;
}
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.game-header .brand { font-size: 26px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.header-actions button { width: auto; }
@media (max-width: 900px) {
    .game-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .room-code { width: 100%; box-sizing: border-box; text-align: left; }
}
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.room-code {
    background: #eef2f7;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    border: 1px solid #d1d5db;
}
.theme-dark .room-code {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.08);
}

.game-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}
@media (max-width: 900px) {
    .game-grid { grid-template-columns: 1fr; }
    .board-card, .info-card { padding: 16px; }
}

.board-card { padding: 22px; position: relative; }
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.label { color: var(--muted); font-size: 13px; }
.value { font-size: 20px; font-weight: 800; }

.board-wrapper { position: relative; }

.winner-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 800;
    color: #0f172a;
    border-radius: 10px;
    z-index: 2;
}
.winner-overlay.hidden { display: none; }
.theme-dark .winner-overlay { background: rgba(0,0,0,0.7); color: #e5e7eb; }
.wait-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    background: rgba(255,255,255,0.85);
    color: #0f172a;
    z-index: 3;
    text-align: center;
}
.wait-overlay.hidden { display: none; }
.theme-dark .wait-overlay { background: rgba(0,0,0,0.75); color: #e5e7eb; }
.board-wrapper.waiting .wait-overlay { display: flex; }
.number-pad.waiting button {
    pointer-events: none;
    opacity: 0.3;
}
.board-wrapper.waiting {
    position: relative;
}
.board-wrapper.waiting .sudoku-board {
    filter: blur(8px);
    opacity: 0.15;
    pointer-events: none;
}
.board-wrapper.waiting::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.78);
    z-index: 2;
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    border: 3px solid #000;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
@media (max-width: 700px) {
    .sudoku-board {
        width: 100%;
    }
    .cell { font-size: 16px; }
}
.theme-dark .sudoku-board { background: #0b1220; border-color: #e5e7eb; }
.cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    background: #fff;
    border: 1px solid #d1d5db;
    transition: background 0.15s ease, color 0.15s ease;
    color: #111827;
    position: relative;
}
.theme-dark .cell { border-color: #1f2937; background: #0f172a; color: #e5e7eb; }
.cell.prefilled {
    background: #f3f4f6;
    color: #6b7280;
}
.theme-dark .cell.prefilled { background: #1f2937; color: #cbd5e1; }
.cell .note {
    position: absolute;
    inset: 4px;
    font-size: 11px;
    color: #64748b;
    line-height: 1.1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    place-items: center;
    pointer-events: none;
}
.theme-dark .cell .note { color: #94a3b8; }
.cell.selectable:hover { background: #e0f2fe; }
.cell.selected { background: #dbeafe; border-color: #3b82f6; }
.theme-dark .cell.selectable:hover { background: rgba(34,211,238,0.16); }
.theme-dark .cell.selected { background: rgba(37,99,235,0.25); border-color: #22d3ee; }

.cell.block-border-bottom { border-bottom: 2px solid #000; }
.cell.block-border-right { border-right: 2px solid #000; }
.cell.block-border-top { border-top: 2px solid #000; }
.cell.block-border-left { border-left: 2px solid #000; }

.number-pad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    margin: 14px 0 8px;
}
.number-pad button { min-height: 44px; }
@media (max-width: 700px) {
    .number-pad {
        grid-template-columns: repeat(5, 1fr);
    }
}
.number-pad button {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #d1d5db;
}
.number-pad button:hover { background: #dbeafe; color: #0f172a; }
.number-pad button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #e5e7eb;
    color: #6b7280;
}
.number-pad button.hidden-number { display: none !important; }
.theme-dark .number-pad button { background: #111827; color: #e5e7eb; border-color: #1f2937; }
.theme-dark .number-pad button:hover { background: #1f2937; color: #e5e7eb; }
.theme-dark .number-pad button:disabled { background: #1f2937; color: #6b7280; }
.theme-dark .number-pad button { background: #111827; color: #e5e7eb; border-color: #1f2937; }
.theme-dark .number-pad button:hover { background: #1f2937; color: #e5e7eb; }

.info-card h3 { margin: 0 0 12px; }
.player-box {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
}
.theme-dark .player-box { background: #0f172a; border-color: #1f2937; }
.player-box .name { font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.player-box .stat { color: var(--muted); font-size: 14px; }
.player-box.current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15); }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.4; }

.winner { color: var(--success); font-weight: 800; }
.loser { color: var(--muted); }
