:root {
    --quiz-bg: #170535;
    --quiz-panel: rgba(22, 19, 34, 0.84);
    --quiz-panel-border: rgba(247, 248, 246, 0.14);
    --quiz-text: #f7f8f6;
    --quiz-muted: #b9c2bc;
    --quiz-accent-top: #c2deca;
    --quiz-accent-bottom: #a3ceaf;
    --quiz-accent-text: #1a3022;
    --quiz-accent-line: #8fc6a0;
    --quiz-correct: #6fcf8a;
    --quiz-half: #f2c94c;
    --quiz-wrong: #f19c8c;
    --quiz-radius: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    background: radial-gradient(circle at 50% 30%, #2a1356 0%, var(--quiz-bg) 70%);
    color: var(--quiz-text);
    font-family: 'Open Sans', 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

.quiz-hidden {
    display: none !important;
}

.quiz-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* 3D stage */

.quiz-canvas {
    position: fixed;
    inset: 0;
    transition: filter 600ms ease, opacity 600ms ease;
}

.quiz-canvas canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.quiz-canvas-dimmed {
    filter: blur(4px) brightness(0.55);
    pointer-events: none;
}

.quiz-loading {
    position: fixed;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    text-align: center;
    pointer-events: none;
}

.quiz-spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 12px;
    border: 2px solid rgba(247, 248, 246, 0.18);
    border-top-color: var(--quiz-text);
    border-radius: 50%;
    animation: quiz-spin 0.8s linear infinite;
}

.quiz-loading-text {
    margin: 0;
    font-size: 13px;
    color: var(--quiz-muted);
}

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

/* Shared panel and controls */

.quiz-card {
    position: fixed;
    z-index: 2;
    border: 1px solid var(--quiz-panel-border);
    border-radius: var(--quiz-radius);
    background: var(--quiz-panel);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.quiz-eyebrow {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--quiz-accent-line);
}

.quiz-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.quiz-actions-split {
    flex-direction: row;
    flex-wrap: wrap;
}

.quiz-actions-split > * {
    flex: 1 1 auto;
}

.quiz-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
}

.quiz-btn:active {
    transform: translateY(1px);
}

.quiz-btn-primary {
    background: linear-gradient(180deg, var(--quiz-accent-top) 0%, var(--quiz-accent-bottom) 100%);
    color: var(--quiz-accent-text);
    box-shadow: inset 0 0 0 1px rgba(55, 130, 85, 0.5);
}

.quiz-btn-secondary {
    background: rgba(247, 248, 246, 0.08);
    color: var(--quiz-text);
    box-shadow: inset 0 0 0 1px var(--quiz-panel-border);
}

@media (hover: hover) {
    .quiz-btn-primary:hover {
        filter: brightness(1.06);
    }

    .quiz-btn-secondary:hover {
        background: rgba(247, 248, 246, 0.14);
    }
}

.quiz-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.quiz-text-btn {
    padding: 4px 2px;
    border: none;
    background: none;
    color: var(--quiz-muted);
    font: inherit;
    font-size: 13px;
    text-decoration: underline;
    text-decoration-color: rgba(185, 194, 188, 0.4);
    text-underline-offset: 3px;
    cursor: pointer;
}

.quiz-text-btn:hover {
    color: var(--quiz-text);
}

.quiz-link {
    font-size: 13px;
    color: var(--quiz-accent-line);
    text-decoration: underline;
    text-decoration-color: rgba(143, 198, 160, 0.4);
    text-underline-offset: 3px;
}

.quiz-aside {
    font-size: 13px;
    line-height: 1.5;
    color: var(--quiz-muted);
}

.quiz-link:hover {
    color: var(--quiz-accent-top);
}

/* Intro */

.quiz-intro,
.quiz-results {
    top: 50%;
    left: 50%;
    width: min(520px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    overflow-y: auto;
    transform: translate(-50%, -50%);
    padding: 28px;
}

.quiz-results {
    text-align: center;
}

.quiz-intro .quiz-actions {
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.quiz-title {
    margin: 0 0 6px;
    font-size: 28px;
    line-height: 1.2;
}

.quiz-subtitle {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--quiz-accent-top);
}

.quiz-lede {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--quiz-muted);
}

.quiz-rules {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.quiz-rules li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.quiz-rule-icon {
    flex: 0 0 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(143, 198, 160, 0.16);
    color: var(--quiz-accent-top);
    font-size: 13px;
}

/* Top bar */

.quiz-topbar {
    position: fixed;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    pointer-events: none;
}

.quiz-brand,
.quiz-progress {
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--quiz-panel-border);
    border-radius: 8px;
    background: rgba(22, 19, 34, 0.76);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-size: 13px;
    font-weight: 700;
}

.quiz-progress {
    gap: 12px;
}

.quiz-dots {
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.quiz-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(247, 248, 246, 0.18);
}

.quiz-dot-current {
    box-shadow: 0 0 0 2px var(--quiz-text);
}

.quiz-dot-correct {
    background: var(--quiz-correct);
}

.quiz-dot-half {
    background: var(--quiz-half);
}

.quiz-dot-wrong {
    background: rgba(247, 248, 246, 0.42);
}

.quiz-score {
    font-weight: 600;
    color: var(--quiz-muted);
}

.quiz-score strong {
    color: var(--quiz-text);
}

/* Question */

.quiz-question {
    left: 50%;
    bottom: calc(16px + var(--quiz-keyboard-inset, 0px));
    width: min(480px, calc(100% - 24px));
    transform: translateX(-50%);
    padding: 16px;
}

.quiz-question-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.quiz-question-header .quiz-eyebrow {
    margin: 0;
}

