body {
    margin: 0;
    background-color: #0b0709;
    background-image:
        radial-gradient(ellipse at 18% 20%, rgba(112, 24, 43, 0.38), transparent 58%),
        radial-gradient(ellipse at 85% 80%, rgba(87, 15, 34, 0.32), transparent 55%),
        linear-gradient(145deg, #170b10 0%, #0b0709 52%, #200b13 100%);
    background-attachment: fixed;
    color: #fff3f5;

    font-family:
        "PingFang SC",
        "Microsoft YaHei",
        Arial,
        sans-serif;

    height: 100vh;

    display: flex;
    flex-direction: column;

    justify-content: center;
    align-items: center;
}

h1 {
    font-size: 60px;
    margin-bottom: 10px;
}

p {
    color: #c6aeb6;
}

button {
    margin-top: 30px;

    padding: 15px 40px;

    font-size: 18px;

    background: linear-gradient(135deg, #a62946, #78172f);
    box-shadow: 0 8px 28px rgba(100, 13, 35, 0.3), inset 0 1px 0 rgba(255, 220, 229, 0.12);
    transition: filter 160ms ease, box-shadow 160ms ease;
    color: #fff3f5;

    border: none;
    border-radius: 8px;

    cursor: pointer;
}

/* Page visibility and difficulty selection */
[hidden] {
    display: none !important;
}

main {
    width: 100%;
    text-align: center;
    padding: 24px;
    box-sizing: border-box;
}

.difficulty-options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}

button[aria-pressed="true"] {
    background: #64172c;
    outline: 2px solid #f2b5c5;
    outline-offset: 3px;
}

button:focus-visible {
    outline: 2px solid #f2b5c5;
    outline-offset: 3px;
}

@media (max-width: 480px) {
    h1 { font-size: 44px; }
}

label { display: block; margin: 24px 0 10px; color: #dbc3ca; }
select { padding: 12px 18px; border: 1px solid #68404e; border-radius: 8px; background: #211219; color: white; font: inherit; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
body { min-height: 100vh; height: auto; }

.timer { font-size: 48px; font-variant-numeric: tabular-nums; }
.task-card { max-width: 480px; margin: 24px auto 0; padding: 20px; background: #211219; border: 1px solid #4d2937; border-radius: 12px; }
.task-card p { line-height: 1.5; }
progress { width: 100%; height: 12px; accent-color: #b43c5b; }
#session-state { color: #e1cbd2; }

button:not(:disabled):hover { filter: brightness(1.12); }
select:focus-visible { outline: 2px solid #f2b5c5; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
    button { transition: none; }
}

/* Focus the game layout on the current task, in every difficulty. */
#game-page { width: min(100%, 900px); margin: 0 auto; padding: 48px 0 24px; }
#game-summary { margin: 0 0 20px; color: #c6aeb6; font-size: 14px; }
#game-page .task-card {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    min-height: clamp(340px, 58vh, 560px);
    margin: 0;
    padding: clamp(24px, 5vw, 56px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 20px;
    background: rgba(33, 18, 25, 0.88);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.22);
}
#game-page .task-label { margin: 0 0 28px; color: #c6aeb6; font-size: 16px; font-weight: 400; letter-spacing: 0.12em; }
#task-text { margin: 0; color: #fff3f5; font-size: clamp(28px, 4.8vw, 44px); line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
#game-page .task-countdown { margin: 36px 0 20px; font-size: 16px; }
#task-timer { font-variant-numeric: tabular-nums; }
:is(#game-page, #reward-page) .game-back {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    z-index: 10;
    margin: 0;
    padding: 0;
    width: 44px;
    height: 44px;
    background: transparent;
    box-shadow: none;
    color: #dfc8d0;
    font-size: 28px;
    border-radius: 50%;
}
:is(#game-page, #reward-page) .game-back:hover { background: rgba(255, 243, 245, 0.08); }

/* Lift the task heading and content without moving the countdown. */
#game-page .task-label,
#game-page #task-text {
    position: relative;
    top: -24px;
}

.ending-preview-controls { margin: 28px auto 0; padding-top: 18px; border-top: 1px solid #4d2937; max-width: 360px; }
.ending-preview-controls p { font-size: 13px; margin: 0 0 12px; }
.ending-preview-controls button { margin: 6px; padding: 10px 18px; font-size: 14px; background: transparent; border: 1px solid #68404e; box-shadow: none; }

#reward-page { width: min(100%, 900px); margin: 0 auto; padding: 56px 0 24px; }
#reward-heading { margin: 0 0 32px; font-size: clamp(26px, 4.5vw, 40px); line-height: 1.5; }
#reward-page .task-card { max-width: none; min-height: 260px; padding: clamp(24px, 5vw, 48px); box-sizing: border-box; }
#reward-page .task-label { font-size: 16px; font-weight: 400; color: #c6aeb6; }
#reward-task { font-size: clamp(28px, 4.8vw, 44px); color: #fff3f5; line-height: 1.5; }
#reward-page .task-countdown { margin: 32px 0 20px; }
/* A steady red cue for the five-second stillness task; no flashing. */
body.stop-task { background-color: #821d31; background-image: linear-gradient(145deg, #a52a40, #681b2d); }
body.stop-task .task-card { background: rgba(67, 10, 24, 0.8); border-color: #c2677a; }

/* Age confirmation and restricted-access message */
#welcome-page, #underage-page { max-width: 700px; margin: 0 auto; padding: 24px 0; }
#welcome-page h1, #underage-page h1 { margin: 12px 0 28px; font-size: clamp(28px, 5.5vw, 44px); line-height: 1.35; }
.age-eyebrow { font-size: 14px; letter-spacing: 0.14em; color: #c6aeb6; }
.age-notice { max-width: 600px; margin: 0 auto; text-align: left; }
.age-notice p { font-size: 16px; line-height: 1.85; color: #dac5cc; }
.age-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; margin-top: 30px; }
.age-actions button { margin: 0; padding: 15px 22px; font-size: 16px; }
.age-actions .secondary-button { background: transparent; border: 1px solid #79515f; box-shadow: none; color: #dfc8d0; }
@media (max-width: 480px) { .age-actions { flex-direction: column; } .age-actions button { width: 100%; } }

#ending-heading.failure-heading {
    white-space: pre-line;
    font-size: clamp(18px, 4.5vw, 44px);
    line-height: 1.65;
    margin: 0 0 24px;
}

#difficulty-page .feedback-note {
    margin: 22px auto 0;
    max-width: 520px;
    color: rgba(225, 203, 212, 0.62);
    font-size: 13px;
    line-height: 1.8;
}
.feedback-note a { color: inherit; text-decoration: none; white-space: nowrap; }
.feedback-note a:hover { color: #f2d4df; text-decoration: underline; }
.feedback-note a:focus-visible { outline: 2px solid #f2b5c5; outline-offset: 4px; border-radius: 2px; }

#difficulty-heading { font-size: clamp(28px, 5vw, 36px); line-height: 1.4; }

/* Green atmosphere only while the reward progress page is visible. */
body:has(#reward-page:not([hidden])) {
    background-color: #070c0a;
    background-image:
        radial-gradient(ellipse at 18% 18%, rgba(133, 211, 171, 0.19), transparent 57%),
        radial-gradient(ellipse at 85% 78%, rgba(79, 151, 115, 0.15), transparent 55%),
        linear-gradient(145deg, #101e17 0%, #070c0a 52%, #102219 100%);
    color: #edfff4;
}
#reward-page #reward-heading, #reward-page #reward-task {
    color: #e2ffed;
    text-shadow: 0 0 32px rgba(146, 225, 180, 0.15);
}
#reward-page p, #reward-page .task-label { color: #b3cdbd; }
#reward-page .task-card {
    background: rgba(14, 28, 20, 0.88);
    border-color: #385644;
    box-shadow: 0 18px 70px rgba(0, 0, 0, 0.28), 0 0 35px rgba(115, 193, 148, 0.06);
}
#reward-page progress { accent-color: #a4dfb9; }
#reward-page .game-back { color: #c3e3cf; }
#reward-page button:focus-visible { outline-color: #c5f1d5; }
