/* ================================================================
   A Menina da Lanterna — interface
   Paleta: índigo da noite, ouro da chama, coral do casaco, pêssego do sol.
   ================================================================ */

:root {
    --ink: oklch(12% 0.04 270);
    --ink-deep: oklch(8% 0.035 270);
    --parchment: oklch(93% 0.04 85);
    --gold: oklch(82% 0.15 78);
    --gold-deep: oklch(64% 0.14 62);
    --coral: oklch(62% 0.16 32);
    --ember: oklch(68% 0.18 48);
    --blood: oklch(54% 0.18 22);

    --text: oklch(96% 0.02 85);
    --text-soft: oklch(82% 0.03 80);
    --text-dim: oklch(64% 0.03 270);

    --panel: color-mix(in oklab, oklch(16% 0.04 270) 66%, transparent);
    --panel-strong: color-mix(in oklab, oklch(11% 0.04 270) 86%, transparent);
    --line: color-mix(in oklab, var(--gold) 32%, transparent);
    --line-soft: color-mix(in oklab, var(--parchment) 12%, transparent);

    --radius: 14px;
    --radius-lg: 22px;
    --blur: 20px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: clip;
    overscroll-behavior: none;
    background: var(--ink-deep);
}

body {
    min-height: 100dvh;
    color: var(--text);
    font-family: 'Nunito', system-ui, sans-serif;
    user-select: none;
    touch-action: none;
}

button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

.mono {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
}

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

.game-shell {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% 0%, oklch(22% 0.06 270) 0%, var(--ink-deep) 70%);
}

#scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.fade {
    position: absolute;
    inset: 0;
    z-index: 25;
    background: #05040a;
    opacity: 0;
    pointer-events: none;
}

.vignette {
    position: absolute;
    inset: 0;
    z-index: 18;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at 50% 50%, transparent 38%, oklch(12% 0.1 280 / 0.88) 100%);
    transition: opacity 0.3s ease;
}

.hit-flash {
    position: absolute;
    inset: 0;
    z-index: 19;
    pointer-events: none;
    background: oklch(55% 0.22 32 / 0.38);
    opacity: 0;
}

.hit-flash.is-on { animation: hitFlash 0.45s ease-out; }

@keyframes hitFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.game-shell > header {
    position: absolute;
    top: calc(0.9rem + var(--safe-top));
    left: calc(1rem + var(--safe-left));
    right: calc(1rem + var(--safe-right));
    z-index: 40;
    margin: 0;
    padding: 0;
    max-width: none;
    width: auto;
    pointer-events: none;
    gap: 0.6rem;
}

.game-shell > header > * { pointer-events: auto; }

