@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Fredoka:wght@400;600;700&display=swap");

:root {
    --bg-top: #fcff8a;
    --bg-mid: #ff8ad4;
    --bg-bottom: #63ecff;
    --card: #fffef9;
    --ink: #1d263b;
    --accent: #ff6f3c;
    --accent-2: #009f93;
    --accent-3: #ffcb3c;
    --accent-4: #7a4dff;
    --correct: #1f9f4a;
    --wrong: #c0392b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Fredoka", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background: linear-gradient(160deg, var(--bg-top), var(--bg-mid) 44%, var(--bg-bottom));
    background-size: 260% 260%;
    animation: bg-spin 9s ease-in-out infinite alternate;
    overflow-x: hidden;
}

#app-layer {
    position: relative;
    z-index: 2;
}

#confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 6;
    overflow: hidden;
}

#fireworks-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    mix-blend-mode: screen;
}

.distraction-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    opacity: 0.32;
    background:
        repeating-linear-gradient(
            -55deg,
            rgba(255, 255, 255, 0.2) 0,
            rgba(255, 255, 255, 0.2) 8px,
            transparent 8px,
            transparent 18px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(122, 77, 255, 0.16) 0,
            rgba(122, 77, 255, 0.16) 2px,
            transparent 2px,
            transparent 10px
        );
    animation: sweep-overlay 3.2s linear infinite;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 18px;
    border-radius: 2px;
    opacity: 0.9;
    animation: confetti-fall linear forwards;
}

.party-lights {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 16%, rgba(255, 203, 60, 0.42), transparent 30%),
        radial-gradient(circle at 82% 21%, rgba(0, 159, 147, 0.35), transparent 31%),
        radial-gradient(circle at 22% 80%, rgba(255, 111, 60, 0.33), transparent 35%),
        radial-gradient(circle at 91% 74%, rgba(255, 255, 255, 0.4), transparent 25%);
    animation: drift 7s ease-in-out infinite alternate;
}

.page-shell {
    width: min(960px, 92vw);
    margin: 0 auto;
    padding: 2.2rem 0 3rem;
    position: relative;
    z-index: 2;
    animation: screen-shake 480ms steps(2, end) infinite;
}

.hero {
    text-align: center;
    padding: 0.5rem 0 1.3rem;
    animation: rise-in 700ms ease-out both, hero-bounce 2.8s ease-in-out infinite, stutter 0.9s steps(1, end) infinite;
}

.eyebrow {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9b4f28;
    margin: 0 0 0.4rem;
}

h1 {
    font-family: "Baloo 2", "Trebuchet MS", sans-serif;
    font-size: clamp(2rem, 6vw, 3.7rem);
    line-height: 1;
    margin: 0;
    text-shadow: 0 4px 0 rgba(255, 255, 255, 0.5), 0 10px 22px rgba(122, 77, 255, 0.35);
    animation: rainbow-text 5s linear infinite;
}

.hero-copy {
    max-width: 720px;
    margin: 0.8rem auto 1rem;
    font-size: clamp(1rem, 2.4vw, 1.2rem);
}

.quiz-card {
    background: var(--card);
    border-radius: 22px;
    padding: clamp(1rem, 3vw, 2rem);
    box-shadow: 0 20px 40px rgba(29, 38, 59, 0.15);
    border: 3px solid rgba(122, 77, 255, 0.25);
    animation: rise-in 850ms ease-out both, glow-card 2.4s ease-in-out infinite, card-tilt 5.5s ease-in-out infinite;
}

.quiz-top-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.progress,
.score-live {
    margin: 0 0 0.8rem;
    font-size: 0.95rem;
    color: #47506c;
    font-weight: 600;
}

.question {
    margin: 0 0 1rem;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    line-height: 1.3;
    animation: jitter 1.8s steps(1, end) infinite;
}

.options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.7rem;
}

