@font-face {
    font-family: Archivo;
    src: url('../../assets/fonts/archivo-latin.woff2') format('woff2');
    font-weight: 500 800;
    font-display: swap;
}

@font-face {
    font-family: Inter;
    src: url('../../assets/fonts/inter-latin.woff2') format('woff2');
    font-weight: 400 800;
    font-display: swap;
}

:root {
    font-family: Inter, sans-serif;
    color: #1e2a3f;
    background: #eef5ff;
    --purple: #5951d4;
    --green: #166534;
    --red: #b42332;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

[hidden] {
    display: none !important;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 3px solid #255ba7;
    outline-offset: 5px;
}

/* Shell e topo */
.app-shell {
    max-width: 1320px;
    padding: 24px;
    margin: auto;
    min-height: 100svh;
}

.screen-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-link__logo {
    display: block;
    width: clamp(160px, 22vw, 240px);
}

.back-badge {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 15px;
    background: #ffffffd1;
    color: #1172b0;
    box-shadow: 0 10px 22px #0a456d24;
}

.back-badge svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.top-actions {
    display: flex;
    gap: 12px;
}

.utility {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 16px;
    background: #ffffffd9;
    box-shadow: 0 8px 22px #30477712;
}

.utility img {
    width: 27px;
    height: 27px;
    object-fit: contain;
}

/* Título e placar */
.heading-row {
    margin: 30px 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

h1 {
    font: 800 clamp(1.25rem, 2.3vw, 1.85rem) Archivo, sans-serif;
    margin: 0;
}

h2 {
    font: 800 clamp(1.35rem, 2.5vw, 2rem)/1.2 Archivo, sans-serif;
    margin: 0 0 24px;
}

h2:focus {
    outline: none;
}

.score {
    display: flex;
    gap: 18px;
    font-size: .78rem;
    font-weight: 800;
    color: #526079;
    margin: 0;
    white-space: nowrap;
}

.score span+span {
    color: var(--purple);
}

/* Pergunta: imagem + painel de respostas */
.question {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    align-items: center;
    gap: 48px;
}

.reading {
    min-width: 0;
    text-align: center;
}

.image-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
}

.image-button img {
    display: block;
    width: 100%;
    height: min(70vh, 780px);
    object-fit: contain;
    filter: drop-shadow(0 12px 14px #34466c14);
}

.zoom-button {
    border: 0;
    background: none;
    color: #4653a0;
    font-size: .75rem;
    font-weight: 800;
    padding: 12px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.zoom-button:disabled {
    visibility: hidden;
}

.zoom-button img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

#loadStatus {
    font-size: .8rem;
    font-weight: 700;
    color: #526079;
}

.answer-panel {
    min-width: 0;
    padding: 12px 4px;
}

.options {
    display: grid;
    gap: 12px;
}

.option {
    display: flex;
    align-items: center;
    text-align: left;
    gap: 16px;
    min-height: 78px;
    padding: 16px 20px;
    border: 2px solid #c8d3ef;
    border-radius: 20px;
    background: #ffffffc9;
    color: #253451;
    font-weight: 800;
    font-size: clamp(1rem, 1.7vw, 1.35rem);
    transition: background .2s, border-color .2s, transform .2s;
    position: relative;
}

.option:not(:disabled):hover {
    border-color: var(--purple);
    background: #fff;
    transform: translateY(-2px);
}

.letter {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #ebeafd;
    color: var(--purple);
}

.answer-label {
    flex: 1;
}

.answer-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.option.eliminated {
    background: #fbe8ec;
    border-color: #d7929d;
    color: #8d2635;
    opacity: .65;
    text-decoration: line-through;
}

.option.correct {
    background: #dcfce7;
    border-color: #25864c;
    color: #14532d;
    box-shadow: 0 0 0 5px #35b76d1c;
}

.option.correct .letter {
    background: #168045;
    color: white;
}

.option.muted {
    opacity: .35;
}

.option.eliminated .letter {
    background: #f5cfd5;
    color: #8d2635;
}

/* Mascote e mensagem de feedback */
.helper {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 22px;
    min-height: 112px;
}

.mascot {
    width: 100px;
    height: 112px;
    object-fit: contain;
    flex-shrink: 0;
}

.feedback strong {
    font: 800 1rem Archivo, sans-serif;
}

.feedback p {
    font-size: .8rem;
    line-height: 1.65;
    font-weight: 600;
    margin: 8px 0 0;
    color: #526079;
}

.feedback.success strong {
    color: var(--green);
}

.feedback.error strong {
    color: var(--red);
}

.advance-note {
    text-align: center;
    font-size: .75rem;
    font-weight: 700;
    color: #526079;
    min-height: 20px;
    margin: 10px 0;
}

/* Variante "wide" (quadrinhos/tirinhas horizontais) */
.question.wide {
    grid-template-columns: 1fr;
    gap: 16px;
}

.wide .image-button img {
    height: auto;
    max-height: 370px;
}

.wide .answer-panel {
    max-width: 1160px;
    width: 100%;
    margin: auto;
}

.wide h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.wide .options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wide .option {
    font-size: 1rem;
    padding: 14px 12px;
    gap: 10px;
}

.wide .helper {
    justify-content: center;
    min-height: 85px;
    margin-top: 14px;
}

.wide .mascot {
    width: 72px;
    height: 85px;
}

.wide .feedback {
    max-width: 620px;
}

/* Animações de acerto/erro */
.question.celebrating .correct {
    animation: answer-glow 1s ease-in-out 5;
}

.question.celebrating .mascot {
    animation: happy .75s ease-in-out 6;
}

.shake {
    animation: shake .38s ease-in-out;
}

@keyframes answer-glow {
    50% {
        box-shadow: 0 0 0 8px #35b76d25;
        transform: scale(1.018);
    }
}

@keyframes happy {
    50% {
        transform: translateY(-12px) rotate(-4deg);
    }
}

@keyframes shake {

    25%,
    75% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }
}

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

#confetti i {
    position: absolute;
    left: var(--x);
    top: -20px;
    width: 9px;
    height: 14px;
    background: var(--color);
    border-radius: 3px;
    animation: fall 3.8s var(--delay) ease-in forwards;
}