.game-shell > header .back-link {
    background: var(--panel-strong);
    backdrop-filter: blur(var(--blur));
    border-color: var(--line);
    color: var(--text-soft);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.game-shell > header .back-link:hover {
    color: var(--gold);
    border-color: var(--gold);
}

.game-shell > header .app-logo {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 1.05rem;
    color: var(--parchment);
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 1.35rem;
    height: 1.35rem;
    margin-right: 0.35rem;
    border: 2px solid var(--gold);
    border-radius: 50%;
    color: var(--gold);
    box-shadow: 0 0 14px oklch(80% 0.16 78 / 0.65);
}

.lab-foot {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(0.4rem + var(--safe-bottom));
    z-index: 30;
    margin: 0;
    padding: 0.4rem;
    border: 0;
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.5;
    pointer-events: none;
}

.lab-foot a { color: var(--text-soft); pointer-events: auto; }

body[data-state="playing"] .lab-foot,
body[data-state="intro"] .lab-foot,
body[data-state="playing"] .game-shell > header .app-logo {
    opacity: 0;
    transition: opacity 0.5s var(--ease);
}

.hud {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    padding: calc(4.2rem + var(--safe-top)) calc(1rem + var(--safe-right)) calc(1rem + var(--safe-bottom))
        calc(1rem + var(--safe-left));
}

.hud[hidden] { display: none; }

.panel {
    background: var(--panel);
    backdrop-filter: blur(var(--blur)) saturate(1.15);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    padding: 0.6rem 0.85rem;
}

.hud-label {
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    opacity: 0.9;
}

.hud-top {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(220px, 2fr) minmax(120px, 1fr);
    gap: 0.75rem;
}

.hearts { display: flex; gap: 0.28rem; margin: 0.35rem 0 0.45rem; }

.heart {
    width: 16px;
    height: 16px;
    display: inline-block;
    background: transparent;
    border: 1.5px solid var(--line);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    opacity: 0.35;
}

.heart.is-on {
    background: linear-gradient(160deg, oklch(74% 0.16 32), var(--coral));
    opacity: 1;
    box-shadow: 0 0 10px oklch(62% 0.18 32 / 0.55);
}

.fuel {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.4rem;
    align-items: center;
}

.fuel i {
    display: block;
    height: 7px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.fuel b {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(1);
    background: linear-gradient(90deg, var(--gold-deep), var(--gold));
    box-shadow: 0 0 10px oklch(80% 0.16 78 / 0.5);
}

.fuel[data-low="true"] b {
    background: linear-gradient(90deg, var(--blood), var(--ember));
    animation: fuelPulse 0.8s ease-in-out infinite;
}

@keyframes fuelPulse {
    50% { filter: brightness(1.35); }
}

.quest-panel { justify-self: center; width: min(480px, 100%); }

.objective {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
    color: var(--parchment);
    line-height: 1.4;
}

.score-panel { justify-self: end; min-width: 118px; }
.score-row { display: flex; justify-content: space-between; gap: 0.8rem; align-items: baseline; }
.score-row--sub { margin-top: 0.25rem; color: var(--text-dim); }

.stealth {
    position: absolute;
    top: calc(9rem + var(--safe-top));
    left: 50%;
    translate: -50% 0;
    width: min(280px, 70vw);
    text-align: center;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: oklch(85% 0.08 80);
}

.stealth i {
    display: block;
    height: 6px;
    margin-top: 0.35rem;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.stealth b {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(0);
    background: linear-gradient(90deg, var(--gold), var(--ember));
}

.stealth[data-danger="true"] { color: oklch(78% 0.16 25); }
.stealth[data-danger="true"] b {
    background: var(--blood);
    box-shadow: 0 0 12px oklch(55% 0.2 25 / 0.8);
}

.message {
    position: absolute;
    left: 50%;
    bottom: calc(6.5rem + var(--safe-bottom));
    translate: -50% 0;
    margin: 0;
    max-width: min(540px, 86vw);
    text-align: center;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.15rem;
    color: var(--parchment);
    text-shadow: 0 2px 18px #000;
    opacity: 0;
    pointer-events: none;
}

.message[data-show="true"] { opacity: 1; transition: opacity 0.35s ease; }

.prompt {
    position: absolute;
    left: 50%;
    bottom: calc(4.4rem + var(--safe-bottom));
    translate: -50% 0;
    margin: 0;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    color: var(--parchment);
    font-size: 0.88rem;
    pointer-events: none;
}

.prompt kbd {
    display: inline-grid;
    place-items: center;
    min-width: 1.3rem;
    margin-right: 0.35rem;
    padding: 0.05rem 0.3rem;
    border-radius: 5px;
    border: 1px solid var(--line);
    font-size: 0.72rem;
    color: var(--gold);
}

.hud-actions {
    position: absolute;
    z-index: 3; /* acima da zona de olhar, que cobre a tela inteira */
    right: calc(1rem + var(--safe-right));
    bottom: calc(1.1rem + var(--safe-bottom));
    display: flex;
    gap: 0.45rem;
    align-items: center;
    pointer-events: auto;
}

.icon-button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--panel-strong);
    border: 1px solid var(--line-soft);
    color: var(--text-soft);
}

.icon-button:hover { color: var(--gold); border-color: var(--gold); }
.fps { font-size: 0.72rem; color: var(--text-dim); }

.chapter-card {
    position: absolute;
    inset: 0;
    z-index: 22;
    display: grid;
    place-content: center;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at 50% 50%, oklch(10% 0.04 270 / 0.4), transparent 60%);
}

.chapter-card.is-on { animation: cardIn 3.4s var(--ease) forwards; }

.chapter-roman {
    font-family: 'Cormorant Garamond', Georgia, serif;
    letter-spacing: 0.4em;
    color: var(--gold);
    font-size: 0.9rem;
}

