:root {
    --bg: #fff8ea;
    --surface: #fffdf8;
    --surface-strong: #ffffff;
    --ink: #252428;
    --muted: #62606a;
    --line: #ded2bd;
    --accent: #dc524c;
    --accent-dark: #a93634;
    --gold: #f4bd3d;
    --teal: #287c7c;
    --shadow: 0 18px 45px rgba(65, 48, 31, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    background:
        linear-gradient(135deg, rgba(255, 248, 234, 0.96), rgba(239, 249, 250, 0.9)),
        var(--bg);
}

.app-shell {
    width: min(1000px, 100%);
    display: grid;
    gap: 22px;
}

.game-header {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 42px;
    line-height: 1.05;
}

.tagline {
    max-width: 560px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.5;
}

.score-strip {
    display: grid;
    gap: 10px;
}

.score-pill {
    min-width: 108px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--gold);
    border-radius: 8px;
    background: var(--surface-strong);
}

.score-pill.loss {
    border-left-color: var(--accent);
}

.score-pill.trap {
    border-left-color: var(--teal);
}

.score-pill strong,
.score-pill span {
    display: block;
}

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

.score-pill span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.play-column {
    display: grid;
    gap: 16px;
    justify-items: center;
}

.board-panel,
.side-panel section,
.below-game-grid section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.board-panel {
    display: flex;
    width: min(100%, 638px);
    aspect-ratio: 1;
    place-self: start center;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

#drawSurface {
    display: block;
    width: 100%;
    max-width: 600px;
    height: auto;
    aspect-ratio: 1;
    border: 1px solid #d2c5a6;
    border-radius: 8px;
    background: #f5eed6;
}

.side-panel {
    display: grid;
    gap: 16px;
}

.side-panel section,
.below-game-grid section {
    padding: 18px;
}

.below-game-grid {
    width: min(100%, 638px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-weight: 700;
}

.section-heading span:last-child {
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.status-grid {
    display: grid;
    gap: 10px;
}

.status-box {
    min-height: 62px;
    padding: 12px;
    border: 1px solid #eadfca;
    border-radius: 8px;
    background: var(--surface-strong);
}

.status-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.how-to-list {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.how-to-list li + li {
    margin-top: 8px;
}

.how-to-list strong {
    color: var(--ink);
}

#keyPressed,
#eatenCalculator,
#wallState,
#godModeState {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}

.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

button {
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid #c8baa0;
    border-radius: 8px;
    color: var(--ink);
    background: #fff8e8;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(65, 48, 31, 0.12);
}

button:focus-visible {
    outline: 3px solid rgba(40, 124, 124, 0.36);
    outline-offset: 2px;
}

.primary-action {
    grid-column: 1 / -1;
    color: #fff;
    border-color: var(--accent-dark);
    background: var(--accent);
}

.secondary-action {
    background: #f0fbfb;
}

@media (max-width: 920px) {
    body {
        align-items: flex-start;
        padding: 22px;
    }

    .game-header {
        display: grid;
    }

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

@media (max-width: 560px) {
    body {
        padding: 14px;
    }

    h1 {
        font-size: 34px;
    }

    .tagline {
        font-size: 15px;
    }

    .board-panel,
    .side-panel section,
    .below-game-grid section {
        padding: 12px;
    }

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

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

    .primary-action {
        grid-column: auto;
    }
}
