:root {
    --bg: #f4f5ef;
    --panel: #fffdf7;
    --ink: #17211d;
    --muted: #637169;
    --line: #d8d0bc;
    --track: #31483f;
    --primary: #257463;
    --primary-dark: #17493d;
    --yellow: #e4b13b;
    --coral: #df674d;
    --blue: #4a87a5;
    --soft: #eef5ec;
    --shadow: 0 22px 58px rgba(23, 33, 29, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    background:
        linear-gradient(120deg, rgba(37, 116, 99, 0.12), transparent 44%),
        linear-gradient(180deg, #fffdf7 0%, var(--bg) 100%);
}

button {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 4px 0 var(--primary-dark);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

button:hover,
button:focus-visible {
    background: #2f8b77;
    outline: 3px solid rgba(37, 116, 99, 0.22);
    outline-offset: 2px;
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--primary-dark);
}

h1,
h2,
p {
    margin: 0;
}

.arcade-shell {
    width: min(1500px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 24px;
}

.topbar,
.stage-panel,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 247, 0.96);
    box-shadow: var(--shadow);
}

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(420px, 0.9fr);
    gap: 14px;
    align-items: center;
    padding: 14px;
}

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

.brand-mark {
    display: grid;
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 8px;
    color: #2c2109;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.35), transparent),
        var(--yellow);
    box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12);
    font-size: 22px;
    font-weight: 900;
}

.brand p {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.brand h1 {
    margin-top: 3px;
    font-size: clamp(32px, 5vw, 58px);
    line-height: 0.95;
}

.score-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.score-strip article {
    display: grid;
    gap: 3px;
    min-height: 66px;
    place-items: center;
    border: 1px solid #e5d9bd;
    border-radius: 8px;
    background: #fbf5e7;
}

.score-strip span,
.meter span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.score-strip strong {
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(20px, 2.5vw, 30px);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 14px;
    margin-top: 14px;
}

.stage-panel {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: 12px;
    background:
        linear-gradient(180deg, #f8f5e9, #e9efe9);
}

canvas {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid #b8c7bd;
    border-radius: 8px;
    background: var(--track);
    touch-action: none;
}

.overlay {
    position: absolute;
    inset: 12px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(244, 245, 239, 0.72);
    backdrop-filter: blur(3px);
}

.overlay-box {
    display: grid;
    gap: 13px;
    width: min(520px, calc(100% - 28px));
    border: 1px solid #d8c99d;
    border-radius: 8px;
    padding: clamp(18px, 3vw, 32px);
    background: #fffdf7;
    box-shadow: var(--shadow);
    text-align: center;
}

.overlay-box h2 {
    font-size: clamp(30px, 5vw, 48px);
    line-height: 1;
}

.overlay-box p,
.panel p {
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.42;
}

.mode-pill {
    justify-self: center;
    border: 1px solid #d9bf72;
    border-radius: 999px;
    padding: 8px 12px;
    color: #5e4510;
    background: #fff1c9;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.is-hidden {
    display: none !important;
}

.side-panel {
    display: grid;
    align-content: start;
    gap: 14px;
    min-width: 0;
}

.panel {
    padding: 14px;
}

.panel h2 {
    margin-bottom: 12px;
    font-size: 18px;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.control-grid span {
    display: grid;
    min-height: 42px;
    place-items: center;
    border: 1px solid #d8d0bc;
    border-radius: 8px;
    background: #f7f1df;
    font-weight: 900;
}

.meter {
    display: grid;
    gap: 7px;
}

.meter strong {
    justify-self: end;
    margin-top: -23px;
    font-size: 13px;
}

.meter div {
    height: 13px;
    overflow: hidden;
    border-radius: 999px;
    background: #d9e0d7;
}

.meter i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--yellow), var(--coral));
}

.status-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.status-list span,
.mission-list li {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px;
    background: #fbf8ed;
    color: #4b544f;
    font-size: 13px;
    font-weight: 800;
}

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

.mission-list li.is-done {
    border-color: #add4bf;
    background: #edf8f1;
    color: #1d5d42;
}

.button-stack {
    display: grid;
    gap: 10px;
}

.soft-button {
    color: var(--primary-dark);
    background: #dfece5;
    box-shadow: 0 4px 0 #bed3c8;
}

.mobile-pad {
    display: none;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.mobile-pad button {
    min-height: 48px;
    padding: 0 8px;
    font-size: 13px;
}

@media (max-width: 1120px) {
    .topbar,
    .game-layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 760px) {
    .arcade-shell {
        width: min(100% - 16px, 1500px);
        padding-top: 8px;
    }

    .score-strip,
    .side-panel {
        grid-template-columns: 1fr 1fr;
    }

    .brand-mark {
        width: 56px;
        height: 56px;
    }

    .stage-panel {
        padding: 8px;
    }

    .overlay {
        inset: 8px;
    }

    .mobile-pad {
        display: grid;
    }
}

@media (max-width: 560px) {
    .score-strip,
    .side-panel,
    .mobile-pad {
        grid-template-columns: 1fr;
    }
}