.chapter-card h2 {
    margin: 0.4rem 0 0.2rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(2rem, 6vw, 3.6rem);
    font-weight: 700;
    color: var(--parchment);
    text-shadow: 0 8px 40px #000;
}

.chapter-card p {
    margin: 0;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.82rem;
    color: var(--text-soft);
}

@keyframes cardIn {
    0% { opacity: 0; transform: translateY(12px); }
    12% { opacity: 1; transform: none; }
    78% { opacity: 1; }
    100% { opacity: 0; }
}

/* O card pode passar da tela (celular deitado, menu cheio): o overlay rola.
   O body trava o toque para o jogo, então o overlay libera o pan vertical. */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(4.4rem + var(--safe-top)) calc(1rem + var(--safe-right))
        calc(1.2rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
    background: color-mix(in oklab, var(--ink-deep) 42%, transparent);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.overlay[hidden] { display: none; }

.overlay-card {
    width: min(860px, 100%);
    /* margin auto centraliza sem cortar o topo quando o card é mais alto
       que a tela — `align-items: center` sozinho tornaria o topo inalcançável. */
    margin: auto;
    background: color-mix(in oklab, oklch(14% 0.04 270) 80%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    padding: 1.6rem 1.7rem 1.4rem;
}

.compact-card { width: min(440px, 100%); text-align: center; }

.eyebrow {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0.6rem;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
}

.eyebrow i {
    width: 28px;
    height: 1px;
    background: var(--gold);
    display: inline-block;
}

.eyebrow--danger { color: oklch(72% 0.16 25); }
.eyebrow--gold { color: var(--gold); }

/* O menu nunca esconde o botão de começar: só o miolo (.menu-grid) rola,
   cabeçalho e rodapé ficam fora da área de scroll — de propósito sem
   position:sticky aqui, que em alguns motores vaza conteúdo não rolado
   por cima da borda arredondada do card. */
.menu-card {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    min-height: 0;
}

.menu-head { flex: 0 0 auto; }

.menu-head h1, .overlay-card h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 700;
    margin: 0 0 0.5rem;
    line-height: 1.15;
    color: var(--parchment);
}

.menu-head h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.menu-head h1 span { color: var(--gold); }

.lede {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
    max-width: 54ch;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    gap: 1.1rem;
    margin: 1.3rem 0 1.1rem;
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.menu-section h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.95rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0 0 0.55rem;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.chapter-chip {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    text-align: left;
    padding: 0.5rem 0.7rem;
    border-radius: 10px;
    border: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-soft);
}

.chapter-chip b {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--gold);
    min-width: 1.4rem;
}

.chapter-chip[data-active="true"] {
    border-color: var(--gold);
    background: color-mix(in oklab, var(--gold) 14%, transparent);
    color: var(--parchment);
}

.chapter-chip:disabled { opacity: 0.35; cursor: not-allowed; }

.keys {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-soft);
}

kbd {
    display: inline-block;
    min-width: 1.3rem;
    padding: 0.08rem 0.32rem;
    margin-right: 0.15rem;
    border-radius: 5px;
    border: 1px solid var(--line);
    font-size: 0.72rem;
    color: var(--parchment);
}

.settings-grid { display: grid; gap: 0.7rem; }

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.82rem;
    color: var(--text-soft);
}

.field select, .field input[type="range"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
}

.section-note {
    margin: 0.7rem 0 0;
    font-size: 0.78rem;
    color: var(--text-dim);
}

.menu-foot {
    display: flex;
    justify-content: flex-end;
    flex: 0 0 auto;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line-soft);
}

.primary-button, .ghost-button {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem 1.15rem;
    border-radius: 999px;
    pointer-events: auto;
}

.primary-button {
    background: linear-gradient(180deg, oklch(82% 0.15 78), oklch(62% 0.14 58));
    color: oklch(16% 0.04 70);
    font-weight: 750;
    box-shadow: 0 10px 28px oklch(70% 0.14 78 / 0.4);
}

.primary-button:hover { filter: brightness(1.08); }

.ghost-button {
    margin-top: 0.55rem;
    border: 1px solid var(--line);
    color: var(--text-soft);
}

.ghost-button:hover { color: var(--gold); border-color: var(--gold); }

