* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --background: #FAFAFA;
    --text: #111111;
    --muted: #767676;
    --border: #E3E3E0;
    --card: #FFFFFF;
    --accent: #4F46E5;
}

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

html {
    background: var(--background);
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    background: var(--background);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button {
    font: inherit;
}

button:focus-visible {
    outline: 3px solid rgba(79, 70, 229, 0.28);
    outline-offset: 3px;
}

.app {
    width: 100%;
    min-height: 100dvh;
}

.screen {
    display: none;
    width: 100%;
    min-height: 100dvh;
}

.screen.active {
    display: flex;
}

.eyebrow,
.setup-label,
.insight-eyebrow {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.primary-button,
.secondary-button {
    border-radius: 999px;
    border: none;
    cursor: pointer;
    min-height: 56px;
    padding: 16px 28px;
    font-size: 16px;
    font-weight: 700;
    transition:
        transform 120ms ease,
        background-color 160ms ease,
        color 160ms ease,
        border-color 160ms ease,
        opacity 160ms ease;
    -webkit-tap-highlight-color: transparent;
}

.primary-button {
    background: var(--accent);
    color: #FFFFFF;
}

.primary-button:hover {
    background: #4338CA;
}

.primary-button:active,
.secondary-button:active {
    transform: scale(0.975);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.secondary-button {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.secondary-button:hover {
    border-color: #BBBBB7;
}

#intro-screen {
    align-items: center;
    justify-content: center;
    padding:
        max(28px, env(safe-area-inset-top))
        24px
        max(28px, env(safe-area-inset-bottom));
}

.intro-content {
    width: min(100%, 620px);
    text-align: center;
}

#intro-screen .eyebrow {
    margin-bottom: 20px;
}

h1 {
    font-size: clamp(52px, 13vw, 92px);
    line-height: 0.94;
    letter-spacing: -0.06em;
    font-weight: 800;
}

.intro-description {
    max-width: 470px;
    margin: 28px auto 30px;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.55;
}

#start-btn {
    min-width: min(100%, 250px);
}

.intro-meta {
    margin-top: 18px;
    color: var(--muted);
    font-size: 13px;
}

#setup-screen,
#insight-screen,
#calculation-screen {
    align-items: center;
    justify-content: center;
    padding:
        max(28px, env(safe-area-inset-top))
        24px
        max(28px, env(safe-area-inset-bottom));
}

.setup-content,
.insight-content,
.calculation-content {
    width: min(100%, 620px);
    text-align: center;
}

.setup-progress-track {
    width: min(100%, 560px);
    height: 5px;
    margin: 22px auto 28px;
    overflow: hidden;
    background: var(--border);
    border-radius: 999px;
}

.setup-progress-bar {
    width: 10%;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    transition: width 1200ms ease;
}

.setup-content h2,
.insight-content h2,
.calculation-content h2 {
    max-width: 580px;
    margin: 0 auto;
    font-size: clamp(30px, 7vw, 52px);
    line-height: 1;
    letter-spacing: -0.045em;
    font-weight: 780;
}

.setup-content p,
.calculation-content p,
.insight-subtext {
    max-width: 430px;
    margin: 18px auto 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.55;
}

.insight-dot {
    width: 12px;
    height: 12px;
    margin: 22px auto;
    border-radius: 50%;
    background: var(--accent);
    animation: insight-pulse 1.4s infinite;
}

.calculation-spinner {
    width: 36px;
    height: 36px;
    margin: 22px auto;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

#quiz-screen {
    flex-direction: column;
    min-height: 100dvh;
}

.quiz-header {
    width: 100%;
    flex: 0 0 15dvh;
    padding:
        max(18px, env(safe-area-inset-top))
        clamp(18px, 3vw, 40px)
        0;
}

.progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    letter-spacing: 0.02em;
    margin-bottom: 12px;
}

#question-progress {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

