:root {
    --ink: #2c2037;
    --ink-soft: #6f5e74;
    --accent: #ff6b57;
    --accent-deep: #e34d4f;
    --accent-warm: #ffb347;
    --mint: #6fd7c7;
    --gold: #ffd867;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-strong: rgba(255, 255, 255, 0.9);
    --shadow: 0 26px 60px rgba(102, 54, 39, 0.22);
    --stage-shadow: 0 32px 90px rgba(82, 52, 40, 0.24);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Trebuchet MS", "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 28%),
        radial-gradient(circle at 85% 10%, rgba(255, 248, 216, 0.88), transparent 26%),
        linear-gradient(135deg, #fff0b6 0%, #ffb58e 38%, #87d7d2 100%);
    touch-action: manipulation;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.12), transparent 55%),
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.16) 0, transparent 22%);
    mix-blend-mode: soft-light;
}

.page-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: clamp(18px, 4vw, 36px);
}

.game-shell {
    position: relative;
    width: min(960px, 94vw);
}

.game-shell.is-hit .game-stage {
    animation: stage-shake 0.34s linear;
}

.scene-decor {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.scene-cloud,
.scene-burst {
    position: absolute;
    display: block;
    pointer-events: none;
}

.scene-cloud {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.5);
    filter: blur(2px);
    box-shadow:
        28px 6px 0 rgba(255, 255, 255, 0.48),
        55px -4px 0 rgba(255, 255, 255, 0.42),
        78px 8px 0 rgba(255, 255, 255, 0.34);
    animation: cloud-drift linear infinite;
}

.scene-cloud--one {
    top: 34px;
    left: -80px;
    width: 64px;
    height: 22px;
    animation-duration: 18s;
}

.scene-cloud--two {
    top: 100px;
    left: -120px;
    width: 72px;
    height: 24px;
    animation-duration: 24s;
    animation-delay: -8s;
}

.scene-cloud--three {
    top: 64px;
    left: -160px;
    width: 58px;
    height: 18px;
    animation-duration: 20s;
    animation-delay: -14s;
}

.scene-burst {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    animation: burst-float 8s ease-in-out infinite;
}

.scene-burst--one {
    right: 8%;
    top: 56px;
    width: 120px;
    height: 120px;
}

.scene-burst--two {
    left: 3%;
    bottom: 42px;
    width: 150px;
    height: 150px;
    animation-delay: -4s;
}

.game-stage {
    position: relative;
    min-height: clamp(280px, 56vw, 420px);
    border-radius: 34px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.68);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.44) 0%, rgba(255, 239, 188, 0.28) 100%),
        linear-gradient(180deg, #fff2d9 0%, #ffd7a6 48%, #ffd39a 100%);
    box-shadow: var(--stage-shadow);
    isolation: isolate;
    touch-action: manipulation;
    user-select: none;
}

.game-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.72), transparent 18%),
        radial-gradient(circle at 78% 24%, rgba(255, 255, 255, 0.32), transparent 22%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 65%);
    pointer-events: none;
    z-index: 0;
}

.hud {
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    display: flex;
    gap: 12px;
    z-index: 6;
}

.hud-card {
    min-width: 154px;
    padding: 14px 16px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    transition: transform 0.24s ease, box-shadow 0.24s ease;
}

.hud-card--wide {
    flex: 1;
}

.hud-card.is-pulse {
    animation: hud-pulse 0.42s ease;
}

.hud-label {
    display: block;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.hud-value {
    display: block;
    margin-top: 6px;
    font-size: clamp(26px, 4vw, 40px);
    line-height: 1;
    letter-spacing: -0.04em;
}

.hud-value--status {
    font-size: clamp(18px, 2.4vw, 25px);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.hud-subvalue {
    display: inline-flex;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1;
}

.track-horizon {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 30%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(225, 169, 87, 0.65), transparent);
    opacity: 0.75;
    z-index: 1;
}

.player {
    position: absolute;
    left: clamp(46px, 8vw, 96px);
    bottom: calc(30% - 8px);
    width: clamp(62px, 10vw, 82px);
    height: clamp(72px, 11vw, 94px);
    transform: translate3d(0, 0, 0);
    transform-origin: bottom center;
    will-change: transform;
    z-index: 5;
}

.player-shadow {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: -8px;
    height: 16px;
    border-radius: 999px;
    background: rgba(87, 52, 30, 0.25);
    filter: blur(10px);
    transform-origin: center;
}

.player-figure {
    position: absolute;
    inset: 0;
    transform-origin: bottom center;
    will-change: transform;
}

.player-art {
    position: absolute;
    inset: 0;
    border-radius: 26px 26px 18px 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 34%),
        linear-gradient(180deg, #ff8c72 0%, #ff5a61 52%, #ec4c71 100%);
    background-position: center;
    background-size: cover;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.58),
        0 16px 28px rgba(136, 68, 60, 0.22);
    animation: idle-bob 2.2s ease-in-out infinite;
}