.card-actions { display: flex; flex-direction: column; align-items: center; margin-top: 1rem; }

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem 1rem;
    margin: 1rem 0 0;
    text-align: left;
}

.stats div {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.45rem 0.55rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
}

.stats span { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
.stats strong { color: var(--parchment); }

.dialogue-overlay { align-items: end; background: linear-gradient(transparent, oklch(8% 0.04 270 / 0.84)); }
.dialogue-card {
    width: min(640px, 100%);
    margin-bottom: 2rem;
    padding: 1.1rem 1.3rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel-strong);
}

.dialogue-speaker {
    margin: 0 0 0.35rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--gold);
}

.dialogue-text {
    margin: 0 0 0.8rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--parchment);
}

.loading-overlay { background: var(--ink-deep); }
.loading-card { text-align: center; }

.loading-card h1 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1.6rem, 4vw, 2.5rem);
    margin: 0.8rem 0 0.4rem;
}

.ring-loader {
    display: inline-block;
    width: 54px;
    height: 54px;
    border: 4px solid oklch(80% 0.14 78 / 0.22);
    border-top-color: var(--gold);
    border-radius: 50%;
    box-shadow: 0 0 24px oklch(80% 0.16 78 / 0.45);
    animation: spin 1.1s linear infinite;
}

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

.loading-bar {
    width: min(280px, 70vw);
    height: 6px;
    margin: 0.9rem auto 0;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.loading-bar i {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--gold-deep), var(--gold));
    box-shadow: 0 0 12px var(--gold);
}

.touch-controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.stick {
    pointer-events: auto;
    position: absolute;
    z-index: 2;
    left: calc(1rem + var(--safe-left));
    bottom: calc(1.4rem + var(--safe-bottom));
    width: 124px;
    height: 124px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--panel);
    backdrop-filter: blur(var(--blur));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    display: grid;
    place-items: center;
}

.stick i {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 32%, oklch(92% 0.1 88), var(--gold));
    box-shadow: 0 0 18px oklch(80% 0.16 78 / 0.45);
    opacity: 0.9;
}

/* O rótulo é redundante no toque (o aria-label descreve o stick) e encostava
   na borda de baixo em telas curtas. */
.stick span { display: none; }

/* Camada base: qualquer arrasto livre da tela gira a câmera. */
.look-zone {
    pointer-events: auto;
    position: absolute;
    inset: 0;
    z-index: 0;
}

.touch-buttons {
    pointer-events: auto;
    position: absolute;
    z-index: 2;
    right: calc(1rem + var(--safe-right));
    bottom: calc(1.4rem + var(--safe-bottom));
    display: grid;
    grid-template-areas:
        ".   use"
        "run atk";
    gap: 0.5rem;
    align-items: end;
    justify-items: end;
}

.pad {
    display: grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--panel-strong);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--line);
    color: var(--parchment);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.68rem;
    font-weight: 700;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.12s var(--ease), filter 0.12s ease;
}

.pad:active { transform: scale(0.93); filter: brightness(1.15); }

.pad-run { grid-area: run; width: 64px; height: 64px; }

.pad-atk {
    grid-area: atk;
    width: 86px;
    height: 86px;
    font-size: 1.6rem;
    background: radial-gradient(circle at 40% 34%,
            color-mix(in oklab, var(--ember) 62%, transparent),
            color-mix(in oklab, var(--ember) 30%, var(--panel-strong)));
    color: var(--parchment);
}

.pad-use {
    grid-area: use;
    width: 68px;
    height: 68px;
    background: color-mix(in oklab, var(--gold) 26%, var(--panel-strong));
    color: var(--parchment);
}

/* Acende junto com o balão de "E interagir": mostra onde tocar. */
.pad-use[data-ready="true"] {
    background: linear-gradient(180deg, oklch(82% 0.15 78), oklch(64% 0.14 62));
    color: oklch(16% 0.04 70);
    border-color: var(--gold);
    box-shadow: 0 0 0 3px oklch(80% 0.16 78 / 0.22), 0 10px 26px rgba(0, 0, 0, 0.42);
    animation: padReady 1.5s ease-in-out infinite;
}

