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; }
.activity-modes { max-width: 440px; margin: 28px auto 0; padding: 14px 18px; border: 1px solid #68404e; border-radius: 12px; display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; }
.activity-modes legend { padding: 0 10px; color: #dbc3ca; }
.activity-modes label { margin: 0; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.activity-modes input { accent-color: #b43c5b; width: 18px; height: 18px; }
#duration-input { width: min(100%, 240px); box-sizing: border-box; padding: 12px 18px; border: 1px solid #68404e; border-radius: 8px; background: #211219; color: #fff3f5; font: inherit; font-size: 18px; }
#duration-input:focus-visible { outline: 2px solid #f2b5c5; outline-offset: 3px; }
#duration-help, .mode-description { font-size: 13px; color: #c6aeb6; line-height: 1.6; }
.input-error { font-size: 14px; min-height: 1.6em; color: #ffc0ce; margin: 8px 0 0; }
#ending-heading { font-size: clamp(28px, 5vw, 42px); line-height: 1.5; }

.success-confetti { position: fixed; inset: 0; z-index: 100; pointer-events: none; overflow: hidden; }
.confetti-piece { position: absolute; top: -20px; width: 8px; height: 13px; opacity: 0; animation: confetti-fall linear both; will-change: transform; }
@keyframes confetti-fall {
    0% { opacity: 0; transform: translate3d(0, -20px, 0) rotate(0deg); }
    8% { opacity: 0.95; }
    80% { opacity: 0.85; }
    100% { opacity: 0; transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin)); }
}
@media (prefers-reduced-motion: reduce) { .success-confetti { display: none; } }

/* Slow red-black ocean on the settings screen. */
body:has(#difficulty-page:not([hidden])) {
    isolation: isolate;
    background: #080305;
}
body:has(#difficulty-page:not([hidden]))::before,
body:has(#difficulty-page:not([hidden]))::after {
    content: "";
    position: fixed;
    pointer-events: none;
    z-index: -1;
    inset: -9%;
}
body:has(#difficulty-page:not([hidden]))::before {
    background-image: linear-gradient(135deg, #d24c66, #571323 55%, #bc3a50), url("ocean-texture.png");
    background-size: cover;
    background-position: center;
    background-blend-mode: multiply;
    opacity: .9;
    animation: ocean-drift 26s ease-in-out infinite alternate;
}
body:has(#difficulty-page:not([hidden]))::after {
    background:
        radial-gradient(ellipse at 22% 26%, rgba(169, 24, 50, .2), transparent 48%),
        radial-gradient(ellipse at 77% 72%, rgba(210, 53, 74, .13), transparent 45%),
        linear-gradient(90deg, rgba(5, 2, 4, .14), rgba(5, 2, 4, .42) 50%, rgba(5, 2, 4, .14));
    animation: ocean-glimmer 13s ease-in-out infinite alternate;
}
#difficulty-page { position: relative; }
@keyframes ocean-drift {
    from { transform: translate3d(-1.5%, -2%, 0) scale(1.02) rotate(-1deg); }
    to { transform: translate3d(1.5%, 2%, 0) scale(1.08) rotate(1deg); }
}
@keyframes ocean-glimmer {
    from { opacity: .55; transform: translate3d(-2%, 0, 0); }
    to { opacity: 1; transform: translate3d(2%, -1%, 0); }
}
@media (prefers-reduced-motion: reduce) {
    body:has(#difficulty-page:not([hidden]))::before,
    body:has(#difficulty-page:not([hidden]))::after { animation: none; }
}

#language-switcher { width: 100%; box-sizing: border-box; text-align: center; padding: 22px 16px 30px; color: #c6aeb6; font-size: 12px; }
#language-switcher > div { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
#language-switcher button { margin: 0; padding: 10px 14px; font-size: 14px; background: rgba(24, 12, 18, .7); border: 1px solid #68404e; box-shadow: none; }
#language-switcher button[aria-pressed="true"] { background: #64172c; }
html[lang="en"] .age-actions button { white-space: normal; }

/* Language selection is only visible on the home screen. */
body:not(:has(#welcome-page:not([hidden]))) #language-switcher { display: none; }

/* Branding above difficulty selection, rabbit first, wordmark second. */
.difficulty-brand { width: min(70%, 322px); margin: 0 auto 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.difficulty-brand img { display: block; height: auto; object-fit: contain; }
.difficulty-brand .brand-rabbit { width: 85%; }
.difficulty-brand .brand-wordmark { width: 100%; }
#difficulty-page .difficulty-brand + #difficulty-heading { margin-top: 36px; }

/* Worn sign: long quiet intervals with occasional dimming. */
#difficulty-page:not([hidden]) .brand-wordmark {
    animation: worn-sign 17s linear infinite;
}
@keyframes worn-sign {
    0%, 19%, 24%, 53%, 60%, 84%, 100% {
        opacity: .95;
        filter: grayscale(.1) brightness(.95) drop-shadow(0 0 5px rgba(172, 31, 55, .22));
    }
    20%, 22%, 55%, 58%, 87%, 91% {
        opacity: .4;
        filter: grayscale(.95) brightness(.48) drop-shadow(0 0 0 transparent);
    }
    21%, 23%, 56%, 59%, 88% {
        opacity: 1;
        filter: grayscale(0) brightness(1.12) drop-shadow(0 0 7px rgba(196, 40, 62, .35));
    }
    93%, 97% {
        opacity: .78;
        filter: grayscale(.4) brightness(.8) drop-shadow(0 0 2px rgba(172, 31, 55, .12));
    }
}
@media (prefers-reduced-motion: reduce) {
    #difficulty-page:not([hidden]) .brand-wordmark { animation: none; }
}

/* Gentle partial desaturation and recovery for the rabbit. */
#difficulty-page:not([hidden]) .brand-rabbit {
    animation: rabbit-color-breathe 10s ease-in-out infinite;
}
@keyframes rabbit-color-breathe {
    0%, 100% { filter: grayscale(0) brightness(1); }
    50% { filter: grayscale(.6) brightness(.48); }
}
@media (prefers-reduced-motion: reduce) {
    #difficulty-page:not([hidden]) .brand-rabbit { animation: none; }
}

/* Original two-state rabbit artwork: white on left, red on right. */
.activity-modes input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: url("mode-rabbit-states.png") left center / 200% 100% no-repeat;
    cursor: pointer;
}
.activity-modes input[type="radio"]:checked {
    background-position: right center;
    filter: drop-shadow(0 0 4px rgba(213, 29, 51, .35));
}
.activity-modes input[type="radio"]:focus-visible {
    outline: 2px solid #f2b5c5;
    outline-offset: 4px;
    border-radius: 4px;
}
.activity-modes label { min-height: 44px; }
@media (forced-colors: active) {
    .activity-modes input[type="radio"] { appearance: auto; background: none; }
}

/* Shared responsive type scale and aligned settings controls. */
:root { --ui-font: clamp(14px, 3.1vw, 18px); }
body { font-size: var(--ui-font); }
main { padding: clamp(16px, 4vw, 24px); }
button, select { font-size: calc(var(--ui-font) * 1.125); }
#welcome-page h1, #underage-page h1 { font-size: calc(var(--ui-font) * 2); }
#difficulty-heading { font-size: calc(var(--ui-font) * 1.8); }
#ending-heading, #ending-heading.failure-heading, #reward-heading { font-size: calc(var(--ui-font) * 2); }
#task-text, #reward-task { font-size: calc(var(--ui-font) * 2); }
.age-notice p, .age-actions button, #game-page .task-label,
#reward-page .task-label, #game-page .task-countdown,
#reward-page .task-countdown { font-size: var(--ui-font); }
.age-eyebrow, #game-summary, .input-error,
.ending-preview-controls button, #language-switcher button { font-size: calc(var(--ui-font) * .875); }
#duration-help, .mode-description, #difficulty-page .feedback-note,
.ending-preview-controls p, #language-switcher { font-size: calc(var(--ui-font) * .8125); }
#duration-input { font-size: max(16px, var(--ui-font)); }
#difficulty-page { --controls-width: min(100%, 390px); }
#difficulty-page .difficulty-options {
    width: var(--controls-width); margin-inline: auto;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(8px, 2.3vw, 12px); box-sizing: border-box;
}
#difficulty-page .difficulty-options button {
    min-width: 0; padding: 14px 6px; min-height: 48px;
    overflow-wrap: anywhere;
}
#difficulty-page .activity-modes {
    width: var(--controls-width); max-width: none; min-width: 0;
    box-sizing: border-box; padding: 12px clamp(8px, 2vw, 14px);
    gap: clamp(10px, 3vw, 20px);
}
.activity-modes label { gap: 6px; }
.activity-modes input[type="radio"] {
    width: clamp(28px, 6.5vw, 36px); height: clamp(28px, 6.5vw, 36px);
    flex-basis: clamp(28px, 6.5vw, 36px);
}
