:root {
    color-scheme: dark;
    --bg: #101318;
    --panel: #181d24;
    --panel-2: #202832;
    --line: #334150;
    --text: #f5f7fb;
    --muted: #aeb8c7;
    --green: #63e6a3;
    --amber: #ffc857;
    --red: #ff6b6b;
    --cyan: #53d8fb;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 20% 15%, rgba(83, 216, 251, .18), transparent 28rem),
        linear-gradient(135deg, #101318 0%, #17181e 48%, #151d1b 100%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

.home-page {
    min-height: 100vh;
}

.home-shell {
    width: min(1120px, calc(100% - 36px));
    margin: 0 auto;
    padding: 38px 0;
}

.home-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 360px));
    gap: 18px;
}

.game-card {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--line);
    background: rgba(24, 29, 36, .92);
    box-shadow: 0 16px 50px rgba(0, 0, 0, .22);
}

.game-card-logo {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    background: #0b0f14;
}

.game-card-body {
    padding: 18px;
}

.game-card-body p:not(.eyebrow) {
    min-height: 66px;
    color: var(--muted);
    line-height: 1.5;
}

.play-link {
    display: inline-grid;
    place-items: center;
    min-height: 42px;
    padding: 0 16px;
    background: var(--green);
    color: #07100c;
    font-weight: 800;
    text-decoration: none;
}

.play-link:hover {
    filter: brightness(1.08);
}

.shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    min-height: 100vh;
    padding: 18px;
}

.game-panel,
.card {
    border: 1px solid var(--line);
    background: rgba(24, 29, 36, .92);
    box-shadow: 0 16px 50px rgba(0, 0, 0, .22);
}

.game-panel {
    display: grid;
    grid-template-rows: auto minmax(320px, 1fr);
    overflow: hidden;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.game-logo {
    width: 78px;
    height: 78px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #0b0f14;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--cyan);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(26px, 4vw, 46px);
    line-height: 1;
}

h2 {
    margin-bottom: 12px;
    font-size: 20px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 92px);
    gap: 10px;
}

.stats div {
    min-height: 58px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    background: var(--panel-2);
}

.stats span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.stats strong {
    display: block;
    margin-top: 3px;
    font-size: 24px;
    line-height: 1;
}

.stage-wrap {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
    padding: 14px;
}

canvas {
    display: block;
    width: min(100%, calc((100vh - 150px) * 1.777));
    max-height: calc(100vh - 150px);
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line);
    background: #0b0f14;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M24 3 37 43 24 36 11 43Z' fill='%2363e6a3' stroke='%23eafff4' stroke-width='2'/%3E%3Cpath d='M24 12 30 32 24 29 18 32Z' fill='%2353d8fb'/%3E%3Cpath d='M19 36 24 45 29 36Z' fill='%23ffc857'/%3E%3C/svg%3E") 24 24, none;
}

.overlay {
    position: absolute;
    inset: 14px;
    display: grid;
    place-items: center;
    background: rgba(8, 12, 17, .58);
}

.overlay[hidden] {
    display: none;
}

.start-box {
    width: min(92%, 430px);
    padding: 22px;
    border: 1px solid var(--line);
    background: rgba(24, 29, 36, .94);
}

.start-box p {
    color: var(--muted);
    line-height: 1.5;
}

button {
    min-height: 42px;
    border: 0;
    background: var(--green);
    color: #07100c;
    cursor: pointer;
    font-weight: 800;
}

button:hover {
    filter: brightness(1.08);
}

.side-panel {
    display: grid;
    align-content: start;
    gap: 18px;
}

.card {
    padding: 18px;
}

ol {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    padding: 9px 10px;
    background: var(--panel-2);
    border-left: 3px solid var(--cyan);
}

li.empty {
    display: block;
    color: var(--muted);
    border-left-color: var(--line);
}

.score-form label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.submit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 86px;
    gap: 8px;
}

input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    background: #111820;
    color: var(--text);
    padding: 0 10px;
}

#saveMessage {
    min-height: 20px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 920px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .brand-title {
        align-items: flex-start;
    }

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

    canvas {
        width: 100%;
        max-height: none;
    }
}

@media (max-width: 540px) {
    .shell {
        padding: 10px;
    }

    .stage-wrap {
        padding: 8px;
    }

    .overlay {
        inset: 8px;
    }

    .stats strong {
        font-size: 20px;
    }

    .game-logo {
        width: 58px;
        height: 58px;
    }
}