@keyframes padReady {
    50% { box-shadow: 0 0 0 7px oklch(80% 0.16 78 / 0.12), 0 10px 26px rgba(0, 0, 0, 0.42); }
}

/* ================================================================
   Responsivo
   Alvos: 375×667, 390×844 e paisagem curta (~667×375).
   Regra do HUD no estreito: vitais + placar na primeira linha, objetivo
   na segunda, e uma faixa livre à direita para som/pausa — que descem do
   canto inferior (onde cobriam os botões de toque) para o alto.
   ================================================================ */

@media (max-width: 900px) {
    .menu-grid { grid-template-columns: 1fr; gap: 0.9rem; }

    .hud-top {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "vitals score"
            "quest  quest";
    }

    .heart-panel { grid-area: vitals; }
    .score-panel { grid-area: score; justify-self: end; min-width: 0; }
    .quest-panel { grid-area: quest; justify-self: stretch; width: auto; }
    .message { bottom: calc(12.5rem + var(--safe-bottom)); max-width: min(420px, 80vw); font-size: 1.05rem; }
    .prompt { bottom: calc(10.6rem + var(--safe-bottom)); }

    /* No fluxo, logo abaixo do topo do HUD: um objetivo de duas linhas
       empurrava a barra de alerta para cima do painel quando ela era fixa. */
    .stealth {
        position: static;
        translate: none;
        width: min(280px, 62vw);
        margin: 0.5rem auto 0;
    }
}

@media (max-width: 900px), (max-height: 560px) and (orientation: landscape) {
    /* No canto inferior direito os botões de som/pausa ficavam embaixo dos
       pads de ação. Sobem para a faixa reservada no alto. */
    .hud-actions {
        top: calc(4rem + var(--safe-top));
        right: calc(0.7rem + var(--safe-right));
        bottom: auto;
        flex-direction: column;
        align-items: flex-end;
    }

    .hud-top { padding-right: 3rem; }
    .icon-button { width: 44px; height: 44px; }
    .fps { display: none; }
}

@media (max-width: 768px) {
    .hud {
        padding: calc(4rem + var(--safe-top)) calc(0.7rem + var(--safe-right))
            calc(0.7rem + var(--safe-bottom)) calc(0.7rem + var(--safe-left));
    }

    .hud-top { gap: 0.45rem; }
    .panel { padding: 0.5rem 0.65rem; border-radius: 12px; }
    .hud-label { font-size: 0.58rem; letter-spacing: 0.14em; }

    /* Vida e chama numa linha só: ♥♥♥ ▬▬▬ 100 */
    .heart-panel { display: flex; align-items: center; gap: 0.55rem; }
    .heart-panel > .hud-label { display: none; }
    .hearts { margin: 0; gap: 0.22rem; }
    .heart { width: 14px; height: 14px; }
    /* Sem o rótulo sobram duas colunas: a barra precisa ficar na fração,
       senão colapsa na coluna `auto` e some. */
    .fuel { flex: 1; min-width: 78px; grid-template-columns: minmax(0, 1fr) auto; }
    .fuel .hud-label { display: none; }
    .fuel strong { font-size: 0.85rem; }

    .score-panel .hud-label { display: none; }
    .score-panel { padding: 0.5rem 0.55rem; text-align: right; }
    .score-row { justify-content: flex-end; gap: 0.35rem; }
    #memoriesValue::before { content: '✦ '; color: var(--gold); }

    .objective { font-size: 0.82rem; line-height: 1.35; }
    .overlay { padding-top: calc(4rem + var(--safe-top)); }
    .overlay-card { padding: 1.15rem 1rem 1rem; }
    .menu-head h1 { font-size: 1.7rem; }
    .lede { font-size: 0.92rem; }
    .menu-foot { justify-content: stretch; }
    .menu-foot .primary-button { flex: 1; justify-content: center; }
    .stats { grid-template-columns: 1fr 1fr; gap: 0.45rem; }
    .dialogue-card { margin-bottom: calc(0.9rem + var(--safe-bottom)); padding: 0.95rem 1.05rem; }
    .dialogue-text { font-size: 1.08rem; }
}

