@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700;800&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap');
:root {
    color-scheme: light;
    --forest: #243a30;
    --forest-deep: #182920;
    --moss: #526c50;
    --cream: #f3efdf;
    --paper: #fcfaf2;
    --lime: #d7ec83;
    --coral: #ef866a;
    --ink: #26352d;
    --muted: #778176;
    --line: rgba(36, 58, 48, .16);
    font-family: 'DM Sans', 'Trebuchet MS', sans-serif;
    background: var(--cream);
    color: var(--ink);
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    padding: clamp(12px, 3vw, 36px);
    background-color: var(--cream);
    background-image: radial-gradient(rgba(36, 58, 48, .11) .7px, transparent .7px);
    background-size: 8px 8px;
}

button {
    font: inherit;
}

.arcade {
    width: min(100%, 1120px);
    margin: 0 auto;
    animation: arrive .65s cubic-bezier(.2, .75, .25, 1) both;
}

.topbar {
    display: flex;
    min-height: 82px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 24px;
    color: var(--paper);
    background: var(--forest);
    border: 1px solid var(--forest-deep);
    border-bottom: 4px solid var(--lime);
}

.wordmark,
.topbar-actions,
.topbar-actions p {
    display: flex;
    align-items: center;
}

.wordmark {
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.wordmark-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: var(--forest);
    background: var(--lime);
    font: 500 13px 'DM Mono', monospace;
    border: 2px solid rgba(255, 255, 255, .14);
}

.wordmark-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.wordmark strong {
    display: block;
    font: 700 19px 'Fraunces', Georgia, serif;
}

.wordmark small {
    display: block;
    margin-top: 3px;
    color: #b8c3b5;
    font: 10px 'DM Mono', monospace;
    text-transform: uppercase;
}

.topbar-actions {
    gap: 22px;
}

.objective {
    gap: 9px;
    margin: 0;
    color: #d6dfd0;
    font-size: 12px;
}

.objective-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--lime);
}

.icon-button {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: var(--paper);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .3);
    cursor: pointer;
    font-size: 18px;
}

.icon-button:hover:not(:disabled) {
    color: var(--forest);
    background: var(--lime);
    border-color: var(--lime);
}

.icon-button:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.game-panel {
    margin-top: 18px;
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: 0 14px 36px rgba(36, 58, 48, .09);
}

.scorebar {
    display: grid;
    min-height: 72px;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 11px;
}

.stat:nth-child(2),
.stat:nth-child(3) {
    justify-content: center;
}

.stat:last-child {
    justify-content: flex-end;
}

.stat-label {
    color: var(--muted);
    font: 10px 'DM Mono', monospace;
    letter-spacing: 0;
}

.stat strong {
    color: var(--forest);
    font: 500 17px 'DM Mono', monospace;
}

.stat-lives strong {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #d96e58;
    letter-spacing: 2px;
}

.stat-lives img {
    image-rendering: pixelated;
}

.stat-ultimate strong {
    color: var(--moss);
}

.stage {
    position: relative;
    overflow: hidden;
    background: #d3c093;
    aspect-ratio: 4 / 3;
    isolation: isolate;
}

.stage.is-playing {
    aspect-ratio: 2 / 1;
}

