:root {
    color-scheme: dark;
    font-family: "SFMono-Regular", "Cascadia Mono", "PingFang SC", "Microsoft YaHei", monospace;
    background: #36105f;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #36105f;
}

button {
    font: inherit;
    letter-spacing: 0;
}

.game-shell {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 420px;
    overflow: hidden;
    background: #bdf56b;
    isolation: isolate;
}

#game-container,
#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#game-container canvas {
    object-fit: contain;
    image-rendering: pixelated;
    background: #bdf56b;
}

.screen-layer {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 5vw, 72px);
    background: rgba(54, 16, 95, 0.54);
}

.screen-layer.is-visible {
    display: flex;
}

#start-screen {
    justify-content: flex-start;
    background: linear-gradient(90deg, rgba(221, 255, 154, 0.92) 0%, rgba(189, 245, 107, 0.72) 38%, transparent 70%);
}

.start-copy {
    width: min(480px, 92vw);
    color: #36105f;
    text-shadow: 4px 4px 0 #ffe45b;
}

.eyebrow {
    margin: 0 0 10px;
    color: #6720b4;
    font-size: clamp(12px, 1.5vw, 18px);
    font-weight: 900;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: #6720b4;
    font-family: "PingFang SC", "Microsoft YaHei", Impact, sans-serif;
    font-size: clamp(50px, 7vw, 104px);
    line-height: 0.82;
    letter-spacing: 0;
    -webkit-text-stroke: clamp(2px, 0.3vw, 5px) #36105f;
    text-shadow: 8px 8px 0 #ffe45b;
}

h1 span {
    color: #ff7a2f;
    text-shadow: 8px 8px 0 #bdf56b;
}

.mission {
    max-width: 440px;
    margin: clamp(24px, 4vh, 42px) 0 20px;
    color: #36105f;
    font-size: clamp(15px, 1.6vw, 21px);
    font-weight: 800;
    line-height: 1.6;
    text-shadow: 2px 2px 0 #ddff9a;
}

.primary-button {
    min-width: 168px;
    min-height: 52px;
    border: 3px solid #36105f;
    border-radius: 6px;
    color: #fffdf0;
    background: #6720b4;
    box-shadow: 5px 5px 0 #36105f;
    font-size: 18px;
    font-weight: 950;
    cursor: pointer;
}

.primary-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 7px 7px 0 #36105f;
}

.primary-button:active {
    transform: translate(3px, 3px);
    box-shadow: 2px 2px 0 #36105f;
}

.result-panel {
    width: min(520px, 92vw);
    padding: 32px;
    border: 4px solid #36105f;
    border-radius: 8px;
    color: #36105f;
    background: #f3ffe0;
    box-shadow: 10px 10px 0 rgba(54, 16, 95, 0.72);
    text-align: center;
}

.result-panel .eyebrow {
    color: #6720b4;
}

.result-panel h2 {
    margin: 4px 0 22px;
    font-family: Impact, "Arial Black", sans-serif;
    font-size: clamp(42px, 7vw, 76px);
    line-height: 1;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
    margin: 0 0 26px;
    border: 2px solid #36105f;
    background: #36105f;
}

.result-stats span {
    padding: 15px 10px;
    background: #fff;
    font-size: 14px;
    font-weight: 800;
}

.result-stats b {
    display: block;
    color: #e94235;
    font-size: 28px;
}

.utility-buttons {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    z-index: 15;
    display: flex;
    gap: 8px;
}

.icon-button,
.touch-button {
    display: grid;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.84);
    color: #fff;
    background: rgba(6, 27, 53, 0.68);
    box-shadow: 3px 3px 0 rgba(6, 27, 53, 0.46);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.icon-button {
    width: 42px;
    height: 42px;
    border-radius: 4px;
    font-size: 19px;
    font-weight: 900;
}

.touch-controls {
    position: absolute;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    left: max(18px, env(safe-area-inset-left));
    z-index: 14;
    display: none;
    justify-content: space-between;
    pointer-events: none;
}

.touch-group {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.touch-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    font-size: 30px;
    font-weight: 950;
    pointer-events: auto;
}

.touch-button.action {
    width: 72px;
    height: 72px;
}

.touch-button.jump {
    color: #081a2f;
    background: rgba(255, 225, 47, 0.9);
}

.touch-button.dash {
    color: #081a2f;
    background: rgba(21, 212, 195, 0.9);
}

.touch-button.is-pressed,
.icon-button:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 rgba(6, 27, 53, 0.46);
}

@media (pointer: coarse), (max-width: 900px) {
    .touch-controls {
        display: flex;
    }

    .utility-buttons {
        top: max(8px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
    }

    #start-screen {
        align-items: flex-start;
        padding-top: max(34px, env(safe-area-inset-top));
        background: linear-gradient(90deg, rgba(221, 255, 154, 0.9), rgba(189, 245, 107, 0.38));
    }

    .start-copy {
        width: min(360px, 82vw);
    }

    .mission {
        margin-top: 22px;
    }
}

@media (max-height: 560px) {
    .game-shell {
        min-height: 320px;
    }

    .start-copy {
        transform: scale(0.78);
        transform-origin: left center;
    }

    .touch-button {
        width: 54px;
        height: 54px;
    }

    .touch-button.action {
        width: 60px;
        height: 60px;
    }
}