#question-category {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 11px;
    font-weight: 750;
}

.progress-track {
    width: 100%;
    height: 5px;
    overflow: hidden;
    background: var(--border);
    border-radius: 999px;
}

.progress-bar {
    width: 13.64%;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-status {
    min-height: 20px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.question-container {
    width: 100%;
    max-width: 760px;
    min-height: 85dvh;
    margin: -2dvh auto 0;
    padding:
        0
        clamp(20px, 4vw, 40px)
        max(28px, env(safe-area-inset-bottom));
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
}

.question-stage {
    width: 100%;
}

.question-stage.entering {
    animation: question-enter 250ms ease both;
}

.question-stage.leaving {
    animation: question-leave 250ms ease both;
}

.question-container h2 {
    max-width: 680px;
    margin: 0 auto 34px;
    font-size: clamp(1.75rem, 1.2rem + 2.75vw, 2.5rem);
    line-height: 1.05;
    letter-spacing: -0.045em;
    font-weight: 790;
    text-wrap: balance;
}

.answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.answer-button {
    width: 100%;
    min-height: 56px;
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--card);
    color: var(--text);
    text-align: left;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition:
        transform 100ms ease,
        background-color 100ms ease,
        color 100ms ease,
        border-color 100ms ease;
    -webkit-tap-highlight-color: transparent;
}

.answer-button:hover {
    border-color: #B8B8B3;
}

.answer-button:active {
    transform: scale(0.99);
}

.answer-button.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
}

.answer-button:disabled {
    cursor: default;
}

#result-screen {
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding:
        max(28px, env(safe-area-inset-top))
        24px
        max(32px, env(safe-area-inset-bottom));
}

.result-content {
    width: min(100%, 660px);
    padding: clamp(34px, 6vw, 68px) 0 10px;
    text-align: center;
}

.result-content .eyebrow {
    margin-bottom: 16px;
}

.rarity-number {
    display: flex;
    align-items: baseline;
    justify-content: center;
    margin-bottom: 18px;
    color: var(--accent);
    line-height: 0.88;
    letter-spacing: -0.08em;
    font-size: clamp(88px, 24vw, 180px);
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

.rarity-number span:last-child {
    font-size: 0.38em;
    letter-spacing: -0.04em;
    margin-left: 5px;
}

.result-content h2 {
    max-width: 620px;
    margin: 0 auto;
    font-size: clamp(30px, 7vw, 52px);
    line-height: 0.98;
    letter-spacing: -0.05em;
    font-weight: 800;
    text-wrap: balance;
}

.result-content > p {
    max-width: 520px;
    margin: 18px auto 26px;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.55;
}

.result-insight {
    max-width: 560px;
    margin: 0 auto 30px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.72);
    text-align: left;
}

.result-insight-label {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.result-insight p {
    font-size: 15px;
    line-height: 1.55;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    margin: 0 auto;
}

.ad-slot {
    min-height: 250px;
    max-width: 560px;
    margin: 28px auto 0;
    padding: 12px;
    border-radius: 18px;
    background: #F2F2EF;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.ad-label {
    color: #A0A09B;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.result-footnote {
    max-width: 560px;
    margin: 14px auto 0 !important;
    color: #9A9A95 !important;
    font-size: 11px !important;
    line-height: 1.5 !important;
}

@keyframes question-leave {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-18px); }
}

@keyframes question-enter {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes insight-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.22);
    }
    50% {
        transform: scale(1.12);
        box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 768px) {
    #intro-screen,
    #setup-screen,
    #insight-screen,
    #calculation-screen,
    #result-screen {
        padding-left: 40px;
        padding-right: 40px;
    }

    .answer-button {
        min-height: 64px;
        padding: 18px 22px;
        font-size: 17px;
    }

    .result-actions {
        flex-direction: row;
        max-width: 560px;
    }

    .result-actions .primary-button,
    .result-actions .secondary-button {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}