.game-shell[data-screen="playing"] .player-art {
    animation-duration: 0.8s;
}

.player-spark {
    position: absolute;
    inset: -14px;
    border-radius: 28px;
    border: 2px dashed rgba(255, 255, 255, 0.72);
    opacity: 0;
    transform: scale(0.88);
}

.player-spark.is-active {
    animation: spark-burst 0.4s ease;
}

.obstacle-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 4;
}

.obstacle {
    position: absolute;
    left: 0;
    border-radius: 22px 22px 14px 14px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 26%),
        linear-gradient(180deg, #6b4250 0%, #503947 54%, #3d2f3b 100%);
    background-position: center;
    background-size: cover;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.26),
        0 12px 24px rgba(61, 47, 59, 0.2);
    will-change: transform;
}

.obstacle::after {
    content: "";
    position: absolute;
    left: 14%;
    right: 14%;
    bottom: -8px;
    height: 12px;
    border-radius: 999px;
    background: rgba(74, 48, 42, 0.18);
    filter: blur(8px);
}

.track {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 30%;
    background:
        linear-gradient(180deg, #ffd98a 0%, #ffbf69 54%, #ff9758 100%);
    overflow: hidden;
    z-index: 2;
}

.track::before,
.track::after {
    content: "";
    position: absolute;
    left: -15%;
    right: -15%;
    height: 44%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.track::before {
    top: -26%;
}

.track::after {
    bottom: -26%;
}

.track-line {
    position: absolute;
    left: -12%;
    right: -12%;
    bottom: 18px;
    height: 10px;
    background:
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.95) 0 44px, transparent 44px 88px);
    opacity: 0.82;
    animation: track-dash 0.9s linear infinite;
}

.track-line--alt {
    bottom: 40px;
    height: 6px;
    opacity: 0.38;
    animation-duration: 1.4s;
}

.screen {
    position: absolute;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: clamp(88px, 10vw, 120px) clamp(22px, 4vw, 38px) clamp(26px, 5vw, 40px);
    text-align: center;
    background:
        linear-gradient(180deg, rgba(255, 251, 238, 0.76) 0%, rgba(255, 244, 228, 0.5) 100%);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(0.98);
    transition: opacity 0.28s ease, transform 0.28s ease;
    z-index: 7;
}

.reward-popup {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(360px, calc(100% - 36px));
    padding: 22px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background:
        linear-gradient(180deg, rgba(255, 254, 241, 0.95), rgba(255, 238, 192, 0.9));
    box-shadow: 0 28px 54px rgba(118, 81, 28, 0.24);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -44%) scale(0.9);
    transition: opacity 0.28s ease, transform 0.34s ease;
    z-index: 8;
}

.reward-popup::before {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 34px;
    border: 2px solid rgba(255, 236, 158, 0.58);
    opacity: 0;
    animation: reward-ring 1.4s ease infinite;
}