@media (max-height: 560px) and (orientation: landscape) {
    .hud {
        padding: calc(3.6rem + var(--safe-top)) calc(0.7rem + var(--safe-right))
            calc(0.6rem + var(--safe-bottom)) calc(0.7rem + var(--safe-left));
    }

    /* Deitado sobra largura e falta altura: as três caixas voltam para uma
       linha só. */
    .hud-top {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "vitals quest score";
        gap: 0.4rem;
    }

    .quest-panel { justify-self: stretch; width: auto; }
    .panel { padding: 0.4rem 0.6rem; }

    .objective {
        margin-top: 0.2rem;
        font-size: 0.76rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .stealth {
        position: static;
        translate: none;
        width: min(240px, 46vw);
        margin: 0.4rem auto 0;
        font-size: 0.66rem;
    }

    .message { bottom: calc(8.8rem + var(--safe-bottom)); font-size: 0.98rem; max-width: min(360px, 46vw); }
    .prompt { bottom: calc(7.2rem + var(--safe-bottom)); font-size: 0.8rem; }

    .stick { width: 104px; height: 104px; bottom: calc(0.9rem + var(--safe-bottom)); }
    .stick i { width: 44px; height: 44px; }
    .touch-buttons { bottom: calc(0.9rem + var(--safe-bottom)); gap: 0.4rem; }
    .pad-atk { width: 72px; height: 72px; font-size: 1.35rem; }
    .pad-use { width: 56px; height: 56px; font-size: 0.62rem; }
    .pad-run { width: 54px; height: 54px; font-size: 0.58rem; }

    .overlay { padding-top: calc(3.4rem + var(--safe-top)); }
    .overlay-card { padding: 0.9rem 1.1rem; }

    /* Cabeçalho enxuto para sobrar tela de rolagem no card. */
    .eyebrow { margin-bottom: 0.35rem; font-size: 0.65rem; }
    .menu-head h1 { font-size: 1.35rem; margin-bottom: 0.3rem; }
    .menu-head .lede { font-size: 0.8rem; line-height: 1.4; }
    .menu-grid { margin: 0.7rem 0 0.5rem; gap: 0.7rem; }
    .menu-section h2 { font-size: 0.85rem; margin-bottom: 0.4rem; }
    .menu-foot { padding: 0.6rem 0 0.9rem; }
    /* Fim de noite (derrota/vitória) deitado: estatísticas em quatro colunas e
       botões lado a lado, senão o card estoura os 375px de altura. */
    .compact-card { width: min(600px, 100%); }
    /* <br> sempre força a quebra, display não muda isso — mas display:none
       também apaga o ::before, então o espaço entre as duas metades da
       frase ("trouxe" / "o dia") sumia junto. content:" " devolve o espaço
       sem remover a quebra. */
    .compact-card h2 { font-size: 1.4rem; }
    .compact-card h2 br { display: inline; }
    .compact-card h2 br::before { content: ' '; }
    .compact-card .lede { font-size: 0.82rem; line-height: 1.4; }
    .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; margin-top: 0.7rem; }
    .stats div { padding: 0.35rem 0.45rem; }
    .stats span { font-size: 0.62rem; }

    .card-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.6rem;
        margin-top: 0.8rem;
    }

    .card-actions .ghost-button { margin-top: 0; }
    .chapter-card h2 { font-size: clamp(1.6rem, 5vw, 2.4rem); }
    .dialogue-card { margin-bottom: calc(0.6rem + var(--safe-bottom)); padding: 0.75rem 1rem; }
    .dialogue-text { font-size: 0.95rem; line-height: 1.35; margin-bottom: 0.6rem; }
}

/* Aparelho de toque: alvos de 44px e dicas sem teclado. */
@media (pointer: coarse) {
    .keys--board { display: none; }
    .prompt kbd { display: none; }
    .chapter-chip { min-height: 46px; align-items: center; }
    .primary-button, .ghost-button { min-height: 46px; }
    .field select, .field input[type="range"] { min-height: 44px; }
    .dialogue-card .ghost-button { width: 100%; justify-content: center; }
}

@media (pointer: fine) {
    .keys--touch { display: none; }
}

/* O range precisa do gesto horizontal próprio dentro do overlay que rola. */
.field input[type="range"] { touch-action: none; }

@media (prefers-reduced-motion: reduce) {
    .pad-use[data-ready="true"] { animation: none; }
}
