:root {
    color-scheme: light;
    --ink: #275345;
    --cream: #244c42;
    --muted: #667b60;
    --yellow: #f5cb67;
    --orange: #c95531;
    font-family: Consolas, "Courier New", "Microsoft YaHei", monospace;
    background: #f6f0dc;
    color: var(--cream)
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    min-height: 100svh;
    background: radial-gradient(ellipse at 50% 40%, #fff9e8 0, #e6efcf 70%);
    padding: 20px 16px
}

button,
textarea,
select {
    font: inherit
}

button {
    cursor: pointer
}

button:disabled {
    opacity: .55;
    cursor: wait
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 4px
}

[hidden] {
    display: none !important
}

.cabinet {
    width: min(100%, 396px);
    margin: auto
}

.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--cream);
    font-size: 11px;
    line-height: 1.15;
    letter-spacing: 1px;
    font-weight: bold
}

.brand-mark {
    display: grid;
    place-items: center;
    background: var(--yellow);
    color: var(--ink);
    width: 35px;
    height: 35px;
    font-size: 16px;
    letter-spacing: -2px;
    border: 2px solid #ffe6a2
}

.edition {
    font-size: 8px;
    line-height: 1.9;
    text-align: right;
    color: #657e62;
    letter-spacing: .4px
}

.edition span {
    font-size: 10px;
    letter-spacing: 1px
}

.machine {
    padding: 8px;
    background: #d8e6b7;
    border: 1px solid #9cae7a;
    box-shadow: 0 5px 0 #a6b681, 0 20px 65px #456a4926;
    position: relative
}

.machine:after {
    content: "";
    position: absolute;
    inset: 3px;
    border: 1px solid #f7f1d0;
    pointer-events: none
}

.stage {
    position: relative;
    width: 100%;
    aspect-ratio: 9/16;
    background: #97c66d;
    overflow: hidden;
    container-type: inline-size;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none
}

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

.hud {
    position: absolute;
    top: 2%;
    left: 3%;
    width: 94%;
    padding: 3% 4%;
    background: #fff8e6;
    border: 1px solid #b4c592;
    box-shadow: 3px 3px 0 #456a4933;
    pointer-events: none
}

.live-tag {
    margin-bottom: 2%;
    font-size: 2.6cqw;
    letter-spacing: 1.3px;
    color: #a96519
}

.instruments {
    display: flex;
    justify-content: space-between;
    font-variant-numeric: tabular-nums
}

.label {
    font-size: 2.3cqw;
    color: #617857;
    letter-spacing: .6px
}

.instruments strong {
    display: block;
    font-size: 7.3cqw;
    line-height: 1.3;
    font-weight: normal;
    letter-spacing: -1px
}

.instruments small {
    font-size: 2.7cqw;
    letter-spacing: 0;
    margin-left: 4px;
    color: #617857
}

.speed {
    text-align: right
}

.brake-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 2.5cqw;
    margin-top: 2%
}

.meter {
    height: 6px;
    flex: 1;
    background: #d6dfb9
}

.meter i,
.hold-meter i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--yellow)
}

.hold-row {
    display: flex;
    justify-content: space-between;
    font-size: 2.2cqw;
    margin-top: 2%;
    color: #5e7550
}

.hold-meter {
    height: 2px;
    background: #d6dfb9;
    margin-top: 4px
}

.hold-meter i {
    background: var(--orange)
}

.danger {
    color: #b84428 !important
}

.touch-divider {
    position: absolute;
    top: 50%;
    width: 100%;
    border-top: 1px dashed #fff6d088;
    pointer-events: none;
    display: none;
    color: #fff8de;
    font-size: 2.1cqw
}

.touch-divider span {
    position: absolute;
    right: 4%;
    top: -16px
}

.touch-divider span+span {
    top: 6px
}

.input-status {
    position: absolute;
    bottom: 3%;
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 5%;
    pointer-events: none
}

.input-status span {
    font-size: 2.8cqw;
    color: #36563d;
    background: #fff4ceeb;
    padding: 5px 8px;
    border: 1px solid #c4ce96
}

.input-status .active {
    background: var(--yellow);
    color: var(--ink);
    border-color: #fff0b5
}

.input-status .broken {
    background: #913f35;
    color: #fff0c4
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #daeabb99;
    padding: 6%;
    overflow: auto;
    touch-action: pan-y
}

.panel {
    width: 100%;
    text-align: center;
    padding: 7% 6%;
    background: #fff9eaf5;
    border: 1px solid #aabd8b;
    box-shadow: 4px 4px 0 #456a4933
}

.eyebrow {
    display: block;
    font-size: 2.25cqw;
    color: #a96519;
    letter-spacing: 1px
}

h1 {
    margin: 5% 0;
    font-size: 13cqw;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: 1px;
    text-shadow: 3px 3px 0 #e3d8af
}

h1 span {
    color: #a96519
}

h1 small {
    display: block;
    font-size: 3.6cqw;
    margin-top: 5%;
    color: var(--orange);
    letter-spacing: 3px
}