@keyframes fall {
    to {
        transform: translateY(105vh) rotate(600deg);
        opacity: 0;
    }
}

/* Diálogo de texto ampliado */
dialog {
    border: 0;
    border-radius: 20px;
    padding: 60px 20px 20px;
    width: min(1100px, 96vw);
    max-height: 94svh;
    background: #eef5ff;
    color: #1e2a3f;
}

dialog::backdrop {
    background: #15233dd1;
}

dialog>img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: auto;
}

.close-zoom {
    position: sticky;
    top: 0;
    float: right;
    margin-top: -48px;
    z-index: 1;
}

dialog details {
    margin-top: 20px;
}

dialog summary {
    font-weight: 800;
    cursor: pointer;
    min-height: 44px;
}

dialog details p {
    white-space: pre-wrap;
    line-height: 1.8;
}

body:has(dialog[open]) {
    overflow: hidden;
}

/* Introdução: player nativo, carregado apenas ao escolher assistir. */
.intro-dialog {
    width: min(960px, calc(100vw - 32px));
    max-height: calc(100svh - 32px);
    padding: clamp(14px, 3vw, 24px);
    box-shadow: 0 20px 80px #10284c40;
}

.intro-dialog h2 {
    font-size: clamp(1rem, 3vw, 1.35rem);
    margin: 0 0 14px;
}

.intro-player {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: #182438;
}

.intro-player video {
    display: block;
    width: 100%;
    max-height: calc(100svh - 210px);
    aspect-ratio: 16 / 9;
    object-fit: contain;
}

.intro-play {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 0;
    border-radius: 999px;
    padding: 12px 22px;
    background: #fff;
    color: #162b50;
    font-weight: 800;
    box-shadow: 0 6px 28px #10284c40;
}

.intro-play img {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.intro-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}

.intro-footer p {
    flex: 1 1 220px;
    margin: 0;
    font-size: .8rem;
    line-height: 1.5;
    color: #445776;
}

.intro-skip {
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    background: #5144ca;
    color: #fff;
    font-weight: 800;
}

