:root {
    color-scheme: light;
    --bg-start: #f5efe4;
    --bg-end: #eadcc2;
    --panel: rgba(255, 255, 255, 0.9);
    --panel-strong: rgba(255, 255, 255, 0.98);
    --line: #d6c3a0;
    --text: #1e2732;
    --muted: #5e6873;
    --accent: #b45d2f;
    --accent-strong: #8f451d;
    --accent-alt: #295f79;
    --success: #2f7d4d;
    --shadow: 0 18px 46px rgba(22, 35, 47, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(180, 93, 47, 0.16), transparent 24%),
        radial-gradient(circle at bottom right, rgba(41, 95, 121, 0.16), transparent 26%),
        linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
}

a {
    color: var(--accent-strong);
}

.page {
    width: min(720px, calc(100% - 18px));
    margin: 0 auto;
    padding: 8px 0 14px;
}

.card {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(180px, 0.8fr);
    gap: 12px;
    padding: 12px 14px;
}

.simple-hero {
    grid-template-columns: 1fr;
}

.legal-hero {
    grid-template-columns: 1fr;
}

h1 {
    margin: 0;
    font-size: clamp(24px, 3.4vw, 34px);
    line-height: 1.02;
}

h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.lead,
.hero-meta p,
.legal-card p,
.legal-card li {
    color: var(--muted);
    line-height: 1.4;
}

.lead {
    margin: 6px 0 0;
    font-size: 14px;
}

.game-card,
.legal-card {
    margin-top: 10px;
    padding: 14px;
    background: linear-gradient(180deg, var(--panel-strong), rgba(247, 241, 230, 0.96));
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field label {
    font-size: 13px;
    color: var(--muted);
}

.control,
.button,
.cell {
    font: inherit;
}

.control,
.button {
    min-height: 38px;
    border-radius: 12px;
    border: 1px solid var(--line);
}

.control {
    min-width: 168px;
    padding: 0 12px;
    background: #fffdf8;
    color: var(--text);
}

.button-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(180, 93, 47, 0.2);
}

.button-secondary {
    background: #fffaf2;
    color: var(--accent-strong);
    box-shadow: none;
}

.button:hover,
.button:focus-visible,
.control:hover,
.control:focus-visible,
.cell:hover,
.cell:focus-visible {
    filter: brightness(1.02);
}

.status-panel {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
}

.status-panel h2 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-alt);
}

.status-text {
    margin: 0;
    font-size: 16px;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 12px auto 0;
    max-width: 300px;
}

.board.is-busy {
    pointer-events: none;
    opacity: 0.9;
}

.cell {
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, #fffdfa, #f6eedf);
    color: var(--accent-alt);
    font-size: clamp(28px, 5vw, 44px);
    font-weight: 700;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.cell:hover,
.cell:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(41, 95, 121, 0.45);
    box-shadow: 0 10px 20px rgba(41, 95, 121, 0.12);
}

.cell:disabled {
    cursor: default;
}

.cell.is-winning {
    color: var(--success);
    border-color: rgba(47, 125, 77, 0.45);
    background: linear-gradient(180deg, #f4fff7, #dff4e4);
}

.scoreboard {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.score-card {
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.8);
    text-align: center;
}

.score-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.score-card strong {
    font-size: 22px;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 2px 0;
    color: var(--muted);
    font-size: 13px;
}

.site-footer p {
    margin: 0;
}

.footer-links {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.admin-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 73, 83, 0.34);
    background: #004953;
    color: #fff8ef;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 6px 14px rgba(0, 73, 83, 0.18);
}

.admin-brand-link:hover,
.admin-brand-link:focus-visible {
    filter: brightness(1.05);
}

.admin-logo {
    display: block;
    width: auto;
    height: 22px;
    max-width: 110px;
    object-fit: contain;
    flex: 0 0 auto;
    filter:
        drop-shadow(0 0 1px rgba(0, 0, 0, 0.18))
        drop-shadow(0 1px 2px rgba(0, 0, 0, 0.22));
}

.admin-brand-link span {
    font-size: 12px;
    line-height: 1;
    color: inherit;
}

.cookie-notice {
    position: fixed;
    right: 10px;
    bottom: 10px;
    width: min(420px, calc(100% - 20px));
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 252, 246, 0.98);
    box-shadow: var(--shadow);
    z-index: 20;
}

.cookie-copy strong {
    display: block;
    margin-bottom: 6px;
}

.cookie-copy p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.cookie-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.legal-page {
    padding-bottom: 24px;
}

.legal-card h2:not(:first-child) {
    margin-top: 18px;
}

.legal-card ul {
    margin: 8px 0 0 18px;
    padding: 0;
}

@media (max-width: 640px) {
    .page {
        width: min(100% - 10px, 720px);
        padding-top: 4px;
        padding-bottom: 10px;
    }

    .hero,
    .game-card,
    .legal-card {
        padding: 10px;
    }

    .hero {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: clamp(22px, 7vw, 28px);
    }

    .lead {
        font-size: 13px;
        line-height: 1.32;
    }

    .toolbar {
        gap: 8px;
    }

    .field label {
        font-size: 12px;
    }

    .button-row,
    .footer-links,
    .cookie-actions {
        width: 100%;
    }

    .footer-links {
        gap: 8px;
    }

    .admin-brand-link {
        padding: 4px 8px;
    }

    .admin-logo {
        height: 18px;
        max-width: 90px;
    }

    .button-row .button,
    .cookie-actions .button,
    .cookie-actions a {
        flex: 1 1 140px;
    }

    .control,
    .button {
        width: 100%;
        min-height: 36px;
    }

    .status-panel {
        margin-top: 8px;
        padding: 8px 10px;
    }

    .status-panel h2 {
        font-size: 12px;
    }

    .status-text {
        font-size: 14px;
    }

    .board {
        gap: 5px;
        margin-top: 10px;
        max-width: 258px;
    }

    .cell {
        border-radius: 12px;
        font-size: clamp(24px, 7vw, 36px);
    }

    .scoreboard {
        gap: 6px;
        margin-top: 10px;
    }

    .score-card {
        padding: 7px 6px;
        border-radius: 12px;
    }

    .score-label {
        font-size: 10px;
    }

    .score-card strong {
        font-size: 20px;
    }

    .site-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
        font-size: 12px;
    }

    .cookie-notice {
        right: 6px;
        bottom: 6px;
        width: min(360px, calc(100% - 12px));
        padding: 10px;
        border-radius: 16px;
    }

    .cookie-copy p {
        font-size: 12px;
    }
}

@media (max-width: 420px) {
    .page {
        width: min(100% - 8px, 720px);
    }

    .hero,
    .game-card,
    .legal-card {
        padding: 9px;
    }

    .button-row .button,
    .cookie-actions .button,
    .cookie-actions a {
        flex: 1 1 100%;
    }

    .board {
        max-width: 240px;
    }

    .cell {
        font-size: 26px;
    }
}