.option-btn {
    width: 100%;
    border: 2px solid rgba(29, 38, 59, 0.18);
    background: linear-gradient(100deg, #fff, #fff3ce);
    color: var(--ink);
    text-align: left;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    font: inherit;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.option-btn:hover:not(:disabled) {
    transform: translateY(-4px) rotate(-0.8deg) scale(1.01);
    border-color: var(--accent-4);
    box-shadow: 0 12px 20px rgba(122, 77, 255, 0.25);
}

.option-btn.correct {
    background: rgba(31, 159, 74, 0.12);
    border-color: var(--correct);
}

.option-btn.wrong {
    background: rgba(192, 57, 43, 0.12);
    border-color: var(--wrong);
}

.option-btn:disabled {
    cursor: default;
}

.option-btn.clicked-drop {
    opacity: 0.2;
}

#fallen-options-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 20;
    overflow: hidden;
}

#pile-fire-layer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 0;
    pointer-events: none;
    z-index: 19;
    opacity: 0;
    transition: opacity 320ms ease;
}

#pile-fire-layer.fire-active {
    opacity: 1;
    height: 32vh;
    background:
        radial-gradient(ellipse at 10% 100%, rgba(255, 71, 20, 0.86), transparent 55%),
        radial-gradient(ellipse at 32% 100%, rgba(255, 168, 0, 0.88), transparent 54%),
        radial-gradient(ellipse at 52% 100%, rgba(255, 84, 9, 0.82), transparent 57%),
        radial-gradient(ellipse at 72% 100%, rgba(255, 189, 69, 0.86), transparent 56%),
        radial-gradient(ellipse at 91% 100%, rgba(255, 91, 0, 0.8), transparent 54%);
    animation: fire-flicker 200ms steps(2, end) infinite;
}

#smoke-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 21;
    opacity: 0;
    transition: opacity 500ms ease;
}

#smoke-layer.smoke-active {
    opacity: 0.95;
}

.smoke-puff {
    position: fixed;
    bottom: -60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(58, 58, 58, 0.75), rgba(58, 58, 58, 0));
    filter: blur(1.5px);
    animation: smoke-rise linear forwards;
}

.fallen-option {
    position: fixed;
    margin: 0;
    width: auto;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    will-change: transform;
}

.explanation {
    margin-top: 0.95rem;
    border-left: 4px solid var(--accent-2);
    background: rgba(0, 159, 147, 0.12);
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(120deg, var(--accent), var(--accent-4));
    animation: btn-pulse 1.2s ease-in-out infinite;
}

.btn-secondary {
    color: #102c3a;
    background: linear-gradient(120deg, var(--accent-3), #f3ff8f);
    margin-top: 0.7rem;
}

.score-line {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
}

.rank-line {
    margin-top: 0;
    font-weight: 600;
}

.footer-note {
    text-align: center;
    margin-top: 0.9rem;
    color: #5c3e34;
    font-size: 0.94rem;
}

.bunting {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    z-index: 1;
    pointer-events: none;
}

.bunting span {
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 32px solid var(--accent);
    animation: sway 1.4s ease-in-out infinite;
}

.bunting span:nth-child(3n) {
    border-top-color: var(--accent-2);
}

.bunting span:nth-child(4n) {
    border-top-color: var(--accent-3);
}

.hidden {
    display: none;
}

.chaos-shapes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.chaos-shapes span {
    position: absolute;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    opacity: 0.26;
    filter: blur(1px);
    animation: float-chaos 11s linear infinite;
}

.chaos-shapes span:nth-child(1) {
    top: 14%;
    left: 10%;
    background: #fcff4c;
}

.chaos-shapes span:nth-child(2) {
    top: 30%;
    left: 80%;
    background: #ff4ca1;
    animation-duration: 9s;
}

.chaos-shapes span:nth-child(3) {
    top: 70%;
    left: 12%;
    background: #4cf7ff;
    animation-duration: 13s;
}

.chaos-shapes span:nth-child(4) {
    top: 74%;
    left: 70%;
    background: #8d65ff;
    animation-duration: 10s;
}

.chaos-shapes span:nth-child(5) {
    top: 45%;
    left: 48%;
    background: #ff964c;
    animation-duration: 12s;
}

.chaos-shapes span:nth-child(odd) {
    border-radius: 20%;
}

@keyframes sway {
    0%,
    100% {
        transform: rotate(-3deg);
    }
    50% {
        transform: rotate(3deg);
    }
}

@keyframes drift {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-18px);
    }
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-20vh) rotate(0deg);
    }
    100% {
        transform: translateY(120vh) rotate(720deg);
    }
}

