:root {
    color-scheme: dark;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    --bg: #05060b;
    --surface: rgba(21, 23, 38, 0.84);
    --surface-strong: rgba(28, 30, 49, 0.94);
    --border: rgba(174, 164, 255, 0.18);

    --text: #f5f4fa;
    --muted: #a8a6b6;

    --purple: #a89cff;
    --purple-soft: #766aef;
    --lime: #adff39;

    --board-light: #928da3;
    --board-dark: #504b68;

    --danger: #ff8792;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);

    background:
        radial-gradient(
            circle at 11% 5%,
            rgba(61, 49, 138, 0.38),
            transparent 34rem
        ),
        radial-gradient(
            circle at 88% 8%,
            rgba(111, 24, 64, 0.26),
            transparent 34rem
        ),
        linear-gradient(
            180deg,
            #090a12 0%,
            #05060b 70%
        );
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;

    background:
        linear-gradient(
            115deg,
            rgba(73, 65, 164, 0.07),
            transparent 48%
        );
}

button,
input {
    font: inherit;
}

button {
    min-height: 42px;

    border:
        1px solid
        rgba(190, 186, 215, 0.18);

    border-radius: 999px;

    padding:
        9px
        17px;

    background:
        rgba(52, 52, 71, 0.78);

    color: var(--text);

    font-weight: 650;

    cursor: pointer;

    transition:
        transform 120ms ease,
        background 120ms ease,
        border-color 120ms ease,
        opacity 120ms ease;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);

    background:
        rgba(72, 69, 96, 0.92);

    border-color:
        rgba(190, 182, 255, 0.35);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.38;
    cursor: default;
}

.button-primary {
    background: #f6f5f8;
    color: #111218;
    border-color: #fff;
}

.button-primary:hover:not(:disabled) {
    background: #fff;
}

.button-danger:not(:disabled) {
    color: #ffd7da;

    border-color:
        rgba(255, 111, 124, 0.24);
}

.page {
    width:
        min(
            1220px,
            calc(100% - 34px)
        );

    margin: 0 auto;

    padding:
        54px
        0
        52px;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;

    gap: 28px;

    margin-bottom: 20px;

    padding:
        30px
        32px;

    border:
        1px solid
        var(--border);

    border-radius: 28px;

    background:
        linear-gradient(
            120deg,
            rgba(43, 43, 76, 0.83),
            rgba(30, 22, 38, 0.76)
        );

    box-shadow:
        0 24px 70px
        rgba(0, 0, 0, 0.24);

        blur(14px);
}

.hero-copy {
    min-width: 0;
}

.eyebrow,
.panel-label {
    color: var(--purple);

    font-size: 12px;
    font-weight: 850;

    letter-spacing: 0.17em;
}

h1 {
    margin:
        9px
        0
        7px;

    font-size:
        clamp(
            34px,
            5vw,
            58px
        );

    line-height: 0.98;

    letter-spacing: -0.045em;
}

h1 span {
    color: var(--text);
}

h2 {
    margin:
        4px
        0
        0;

    font-size: 19px;
}

.subtitle {
    max-width: 630px;

    margin: 0;

    color: var(--muted);

    font-size:
        clamp(
            14px,
            1.5vw,
            17px
        );

    line-height: 1.5;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;

    gap: 8px;
}

.message {
    min-height: 34px;

    display: flex;
    align-items: center;

    padding:
        0
        8px;

    color: #d8d6e2;

    font-size: 14px;
}

.message.error {
    color: #ff9ba4;
}

.message.success {
    color: #b9ff91;
}

.game-shell {
    position: relative;

    padding: 22px;

    border:
        1px solid
        rgba(169, 160, 255, 0.15);

    border-radius: 30px;

    background:
        rgba(5, 7, 14, 0.56);

    box-shadow:
        0 30px 90px
        rgba(0, 0, 0, 0.3);

        blur(14px);
}

.game-layout {
    display: grid;

    grid-template-columns:
        minmax(320px, 730px)
        minmax(250px, 1fr);

    gap: 22px;

    align-items: start;
}