/* Telas menores */
@media (max-width: 800px) {
    .app-shell {
        padding: 18px;
    }

    .question {
        gap: 24px;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .option {
        padding: 12px;
        gap: 10px;
        min-height: 68px;
    }

    .letter {
        width: 30px;
        height: 30px;
    }

    .wide .options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .helper {
        gap: 10px;
    }

    .mascot {
        width: 68px;
        height: 90px;
    }

    .score {
        gap: 10px;
    }
}

@media (max-width: 600px) {
    .app-shell {
        padding: 16px;
    }

    .brand-link__logo {
        width: 145px;
    }

    .brand-link {
        gap: 6px;
    }

    .top-actions {
        gap: 8px;
    }

    .utility {
        width: 40px;
        height: 40px;
    }

    .back-badge {
        width: 36px;
        height: 40px;
    }

    .heading-row {
        margin: 24px 0 18px;
        display: block;
    }

    h1 {
        font-size: 1.25rem;
    }

    .score {
        margin-top: 10px;
        font-size: .72rem;
    }

    .question {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .image-button img {
        height: auto;
        max-height: 62svh;
    }

    .answer-panel {
        padding: 0;
    }

    .answer-panel h2 {
        font-size: 1.25rem;
        text-align: center;
        margin-bottom: 16px;
    }

    .options {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .option {
        font-size: .85rem;
        border-radius: 16px;
        min-height: 72px;
        padding: 10px;
        gap: 8px;
    }

    .answer-icon {
        width: 22px;
        height: 22px;
    }

    .letter {
        width: 26px;
        height: 26px;
        font-size: .85rem;
    }

    .helper {
        margin-top: 16px;
        min-height: 85px;
        justify-content: center;
    }

    .feedback {
        max-width: 290px;
    }

    .feedback p {
        font-size: .72rem;
    }

    .feedback strong {
        font-size: .9rem;
    }

    .wide .option {
        font-size: .85rem;
    }

    .wide .image-button img {
        max-height: none;
    }
}

/* Telas baixas (notebook/paisagem) */
@media (min-width: 601px) and (max-height: 820px) {
    .app-shell {
        padding: 18px 24px;
    }

    .brand-link__logo {
        width: 190px;
    }

    .heading-row {
        margin: 18px 0;
    }

    .question {
        gap: 32px;
    }

    .image-button img {
        height: calc(100svh - 200px);
    }

    h2 {
        font-size: 1.45rem;
        margin-bottom: 18px;
    }

    .option {
        min-height: 62px;
        padding: 10px 14px;
        font-size: 1rem;
    }

    .letter {
        width: 32px;
        height: 32px;
    }

    .helper {
        margin-top: 16px;
        min-height: 80px;
    }

    .mascot {
        width: 70px;
        height: 80px;
    }

    .feedback strong {
        font-size: .9rem;
    }

    .feedback p {
        font-size: .74rem;
    }

    .wide .image-button img {
        height: auto;
        max-height: 300px;
    }

    .wide .helper {
        min-height: 65px;
    }

    .wide .mascot {
        height: 65px;
    }

    .advance-note {
        margin: 4px 0;
    }
}

/* Preserve breathing room below the physical screen edge in fullscreen. */
html:fullscreen {
    overflow-y: auto;
    background: #eef5ff;
    scroll-padding-top: 32px;
}

html:fullscreen .app-shell {
    padding-top: max(36px, env(safe-area-inset-top));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
}

html:fullscreen .screen-topbar {
    margin-bottom: 8px;
}

html:fullscreen .image-button img {
    height: min(65vh, 740px);
}

html:fullscreen .wide .image-button img {
    height: auto;
    max-height: 340px;
}

@media (min-width: 601px) and (max-height: 820px) {
    html:fullscreen .image-button img {
        height: calc(100svh - 250px);
    }

    html:fullscreen .wide .image-button img {
        height: auto;
        max-height: 260px;
    }
}

@media (max-width: 600px) {
    html:fullscreen .app-shell {
        padding-top: max(24px, env(safe-area-inset-top));
    }

    html:fullscreen .image-button img {
        height: auto;
        max-height: 60svh;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }

    #confetti {
        display: none;
    }
}