@keyframes bg-spin {
    from {
        background-position: 0% 20%;
    }
    to {
        background-position: 100% 80%;
    }
}

@keyframes hero-bounce {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

@keyframes wobble {
    0%,
    100% {
        transform: rotate(-2deg);
    }
    50% {
        transform: rotate(2deg) translateY(-2px);
    }
}

@keyframes glow-card {
    0%,
    100% {
        box-shadow: 0 20px 40px rgba(29, 38, 59, 0.15);
    }
    50% {
        box-shadow: 0 24px 44px rgba(122, 77, 255, 0.28);
    }
}

@keyframes sweep-overlay {
    0% {
        transform: translateX(-16px);
        opacity: 0.28;
    }
    50% {
        transform: translateX(12px);
        opacity: 0.36;
    }
    100% {
        transform: translateX(-16px);
        opacity: 0.28;
    }
}

@keyframes fire-flicker {
    0%,
    100% {
        transform: translateY(0) scaleY(1);
        filter: saturate(1);
    }
    50% {
        transform: translateY(-3px) scaleY(1.08);
        filter: saturate(1.15);
    }
}

@keyframes smoke-rise {
    0% {
        transform: translateY(0) scale(0.75);
        opacity: 0;
    }
    12% {
        opacity: 0.52;
    }
    65% {
        opacity: 0.36;
    }
    100% {
        transform: translateY(-115vh) scale(2.4);
        opacity: 0;
    }
}

@keyframes stutter {
    0%,
    90%,
    100% {
        filter: hue-rotate(0deg);
    }
    92% {
        filter: hue-rotate(16deg);
    }
    95% {
        filter: hue-rotate(-14deg);
    }
}

@keyframes card-tilt {
    0%,
    100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(0.35deg);
    }
    50% {
        transform: rotate(-0.3deg);
    }
    75% {
        transform: rotate(0.2deg);
    }
}

@keyframes screen-shake {
    0%,
    100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(0.7px, -0.7px);
    }
    50% {
        transform: translate(-0.8px, 0.6px);
    }
    75% {
        transform: translate(0.6px, 0.8px);
    }
}

@keyframes rainbow-text {
    0% {
        color: #ff6f3c;
    }
    25% {
        color: #7a4dff;
    }
    50% {
        color: #009f93;
    }
    75% {
        color: #f39c12;
    }
    100% {
        color: #ff6f3c;
    }
}

@keyframes btn-pulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.04);
    }
}

@keyframes jitter {
    0%,
    100% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(1px);
    }
    40% {
        transform: translateX(-1px);
    }
    60% {
        transform: translateX(2px);
    }
    80% {
        transform: translateX(-2px);
    }
}

@keyframes float-chaos {
    0% {
        transform: translateY(0) translateX(0) scale(1);
    }
    25% {
        transform: translateY(-24px) translateX(10px) scale(1.12);
    }
    50% {
        transform: translateY(4px) translateX(-12px) scale(0.95);
    }
    75% {
        transform: translateY(-8px) translateX(18px) scale(1.08);
    }
    100% {
        transform: translateY(0) translateX(0) scale(1);
    }
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .page-shell {
        width: 94vw;
    }

    .quiz-top-row {
        flex-direction: column;
        gap: 0.15rem;
    }

    .chaos-shapes span {
        width: 54px;
        height: 54px;
    }
}