h2 {
    font-size: 7.4cqw;
    margin: 5% 0;
    color: #a96519;
    letter-spacing: -1px
}

.title-art {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 7% 0;
    color: #739253
}

.title-art img {
    width: 26px;
    height: 42px;
    image-rendering: pixelated
}

.title-art img:last-child {
    width: 40px;
    height: 44px
}

.intro,
.panel p {
    font-size: 3cqw;
    line-height: 1.8;
    color: #506b4c;
    margin: 5% 0
}

.button {
    display: block;
    width: 100%;
    border: 0;
    padding: 4% 8px;
    font-size: 3.5cqw;
    font-weight: bold;
    transition: background .1s, transform .1s
}

.button:active {
    transform: translateY(2px)
}

.primary {
    background: var(--yellow);
    color: #26312c;
    border-bottom: 3px solid #b88a37
}

.primary:hover {
    background: #ffdb7b
}

.secondary {
    background: #e5edcd;
    color: #385c3f;
    border: 1px solid #a4b682;
    margin-top: 3%
}

.secondary:hover {
    background: #d2e2ad
}

.panel .fine-print {
    font-size: 2.5cqw;
    color: #667e5a;
    margin: 7% 0 0
}

.text-button {
    border: 0;
    background: none;
    color: #58744e;
    padding: 12px 5px 0;
    font-size: 2.8cqw
}

.text-button:hover {
    color: #a96519
}

.result-panel {
    padding: 6%
}

.result-panel h2 {
    font-size: 7cqw
}

.result-panel p {
    margin: 3% 0
}

.score {
    border-top: 1px solid #b4c592;
    border-bottom: 1px solid #b4c592;
    padding: 4% 0;
    margin: 5% 0
}

.score>span {
    display: block;
    font-size: 2.4cqw;
    color: #5c774d
}

.score strong {
    display: block;
    font-size: 10cqw;
    font-weight: normal;
    color: #a96519;
    margin-top: 2%
}

.score small {
    font-size: 3cqw
}

.result-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    text-align: left;
    font-size: 2.8cqw;
    color: #5b764d;
    margin: 5% 0
}

.result-stats dd {
    margin: 0;
    text-align: right;
    color: var(--cream);
    font-variant-numeric: tabular-nums
}

.replay-label {
    display: block;
    text-align: left;
    font-size: 2.5cqw;
    color: #5b764d;
    margin: 5% 0 2%;
    letter-spacing: 1px
}

textarea {
    display: block;
    width: 100%;
    resize: none;
    background: #f4f3de;
    border: 1px solid #a4b682;
    color: #3c603f;
    padding: 8px;
    font-size: 2.7cqw;
    line-height: 1.5;
    user-select: text;
    -webkit-user-select: text;
    touch-action: auto;
    overflow-wrap: anywhere
}

.button-pair {
    display: flex;
    gap: 6px;
    margin-bottom: 4%
}

.button-pair .button {
    font-size: 3cqw
}

.panel .error {
    color: #af4026;
    font-size: 2.8cqw;
    min-height: 1.8em
}

.playback-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff6dced;
    padding: 3% 4%;
    text-align: center;
    font-size: 2.8cqw
}

.playback-bar>span {
    display: block;
    margin-bottom: 6px;
    color: #4a6b43
}

.playback-bar>div {
    display: flex;
    gap: 5px
}

.playback-bar button,
.playback-bar select {
    background: #e3edc6;
    border: 1px solid #a6b77e;
    color: var(--cream);
    padding: 7px 4px;
    flex: 1;
    min-width: 0;
    font-size: 2.8cqw
}

.instructions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    font-size: 10px;
    color: #5e7853;
    margin: 18px 0 14px
}

.instructions b {
    color: #8ba173;
    margin: 0 5px
}

kbd {
    font: inherit;
    border: 1px solid #a2b785;
    padding: 2px 4px;
    background: #e6edcc;
    color: #3d603c
}

.footer-line {
    display: flex;
    justify-content: space-between;
    font-size: 7px;
    letter-spacing: .5px;
    color: #6e865a;
    border-top: 1px solid #bdcda0;
    padding-top: 11px
}

.road-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
    image-rendering: auto
}

@media (pointer:coarse) {
    .touch-divider {
        display: block
    }

    .instructions span:first-child {
        display: none
    }
}

@media (max-width:440px) {
    body {
        padding: 10px 8px
    }

    .cabinet {
        width: min(100%, calc((100svh - 108px)*9/16 + 18px))
    }

    .masthead {
        margin-bottom: 8px
    }

    .brand {
        font-size: 9px
    }

    .brand-mark {
        width: 28px;
        height: 28px;
        font-size: 14px
    }

    .edition {
        font-size: 6px
    }

    .edition span {
        font-size: 8px
    }

    .machine {
        padding: 5px
    }

    .instructions {
        margin: 10px 0;
        font-size: 9px;
        gap: 6px
    }

    .footer-line {
        display: none
    }
}

@media (prefers-reduced-motion:reduce) {
    .button {
        transition: none
    }
}