.game-shell[data-screen="loading"] [data-role="loadingScreen"],
.game-shell[data-screen="ready"] [data-role="startScreen"],
.game-shell[data-screen="gameover"] [data-role="gameOverScreen"] {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.game-shell[data-reward-visible="true"] [data-role="rewardPopup"] {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.game-shell[data-reward-visible="true"] [data-role="rewardPopup"]::before {
    opacity: 1;
}

.screen-eyebrow,
.reward-kicker {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.screen-title,
.reward-title {
    margin: 10px 0 0;
    font-size: clamp(34px, 6vw, 56px);
    line-height: 0.96;
    letter-spacing: -0.05em;
}

.reward-title {
    font-size: clamp(26px, 4vw, 36px);
}

.screen-copy,
.reward-copy {
    width: min(100%, 680px);
    margin: 14px auto 0;
    font-size: clamp(15px, 2.1vw, 18px);
    line-height: 1.65;
    color: var(--ink-soft);
}

.screen-note,
.screen-warning {
    margin: 14px 0 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink-soft);
}

.screen-warning {
    max-width: 680px;
    padding: 10px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
}

.screen-warning:empty {
    display: none;
}

.start-grid {
    width: min(100%, 760px);
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.tip-card {
    min-height: 156px;
    padding: 18px;
    border-radius: 24px;
    text-align: left;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
}

.tip-index {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255, 205, 127, 0.4);
    color: var(--accent-deep);
    font-size: 13px;
    font-weight: 700;
}

.tip-title {
    margin: 14px 0 0;
    font-size: 20px;
}

.tip-copy {
    margin: 8px 0 0;
    color: var(--ink-soft);
    line-height: 1.6;
}

.screen-actions {
    display: grid;
    justify-items: center;
    gap: 10px;
    margin-top: 26px;
}

.action-button {
    border: 0;
    padding: 14px 28px;
    border-radius: 999px;
    background:
        linear-gradient(135deg, #ff8b70 0%, #ff6358 55%, #f54c76 100%);
    color: white;
    font: inherit;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 18px 26px rgba(233, 82, 92, 0.28);
    transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease;
}

.action-button:hover,
.action-button:focus-visible {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 22px 34px rgba(233, 82, 92, 0.34);
    filter: saturate(1.08);
    outline: none;
}

.action-button--secondary {
    background:
        linear-gradient(135deg, #57cdbf 0%, #4ab6d4 55%, #458bea 100%);
    box-shadow: 0 18px 26px rgba(69, 139, 234, 0.26);
}

.summary-strip {
    display: grid;
    width: min(100%, 520px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 24px 0;
}

.summary-pill {
    padding: 18px;
    border-radius: 22px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
}

.summary-pill span {
    display: block;
    font-size: 13px;
    color: var(--ink-soft);
}

.summary-pill strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    letter-spacing: -0.03em;
}

.progress {
    width: min(100%, 440px);
    margin-top: 24px;
}

.progress-bar {
    position: relative;
    height: 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.75);
}

.progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background:
        linear-gradient(90deg, var(--mint) 0%, #7fd8a5 50%, var(--gold) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: width 0.26s ease;
}

.progress-value {
    display: inline-block;
    margin-top: 10px;
    color: var(--ink-soft);
    font-size: 14px;
}

.reward-media {
    width: 100%;
    margin-top: 18px;
    padding: 12px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.6);
}

.reward-media img {
    display: block;
    width: min(100%, 164px);
    aspect-ratio: 1;
    margin: 0 auto;
    object-fit: cover;
    border-radius: 18px;
    box-shadow: 0 18px 28px rgba(123, 88, 40, 0.22);
}

.reward-fallback {
    display: none;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 230, 161, 0.48), rgba(255, 255, 255, 0.72));
    color: var(--ink-soft);
    line-height: 1.6;
}

.reward-media.is-fallback img {
    display: none;
}

.reward-media.is-fallback .reward-fallback {
    display: block;
}

@media (max-width: 760px) {
    .hud {
        flex-direction: column;
        top: 14px;
        left: 14px;
        right: 14px;
    }

    .hud-card,
    .hud-card--wide {
        width: 100%;
    }

    .screen {
        padding-top: 108px;
    }

    .start-grid,
    .summary-strip {
        grid-template-columns: 1fr;
    }

    .tip-card {
        min-height: auto;
    }

    .action-button {
        width: 100%;
        max-width: 280px;
    }

    .reward-popup {
        width: min(320px, calc(100% - 24px));
        padding: 18px;
    }
}

@media (max-width: 520px) {
    .page-shell {
        padding: 12px;
    }

    .game-stage {
        min-height: 300px;
        border-radius: 28px;
    }

    .player {
        left: 34px;
        width: 58px;
        height: 72px;
    }

    .track-line {
        bottom: 12px;
    }

    .track-line--alt {
        bottom: 32px;
    }

    .screen-title,
    .reward-title {
        font-size: clamp(28px, 8vw, 40px);
    }
}

@keyframes cloud-drift {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(calc(100vw + 260px));
    }
}

@keyframes burst-float {
    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-12px) scale(1.06);
    }
}

@keyframes idle-bob {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

@keyframes spark-burst {
    0% {
        opacity: 0;
        transform: scale(0.74);
    }

    30% {
        opacity: 0.95;
    }

    100% {
        opacity: 0;
        transform: scale(1.22);
    }
}

@keyframes track-dash {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-88px);
    }
}

@keyframes hud-pulse {
    0% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes reward-ring {
    0% {
        transform: scale(0.98);
        opacity: 0;
    }

    30% {
        opacity: 0.7;
    }

    100% {
        transform: scale(1.06);
        opacity: 0;
    }
}

@keyframes stage-shake {
    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-6px);
    }

    50% {
        transform: translateX(4px);
    }

    75% {
        transform: translateX(-3px);
    }
}
