* {
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}
html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #101d27;
    color: #f6f3e9;
    font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
}
button {
    font: inherit;
    cursor: pointer;
    color: inherit;
    border: 1px solid #52616b;
    border-radius: 7px;
    background: #243641;
    transition: background .15s, transform .15s;
}
button:hover {
    background: #3b505b;
    border-color: #f6c85b;
}
button:active {
    transform: translateY(2px);
}
button:focus-visible {
    outline: 3px solid #f9cb59;
    outline-offset: 3px;
}
button.primary {
    background: #f3c153;
    color: #182730;
    border-color: #ffd987;
    font-weight: 800;
}
canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}
[hidden] {
    display: none !important;
}
.screen {
    position: absolute;
    z-index: 10;
    inset: 0;
    padding: max(28px, env(safe-area-inset-top)) max(5vw, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(5vw, env(safe-area-inset-left));
    overflow: auto;
    background: linear-gradient(90deg, #101d27f5 0%, #101d27e8 35%, #101d2770 65%, #101d2710 100%);
}
.topbar, .menu-footer, .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.brand {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 3px;
}
.brand b {
    color: #f3c153;
    font-size: 25px;
    margin-right: 12px;
}
.small-button {
    padding: 10px 15px;
    font-size: 13px;
}
.audio-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.hero {
    max-width: 570px;
    margin-top: clamp(35px, 12vh, 150px);
}
.eyebrow {
    color: #f3c153;
    font-size: 12px;
    letter-spacing: 4px;
    font-weight: 700;
}
h1 {
    font-size: clamp(45px, 5.6vw, 84px);
    line-height: 1.12;
    letter-spacing: -3px;
    margin: 22px 0;
}
h1 em {
    font-style: normal;
    color: #f3c153;
}
.hero p, .subtitle {
    color: #b6c2c7;
    line-height: 1.9;
    font-size: 15px;
}
.hero .primary {
    padding: 18px 34px;
    font-size: 18px;
    min-width: 255px;
    margin: 20px 12px 22px 0;
}
.stats {
    display: flex;
    gap: 36px;
    margin-top: 26px;
}
.stats strong {
    font-size: 25px;
    display: block;
}
.stats span, small {
    display: block;
    color: #9eafb7;
    font-size: 11px;
    margin-top: 5px;
    font-weight: 400;
}
.menu-footer {
    margin-top: 38px;
    color: #9eafb7;
    font-size: 12px;
}
.tag {
    border: 1px solid #4f646b;
    color: #a9d5ca;
    padding: 7px 12px;
    border-radius: 3px;
    letter-spacing: 1px;
}
.selection {
    background: #101d27eb;
}
.selection h2 {
    font-size: 32px;
    margin: 25px 0 7px;
}
.difficulty {
    display: flex;
    gap: 10px;
    margin: 22px 0;
}
.difficulty button {
    text-align: left;
    padding: 13px 20px;
    min-width: 165px;
}
.difficulty .selected {
    border-color: #f3c153;
    background: #3a3b2e;
    color: #f3c153;
}
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}
.level {
    min-height: 103px;
    padding: 14px 18px;
    text-align: left;
    background: #20323c;
    position: relative;
}
.level b {
    font-size: 24px;
    color: #f3c153;
    margin-right: 12px;
}
.level small {
    margin-top: 10px;
}
.level .done {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #75d7b6;
}
.modal-screen {
    display: grid;
    place-items: center;
    align-items: safe center;
    background: #09141bbb;
    backdrop-filter: blur(5px);
}
.modal {
    width: min(550px, 94vw);
    background: #192c37;
    border: 1px solid #51626b;
    border-top: 4px solid #f3c153;
    padding: 32px;
    border-radius: 9px;
    box-shadow: 0 25px 90px #0008;
}
.modal h2 {
    font-size: 32px;
    margin: 15px 0;
}
.modal p {
    color: #b4c2c9;
    line-height: 1.8;
}
.modal button {
    padding: 13px 18px;
    margin: 6px 5px 0 0;
}
.lesson {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 13px;
    line-height: 1.8;
    font-size: 14px;
    color: #b5c6ce;
}
.lesson b {
    color: #f4c459;
}
#hud {
    position: absolute;
    z-index: 2;
    inset: max(15px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) auto max(20px, env(safe-area-inset-left));
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}
.hud-panel {
    background: #14252eef;
    border: 1px solid #52616a;
    border-radius: 7px;
    padding: 13px 18px;
    box-shadow: 0 5px 20px #0003;
}
.hud-panel b {
    color: #f3c153;
}
.hud-right {
    display: flex;
    gap: 10px;
}
.hud-right button {
    pointer-events: auto;
    padding: 12px 17px;
}
#timer {
    font: 700 27px monospace;
}
#telemetry {
    position: fixed;
    left: 50%;
    bottom: max(22px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    text-align: center;
    min-width: 200px;
    font-size: 13px;
}
#speed {
    font-size: 27px;
    color: white;
}
#controls {
    position: absolute;
    z-index: 3;
    bottom: max(23px, env(safe-area-inset-bottom));
    left: max(22px, env(safe-area-inset-left));
    right: max(22px, env(safe-area-inset-right));
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}
.steering, .pedals {
    display: flex;
    gap: 10px;
    align-items: end;
}
#controls button {
    width: 78px;
    height: 78px;
    background: #1b303de8;
    border: 1px solid #81969d;
    pointer-events: auto;
    touch-action: none;
    font-size: 24px;
    font-weight: 700;
    padding: 4px;
    white-space: nowrap;
}
#controls button.active {
    background: #a87929;
    border-color: #ffe08c;
}
#controls button.horn {
    position: absolute;
    bottom: 90px;
    left: 0;
    width: 78px;
    height: 52px;
    font-size: 16px;
    color: #f5d482;
}
@media (max-height: 600px) {
    #controls button.horn {
        bottom: 76px;
        width: 62px;
        height: 44px;
        font-size: 14px;
    }
}
#controls .throttle {
    background: #efbf50;
    color: #172830;
    height: 100px;
}
#controls .brake {
    font-size: 18px;
}
#controls small {
    font-size: 10px;
    color: inherit;
}
#rotate {
    display: none;
    position: fixed;
    inset: 0;
    background: #142630;
    z-index: 30;
    text-align: center;
    padding: 25vh 25px 0;
}
#rotate span {
    color: #f3c153;
    font-size: 80px;
}
#toast {
    position: absolute;
    z-index: 20;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #172b37ee;
    color: #ffd16d;
    padding: 12px 22px;
    border-radius: 5px;
    pointer-events: none;
    opacity: 0;
}
@media (max-height: 600px) {
    .screen {
        padding: 16px 4vw;
    }
    .hero {
        margin-top: 20px;
    }
    h1 {
        font-size: 48px;
        margin: 13px 0;
    }
    .hero p {
        margin: 8px 0;
    }
    .hero .primary {
        margin: 8px 10px 5px 0;
        padding: 13px 28px;
    }
    .stats {
        margin-top: 10px;
    }
    .menu-footer {
        margin-top: 15px;
    }
    .level {
        min-height: 80px;
        padding: 10px;
    }
    .level b {
        font-size: 19px;
    }
    .selection h2 {
        margin-top: 10px;
        font-size: 25px;
    }
    .difficulty {
        margin: 10px 0;
    }
    .difficulty button {
        padding: 8px 15px;
    }
    #controls button {
        width: 62px;
        height: 62px;
    }
    #controls .throttle {
        height: 78px;
    }
    #telemetry {
        min-width: 158px;
        padding: 8px;
        font-size: 11px;
    }
    .hud-panel {
        padding: 8px 12px;
        font-size: 12px;
    }
    .modal {
        padding: 20px;
    }
}
@media (orientation: portrait) and (max-width: 650px) {
    #rotate {
        display: block;
    }
}
@media (max-width: 850px) {
    #controls button {
        width: 60px;
        height: 64px;
    }
    #telemetry {
        min-width: 160px;
        padding: 9px;
    }
    .level-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (max-width: 700px) and (orientation: landscape) {
    #controls button {
        width: 52px;
        height: 55px;
        font-size: 20px;
    }
    .steering, .pedals {
        gap: 6px;
    }
    #telemetry {
        min-width: 135px;
        font-size: 10px;
    }
    #speed {
        font-size: 22px;
    }
    .level-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .difficulty button {
        min-width: 0;
        flex: 1;
        font-size: 12px;
    }
    .brand {
        font-size: 10px;
        letter-spacing: 1px;
    }
}