.stage::after {
    position: absolute;
    z-index: 1;
    inset: 0;
    border: 1px solid rgba(24, 41, 32, .25);
    content: '';
    pointer-events: none;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.screen {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(20, 35, 28, .46);
    transition: opacity .25s ease, visibility .25s ease;
}

.screen.is-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.screen-content {
    width: min(530px, 100%);
    padding: clamp(18px, 4vw, 38px);
    text-align: center;
    color: var(--forest);
    background: var(--paper);
    border-top: 5px solid var(--coral);
    box-shadow: 8px 8px 0 rgba(24, 41, 32, .25);
    animation: lift .35s ease both;
}

.screen-kicker {
    color: var(--moss);
    font: 10px 'DM Mono', monospace;
}

.screen-art {
    display: block;
    width: min(240px, 54%);
    max-height: 145px;
    object-fit: contain;
    margin: 0 auto 8px;
    image-rendering: pixelated;
}

.screen-art[hidden] {
    display: none;
}

.screen h1 {
    margin: 8px 0 9px;
    font: 700 clamp(25px, 4vw, 38px)/1.06 'Fraunces', Georgia, serif;
}

.screen p {
    margin: 0 auto;
    max-width: 395px;
    color: #59665a;
    font-size: 13px;
    line-height: 1.55;
}

.start-button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    padding: 0 20px;
    color: var(--paper);
    background: var(--forest);
    border: 0;
    box-shadow: 3px 3px 0 var(--lime);
    cursor: pointer;
    font-weight: 700;
    transition: transform .15s ease, background .15s ease;
}

.start-button:hover {
    background: var(--moss);
    transform: translate(-1px, -1px);
}

.screen .screen-hint {
    margin-top: 17px;
    color: #7d867a;
    font: 10px 'DM Mono', monospace;
}

.screen-hint span {
    padding: 0 4px;
    color: var(--coral);
}

.toast {
    position: absolute;
    z-index: 3;
    top: 68px;
    left: 50%;
    padding: 8px 14px;
    color: var(--forest);
    background: rgba(215, 236, 131, .5);
    font: 11px 'DM Mono', monospace;
    opacity: 0;
    transform: translate(-50%, -6px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.controlbar {
    display: flex;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 20px;
    border-top: 1px solid var(--line);
}

.touch-controls {
    display: grid;
    flex: 1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    gap: 8px;
}

.attack-controls {
    display: contents;
}

.move-button,
.action-button,
.ultimate-button {
    display: grid;
    width: 100%;
    height: 38px;
    min-width: 0;
    place-items: center;
    color: var(--forest);
    background: #f0eedf;
    border: 1px solid var(--line);
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

.move-button {
    font-size: 20px;
}

.action-button,
.ultimate-button {
    padding: 0 11px;
    color: var(--paper);
    background: var(--moss);
    font: 10px 'DM Mono', monospace;
}

.ultimate-button {
    background: #b45b43;
}

.ultimate-button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.ultimate-button.is-ready {
    color: var(--forest);
    background: var(--lime);
    animation: ready-pulse 1.2s ease-in-out infinite alternate;
}

.highscores {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 12px 0 0;
    padding: 0;
    color: #718071;
    font: 10px 'DM Mono', monospace;
    list-style: none;
}

.highscores:empty {
    display: none;
}

.origin {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    align-items: center;
    gap: clamp(24px, 4vw, 52px);
    margin-top: 20px;
    padding: clamp(22px, 4vw, 42px);
    background: var(--paper);
    border-top: 4px solid var(--coral);
    border-bottom: 1px solid var(--line);
}

.origin-story {
    max-width: 490px;
}

.origin-kicker,
.origin-figure figcaption span {
    color: var(--moss);
    font: 10px 'DM Mono', monospace;
}

.origin-kicker {
    margin: 0 0 12px;
}

.origin h2 {
    margin: 0 0 15px;
    color: var(--forest);
    font: 700 clamp(25px, 3vw, 34px)/1.08 'Fraunces', Georgia, serif;
}

.origin-story>p:not(.origin-kicker) {
    margin: 0 0 12px;
    color: #59665a;
    font-size: 13px;
    line-height: 1.65;
}

.origin-gallery {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    align-items: end;
    gap: 14px;
}

.origin-figure {
    min-width: 0;
    margin: 0;
}

.origin-figure img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border: 1px solid var(--line);
    box-shadow: 4px 4px 0 rgba(36, 58, 48, .12);
}

.origin-figure-primary img {
    aspect-ratio: 4 / 5;
}

.origin-figure figcaption {
    display: grid;
    gap: 4px;
    margin-top: 10px;
    color: #59665a;
    font-size: 11px;
    line-height: 1.4;
}

.origin-figure figcaption span {
    font-size: 9px;
}

.move-button:hover,
.move-button.is-pressed {
    background: var(--lime);
}

.action-button:hover,
.action-button.is-pressed,
.ultimate-button:hover:not(:disabled) {
    background: var(--forest);
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 2px 0;
    color: #697468;
    font: 10px 'DM Mono', monospace;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 9px;
    text-align: right;
}

.footer-right i {
    width: 6px;
    height: 6px;
    background: var(--coral);
    border-radius: 50%;
}

button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--coral);
    outline-offset: 3px;
}

