:root {
    --bg-top: #fff8e7;
    --bg-bottom: #f0c48c;
    --panel: rgba(22, 27, 36, 0.88);
    --panel-border: rgba(255, 255, 255, 0.18);
    --text-main: #fff9ef;
    --text-muted: #ffe0b4;
    --accent: #ff8f3f;
    --shadow: rgba(55, 25, 4, 0.28);
    --field: rgba(255, 248, 239, 0.1);
    --field-border: rgba(255, 248, 239, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Space Grotesk", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 30%),
        radial-gradient(circle at bottom right, rgba(255, 141, 73, 0.35), transparent 28%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    color: var(--text-main);
}

.page-shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    gap: 24px;
    align-items: center;
    padding: 32px 0;
}

.game-copy,
.game-frame {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    box-shadow: 0 24px 60px var(--shadow);
    backdrop-filter: blur(10px);
}

.game-copy {
    padding: 28px;
    display: grid;
    gap: 18px;
}

.eyebrow {
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.78rem;
    color: var(--text-muted);
}

h1 {
    margin: 0;
    font-size: clamp(2.4rem, 5vw, 4rem);
    line-height: 0.95;
}

.description {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.info-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 18px;
}

.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.card-head h2,
.controls-card h2 {
    margin: 0;
    font-size: 1.05rem;
}

.card-head p,
.controls-card p,
.helper-text {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.join-form {
    display: grid;
    gap: 10px;
}

.input-label {
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.join-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.join-row input {
    min-width: 0;
    border: 1px solid var(--field-border);
    background: var(--field);
    border-radius: 14px;
    color: var(--text-main);
    padding: 14px 16px;
    font: inherit;
}

.join-row input::placeholder {
    color: rgba(255, 224, 180, 0.72);
}

.join-row button {
    border: 0;
    border-radius: 14px;
    padding: 0 18px;
    font: inherit;
    font-weight: 700;
    color: #2b1c10;
    background: linear-gradient(180deg, #ffd37e, #ff9b54);
    cursor: pointer;
}

.join-row button:disabled,
.join-row input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-entry.is-local {
    background: rgba(255, 211, 126, 0.12);
    border: 1px solid rgba(255, 211, 126, 0.22);
}

.leaderboard-rank {
    font-weight: 700;
    color: var(--text-muted);
}

.leaderboard-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-score {
    font-weight: 700;
}

.game-frame {
    padding: 18px;
}

#game {
    width: 100%;
    border-radius: 20px;
    overflow: hidden;
}

#game canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 20px;
}

@media (max-width: 900px) {
    .page-shell {
        grid-template-columns: 1fr;
        padding: 20px 0 24px;
    }

    .game-copy {
        order: 2;
    }

    .game-frame {
        order: 1;
    }

    .join-row {
        grid-template-columns: 1fr;
    }
}