.board-column {
    width: 100%;
}

.board-frame {
    padding: 8px;

    border:
        1px solid
        rgba(207, 201, 255, 0.16);

    border-radius: 22px;

    background:
        linear-gradient(
            145deg,
            rgba(39, 39, 62, 0.96),
            rgba(15, 16, 26, 0.96)
        );

    box-shadow:
        0 22px 60px
        rgba(0, 0, 0, 0.34);
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);

    width: 100%;
    aspect-ratio: 1;

    overflow: hidden;

    border-radius: 15px;

    user-select: none;
}

.square {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 0;

    border: 0;
    border-radius: 0;
    padding: 0;

    cursor: pointer;

    transition:
        filter 90ms ease,
        box-shadow 90ms ease;
}

.square:hover {
    transform: none;
    filter: brightness(1.09);
}

.square.light {
    background: var(--board-light);
}

.square.dark {
    background: var(--board-dark);
}

.piece-glyph {
    position: relative;
    z-index: 2;

    font-family:
        "Segoe UI Symbol",
        "Arial Unicode MS",
        sans-serif;

    font-size:
        clamp(
            31px,
            6vw,
            68px
        );

    line-height: 1;

    pointer-events: none;
}

.piece-glyph.white-piece {
    color: #fff;

    text-shadow:
        0 2px 2px
        rgba(0, 0, 0, 0.38);
}

.piece-glyph.black-piece {
    color: #17151e;

    text-shadow:
        0 1px 1px
        rgba(255, 255, 255, 0.22);
}

.square.selected {
    box-shadow:
        inset
        0
        0
        0
        5px
        var(--lime);
}

.square.last-move::after {
    content: "";

    position: absolute;
    inset: 0;

    z-index: 1;

    pointer-events: none;

    background:
        rgba(180, 255, 61, 0.17);
}

.square .coordinate {
    position: absolute;
    z-index: 3;

    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;

    font-size: 10px;
    font-weight: 850;

    opacity: 0.72;

    pointer-events: none;
}

.square.light .coordinate {
    color: #403b52;
}

.square.dark .coordinate {
    color: #cbc5df;
}

.square .file {
    right: 4px;
    bottom: 3px;
}

.square .rank {
    top: 3px;
    left: 4px;
}

.game-id-row {
    display: flex;
    align-items: center;

    gap: 9px;

    margin-top: 11px;
    padding: 0 5px;

    color: #767385;

    font-size: 11px;

    letter-spacing: 0.12em;
}

.game-id-row code {
    overflow-wrap: anywhere;

    color: #aaa6ba;

    font-size: 11px;
    letter-spacing: 0;
}

.sidebar {
    display: grid;
    gap: 15px;
}

.panel {
    border:
        1px solid
        rgba(187, 180, 255, 0.14);

    border-radius: 20px;

    padding: 20px;

    background:
        linear-gradient(
            145deg,
            rgba(31, 33, 50, 0.92),
            rgba(18, 19, 30, 0.92)
        );

    box-shadow:
        0 17px 50px
        rgba(0, 0, 0, 0.18);
}

.status-panel {
    min-height: 150px;
}

.status {
    margin-top: 13px;

    font-size:
        clamp(
            22px,
            2.3vw,
            30px
        );

    font-weight: 800;

    line-height: 1.08;

    letter-spacing: -0.025em;
}

.status.state-your-turn {
    color: #c9ff86;
}

.status.state-waiting {
    color: #c4bbff;
}

.status.state-finished {
    color: #f4f2f9;
}