.quiz-question-heading {
    margin: 0;
    font-size: 17px;
}

.quiz-feedback {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-left: 3px solid var(--quiz-half);
    border-radius: 6px;
    background: rgba(242, 201, 76, 0.1);
    font-size: 13px;
    line-height: 1.5;
}

.quiz-feedback strong {
    display: block;
    margin-bottom: 2px;
}

.quiz-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.quiz-input {
    min-width: 0;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid rgba(247, 248, 246, 0.22);
    border-radius: 10px;
    background: rgba(247, 248, 246, 0.94);
    color: #1b241e;
    font: inherit;
    font-size: 16px;
}

.quiz-input:focus {
    outline: 2px solid var(--quiz-accent-line);
    outline-offset: 1px;
}

.quiz-input-shake {
    animation: quiz-shake 360ms ease;
}

@keyframes quiz-shake {
    20%, 60% {
        transform: translateX(-5px);
    }

    40%, 80% {
        transform: translateX(5px);
    }
}

.quiz-question-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.quiz-help {
    font-size: 12px;
    color: var(--quiz-muted);
}

/* Reveal */

.quiz-reveal {
    left: 50%;
    bottom: 12px;
    width: min(480px, calc(100% - 24px));
    max-height: calc(100% - 64px);
    display: flex;
    flex-direction: column;
    transform: translateX(-50%);
    padding: 16px;
    animation: quiz-rise 320ms ease;
}

.quiz-reveal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.quiz-reveal .quiz-actions {
    flex: 0 0 auto;
    margin-top: 14px;
}

.quiz-label-short {
    display: none;
}

@keyframes quiz-rise {
    from {
        opacity: 0;
        transform: translate(-50%, 16px);
    }
}

.quiz-reveal-result {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
}

.quiz-reveal-result-correct {
    color: var(--quiz-correct);
}

.quiz-reveal-result-half {
    color: var(--quiz-half);
}

.quiz-reveal-result-wrong {
    color: var(--quiz-wrong);
}

.quiz-photo {
    position: relative;
    margin: 0 0 14px;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(247, 248, 246, 0.06);
    aspect-ratio: 3 / 2;
}

.quiz-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.quiz-photo-credit {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 18px 10px 6px;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.6));
    font-size: 10px;
    text-align: right;
    color: rgba(247, 248, 246, 0.85);
}

.quiz-photo-credit a {
    color: inherit;
}

.quiz-reveal-name {
    margin: 0 0 8px;
    font-size: 22px;
    line-height: 1.2;
}

.quiz-reveal-blurb {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--quiz-muted);
}

/* Results */

.quiz-results-score {
    margin: 0 0 6px;
    font-size: 40px;
    line-height: 1.1;
}

.quiz-results-emoji {
    margin: 0 0 12px;
    font-size: 26px;
    letter-spacing: 4px;
}

.quiz-results-verdict {
    margin: 0 0 18px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--quiz-muted);
}

.quiz-results-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.quiz-results-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(247, 248, 246, 0.06);
    font-size: 14px;
}

.quiz-results-list a {
    margin-left: auto;
    font-size: 12px;
    color: var(--quiz-accent-line);
}

.quiz-share-status {
    min-height: 18px;
    margin: -4px 0 0;
    font-size: 12px;
    color: var(--quiz-accent-line);
}

/* Error */

.quiz-error {
    top: 50%;
    left: 50%;
    width: min(360px, calc(100% - 32px));
    transform: translate(-50%, -50%);
    padding: 20px;
    text-align: center;
}

.quiz-error-text {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.5;
}

/* Wide screens: dock the reveal to the side so the landscape stays in view */

@media (min-width: 900px) {
    .quiz-canvas-beside-panel {
        right: 432px;
    }

    .quiz-reveal {
        top: 64px;
        right: 16px;
        bottom: auto;
        left: auto;
        width: 400px;
        max-height: calc(100% - 80px);
        transform: none;
        animation-name: quiz-slide;
    }

    @keyframes quiz-slide {
        from {
            opacity: 0;
            transform: translateX(16px);
        }
    }
}

@media (max-width: 480px) {
    .quiz-intro,
    .quiz-results {
        padding: 22px 18px;
    }

    .quiz-title {
        font-size: 24px;
    }

    .quiz-subtitle {
        font-size: 15px;
    }

    .quiz-reveal {
        padding: 14px;
    }

    .quiz-reveal-result {
        margin-bottom: 10px;
        font-size: 14px;
    }

    .quiz-photo {
        margin-bottom: 10px;
        aspect-ratio: 16 / 9;
    }

    .quiz-reveal-name {
        margin-bottom: 6px;
        font-size: 19px;
    }

    .quiz-reveal-blurb {
        font-size: 13px;
        line-height: 1.5;
    }

    .quiz-reveal .quiz-actions {
        flex-wrap: nowrap;
        gap: 8px;
        margin-top: 12px;
    }

    .quiz-reveal .quiz-actions > * {
        flex: 1 1 0;
        padding: 0 10px;
        white-space: nowrap;
    }

    .quiz-label-long {
        display: none;
    }

    .quiz-label-short {
        display: inline;
    }

    /* Keep up to ten result squares on one line, and the list compact */
    .quiz-results-emoji {
        font-size: 20px;
        letter-spacing: 2px;
        white-space: nowrap;
    }

    .quiz-results-list {
        gap: 4px;
    }

    .quiz-results-list li {
        padding: 6px 10px;
        font-size: 13px;
    }

    .quiz-brand {
        display: none;
    }

    .quiz-topbar {
        justify-content: flex-end;
    }

    .quiz-help {
        display: none;
    }

    .quiz-question-footer {
        justify-content: flex-end;
    }
}