@keyframes arrive {
    from {
        opacity: 0;
        transform: translateY(9px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes lift {
    from {
        opacity: 0;
        transform: translateY(7px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 620px) {
    body {
        padding: 10px;
        -webkit-user-select: none;
        user-select: none;
    }
    .topbar {
        min-height: 68px;
        padding: 0 12px;
    }
    .wordmark {
        gap: 8px;
    }
    .wordmark-mark {
        width: 32px;
        height: 32px;
    }
    .wordmark strong {
        font-size: 16px;
    }
    .wordmark small {
        font-size: 8px;
    }
    .topbar-actions {
        gap: 8px;
    }
    .objective {
        max-width: 140px;
        font-size: 10px;
        line-height: 1.35;
    }
    .icon-button {
        width: 34px;
        height: 34px;
        flex: 0 0 auto;
    }
    .game-panel {
        margin-top: 10px;
    }
    .origin {
        grid-template-columns: 1fr;
        gap: 22px;
        margin-top: 12px;
        padding: 22px 16px;
    }
    .origin-story {
        max-width: 620px;
    }
    .origin h2 {
        font-size: 27px;
    }
    .origin-gallery {
        gap: 10px;
    }
    .scorebar {
        min-height: 56px;
        padding: 0 8px;
    }
    .stat {
        display: grid;
        gap: 2px;
    }
    .stat:nth-child(2),
    .stat:nth-child(3) {
        justify-items: center;
    }
    .stat:last-child {
        justify-items: end;
    }
    .stat-label {
        font-size: 8px;
    }
    .stat strong {
        font-size: 14px;
    }
    .stat-lives strong {
        font-size: 12px;
        letter-spacing: 0;
        gap: 3px;
    }
    .stat-lives img {
        width: 12px;
        height: 12px;
    }
    .screen {
        padding: 11px;
    }
    .screen-content {
        padding: 13px 16px;
        border-top-width: 3px;
    }
    .screen-kicker {
        font-size: 8px;
    }
    .screen h1 {
        margin: 5px 0;
        font-size: clamp(20px, 6vw, 30px);
    }
    .screen-content>p {
        font-size: 11px;
        line-height: 1.35;
    }
    .start-button {
        min-height: 37px;
        margin-top: 10px;
        padding: 0 14px;
        font-size: 12px;
    }
    .screen .screen-hint {
        margin-top: 8px;
        font-size: 8px;
    }
    .controlbar {
        min-height: 0;
        flex-direction: column;
        align-items: stretch;
        padding: 8px 10px;
    }
    .touch-controls {
        flex: 0 0 auto;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 5px;
    }
    .move-button,
    .action-button,
    .ultimate-button {
        height: 72px;
    }
    .move-button {
        min-width: 0;
    }
    .action-button,
    .ultimate-button {
        padding: 0 6px;
        font-size: 9px;
    }
    .footer {
        padding-top: 12px;
        font-size: 8px;
    }
}

@media (max-width: 390px) {
    .objective {
        max-width: 105px;
    }
    .footer-right {
        max-width: 48%;
    }
    .screen-hint {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

@keyframes ready-pulse {
    from {
        box-shadow: 0 0 0 0 rgba(215, 236, 131, .12);
    }
    to {
        box-shadow: 0 0 0 5px rgba(215, 236, 131, .5);
    }
}