.status-detail {
    margin-top: 9px;

    color: var(--muted);

    font-size: 14px;
    line-height: 1.5;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.move-count {
    display: grid;
    place-items: center;

    min-width: 34px;
    height: 34px;

    border:
        1px solid
        rgba(183, 174, 255, 0.15);

    border-radius: 999px;

    background:
        rgba(255, 255, 255, 0.04);

    color: #c3bfd1;

    font-size: 12px;
    font-weight: 800;
}

.moves {
    margin-top: 18px;

    display: grid;
    gap: 7px;

    color: #dedbe6;

    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;

    font-size: 14px;
}

.move-row {
    display: grid;

    grid-template-columns:
        36px
        minmax(64px, 1fr)
        minmax(64px, 1fr);

    gap: 8px;

    padding:
        7px
        8px;

    border-radius: 8px;
}

.move-row:nth-child(odd) {
    background:
        rgba(255, 255, 255, 0.025);
}

.move-number {
    color: #777386;
}

.info-panel p {
    margin:
        12px
        0
        0;

    color: #9996a8;

    font-size: 13px;
    line-height: 1.55;
}

footer {
    margin-top: 23px;

    padding-left: 7px;

    color: #666374;

    font-size: 12px;
}

@media (max-width: 900px) {
    .hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .actions {
        justify-content: flex-start;
    }

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

    .sidebar {
        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );
    }

    .info-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .page {
        width:
            min(
                100% - 20px,
                1220px
            );

        padding:
            28px
            0
            36px;
    }

    .hero {
        padding:
            24px
            20px;

        border-radius: 22px;
    }

    .actions {
        width: 100%;
    }

    .actions button {
        flex:
            1
            1
            calc(50% - 6px);
    }

    .game-shell {
        padding: 8px;

        border-radius: 20px;
    }

    .board-frame {
        padding: 5px;

        border-radius: 16px;
    }

    .board {
        border-radius: 11px;
    }

    .piece-glyph {
        font-size:
            clamp(
                29px,
                12vw,
                58px
            );
    }

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

    .info-panel {
        grid-column: auto;
    }

    .panel {
        border-radius: 16px;
    }

    .game-id-row code {
        font-size: 9px;
    }
}

/* My Games ------------------------------------------------------ */

.my-games {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.my-game {
    width: 100%;
    min-height: 0;

    display: block;

    border-radius: 12px;

    padding:
        11px
        12px;

    text-align: left;

    background:
        rgba(255, 255, 255, 0.035);

    border:
        1px solid
        rgba(190, 183, 255, 0.11);
}

.my-game:hover:not(:disabled) {
    transform: none;

    background:
        rgba(255, 255, 255, 0.065);

    border-color:
        rgba(190, 183, 255, 0.25);
}

.my-game.current {
    border-color:
        rgba(173, 255, 57, 0.45);

    box-shadow:
        inset 3px 0 0
        var(--lime);
}

.my-game-top {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 10px;
}

.my-game-state {
    font-size: 12px;
    font-weight: 850;

    letter-spacing: 0.08em;
}

.my-game-state.your-turn {
    color: #c9ff86;
}

.my-game-state.waiting {
    color: #c4bbff;
}

.my-game-state.finished {
    color: #aaa6b7;
}

.my-game-time {
    color: #777386;

    font-size: 11px;
    font-weight: 500;

    white-space: nowrap;
}

.my-game-detail {
    margin-top: 5px;

    color: #aaa6b7;

    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;

    font-size: 11px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.my-games-empty {
    color: #858192;

    font-size: 13px;
    line-height: 1.5;
}

/* Chess sidebar tablet layout ---------------------------------- */

@media (min-width: 601px) and (max-width: 900px) {
    .sidebar {
        grid-template-columns:
            minmax(0, 0.9fr)
            minmax(0, 1.1fr);

        align-items: start;
    }

    .status-panel {
        grid-column: 1;
        grid-row: 1;
    }

    .moves-panel {
        grid-column: 1;
        grid-row: 2;
    }

    .my-games-panel {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    .info-panel {
        grid-column: 1 / -1;
        grid-row: 3;
    }
}

.my-games {
    max-height: 390px;
    overflow-y: auto;
    padding-right: 3px;
}

.my-games::-webkit-scrollbar {
    width: 6px;
}

.my-games::-webkit-scrollbar-thumb {
    background:
        rgba(190, 183, 255, 0.22);

    border-radius: 999px;
}
