:root {
    color-scheme: dark;
    --ink: #efede5;
    --muted: #9d9b93;
    --paper: #0e100f;
    --surface: #181b18;
    --raised: #242822;
    --line: rgba(239, 237, 229, 0.13);
    --acid: #ccec67;
    --wood: #9b7047;
    --wood-dark: #5c3e26;
    --cell: clamp(18px, 5.6vw, 30px);
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 5%, rgba(204, 236, 103, 0.1), transparent 25rem),
        var(--paper);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.game-page {
    width: min(100% - 2rem, 76rem);
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.game-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    margin-bottom: 2rem;
}

.back-link {
    width: fit-content;
    padding: 0.65rem 0;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
}

.game-header > div {
    text-align: center;
}

.eyebrow {
    margin: 0 0 0.25rem;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.8rem, 6vw, 4.5rem);
    font-weight: 400;
    letter-spacing: -0.07em;
    line-height: 0.9;
}

.connection-status {
    justify-self: end;
    padding: 0.65rem 0;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.connection-status span {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    margin-right: 0.35rem;
    border-radius: 50%;
    background: #8bc45a;
    box-shadow: 0 0 0 4px rgba(139, 196, 90, 0.12);
}

.game-shell {
    display: grid;
    min-height: min(42rem, calc(100vh - 10rem));
    grid-template-columns: minmax(16rem, 0.75fr) minmax(30rem, 1.4fr);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    background: rgba(22, 25, 22, 0.78);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.game-sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(2rem, 5vw, 4rem);
    border-right: 1px solid var(--line);
}

.section-number {
    margin: 0 0 0.6rem;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2.6rem;
    font-weight: 400;
    letter-spacing: -0.06em;
}

.supporting-copy {
    margin: 0.8rem 0 1.6rem;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

button,
input {
    border: 1px solid var(--line);
    border-radius: 0.75rem;
}

button {
    padding: 0.8rem 1rem;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    transition: transform 140ms ease, background 140ms ease;
}

button:hover:not(:disabled),
button:focus-visible {
    background: var(--raised);
    outline: none;
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.primary-button {
    width: 100%;
    border-color: var(--acid);
    background: var(--acid);
    color: #151711;
}

.primary-button:hover:not(:disabled),
.primary-button:focus-visible {
    background: #dcf58a;
}

.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    color: var(--muted);
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.divider::before,
.divider::after {
    height: 1px;
    flex: 1;
    background: var(--line);
    content: "";
}

label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.7rem;
    font-weight: 700;
}

.join-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
}

input {
    min-width: 0;
    padding: 0.8rem 1rem;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.95rem;
    letter-spacing: 0.14em;
}

input:focus {
    border-color: var(--ink);
    outline: none;
}

.game-code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.72rem;
}

.game-code-row strong {
    color: var(--ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.65rem;
    font-weight: 400;
    letter-spacing: 0.12em;
}

.game-facts {
    margin: 0;
}

.game-facts div {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.78rem;
}

.game-facts dt {
    color: var(--muted);
}

.game-facts dd {
    margin: 0;
    font-weight: 700;
}

.game-status {
    min-height: 2.5rem;
    margin: 1.25rem 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1rem;
    font-style: italic;
    line-height: 1.5;
}

.sidebar-actions {
    display: flex;
    gap: 0.5rem;
}

.text-button {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}

.message-area {
    min-height: 3.4rem;
    margin: auto 0 0;
    padding-top: 2rem;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.5;
}

.board-panel,
.board-placeholder {
    display: grid;
    min-width: 0;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(circle at 80% 15%, rgba(204, 236, 103, 0.08), transparent 17rem),
        #121512;
}

.board {
    display: grid;
    grid-template-columns: repeat(15, var(--cell));
    grid-template-rows: repeat(15, var(--cell));
    padding: calc(var(--cell) / 2);
    border: 1px solid var(--wood-dark);
    border-radius: 0.35rem;
    background: var(--wood);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.42);
}

.cell {
    position: relative;
    width: var(--cell);
    height: var(--cell);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.cell::before,
.cell::after {
    position: absolute;
    z-index: 0;
    background: rgba(48, 30, 15, 0.78);
    content: "";
}

.cell::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
}

.cell::after {
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
}

.cell:hover:not(:disabled),
.cell:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transform: none;
}

.cell.star-point:not(.has-black):not(.has-white) {
    background: radial-gradient(circle, #372614 0 2.5px, transparent 3px);
}

.cell.has-black::before,
.cell.has-white::before {
    z-index: 2;
    top: 7%;
    left: 7%;
    width: 86%;
    height: 86%;
    border-radius: 50%;
    box-shadow: 0 3px 7px rgba(35, 22, 11, 0.35);
}

.cell.has-black::before {
    background: radial-gradient(circle at 35% 28%, #555, #121212 56%);
}

.cell.has-white::before {
    background: radial-gradient(circle at 35% 28%, #fff, #dfddd7 62%);
}

.cell.last-move::after {
    z-index: 3;
    top: 43%;
    left: 43%;
    width: 14%;
    height: 14%;
    border-radius: 50%;
    background: #ff7d68;
}

.board-placeholder {
    color: var(--muted);
    text-align: center;
}

.stone-composition {
    position: relative;
    width: 9rem;
    height: 6rem;
    margin: 0 auto 1rem;
}

.stone-composition span {
    position: absolute;
    width: 5.5rem;
    height: 5.5rem;
    border-radius: 50%;
}

.black-stone {
    top: 0;
    left: 0.3rem;
    background: radial-gradient(circle at 35% 28%, #555, #121212 58%);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.34);
}

.white-stone {
    right: 0.3rem;
    bottom: 0;
    border: 1px solid var(--line);
    background: radial-gradient(circle at 35% 28%, #fff, #dfddd7 62%);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.24);
}

.board-placeholder p {
    font-family: Georgia, "Times New Roman", serif;
    font-style: italic;
}

.hidden {
    display: none !important;
}

@media (max-width: 850px) {
    .game-page {
        width: min(100% - 1rem, 44rem);
        padding-top: 1rem;
    }

    .game-header {
        margin-bottom: 1.2rem;
        padding: 0 0.5rem;
    }

    .game-shell {
        grid-template-columns: 1fr;
    }

    .game-sidebar {
        min-height: 26rem;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .board-panel,
    .board-placeholder {
        min-height: 34rem;
        padding: 1rem;
    }
}

@media (max-width: 500px) {
    .game-header {
        grid-template-columns: 1fr auto;
    }

    .game-header > div {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .back-link,
    .connection-status {
        z-index: 1;
        grid-row: 1;
    }

    .connection-status {
        grid-column: 2;
    }

    .game-sidebar {
        min-height: 25rem;
        padding: 2rem 1.5rem;
    }

    .board-panel,
    .board-placeholder {
        min-height: 26rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
    }
}
