/* ================================================================
   A Jornada do Anel — interface
   Paleta: pergaminho, ouro do Anel, musgo do Condado, sombra das minas.
   ================================================================ */

:root {
    --ink: oklch(12% 0.03 70);
    --ink-deep: oklch(8% 0.025 70);
    --parchment: oklch(92% 0.04 90);
    --gold: oklch(79% 0.14 82);
    --gold-deep: oklch(62% 0.13 68);
    --moss: oklch(52% 0.12 140);
    --ember: oklch(58% 0.19 38);
    --blood: oklch(52% 0.19 22);

    --text: oklch(95% 0.015 90);
    --text-soft: oklch(80% 0.03 85);
    --text-dim: oklch(62% 0.03 80);

    --panel: color-mix(in oklab, oklch(16% 0.03 70) 64%, transparent);
    --panel-strong: color-mix(in oklab, oklch(11% 0.03 70) 84%, transparent);
    --line: color-mix(in oklab, var(--gold) 28%, 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: 'Outfit', 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.05 70) 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: #050301;
    opacity: 0;
    pointer-events: none;
    transition: none;
}

.vignette {
    position: absolute;
    inset: 0;
    z-index: 18;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at 50% 50%, transparent 40%, oklch(20% 0.12 25 / 0.85) 100%);
    transition: opacity 0.3s ease;
}

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

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

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

/* header */
.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: 'Cinzel', Georgia, serif;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.95rem;
    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 12px oklch(75% 0.16 82 / 0.55);
}

.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 */
.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-family: 'Cinzel', Georgia, serif;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    opacity: 0.85;
}

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

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

.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(72% 0.18 25), var(--blood));
    opacity: 1;
    box-shadow: 0 0 10px oklch(60% 0.2 25 / 0.5);
}

.ring-badge {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.ring-badge[data-on="true"] {
    color: var(--gold);
    text-shadow: 0 0 12px oklch(75% 0.16 82 / 0.7);
}

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

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

.score-panel { justify-self: end; min-width: 110px; }
.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(8.5rem + var(--safe-top));
    left: 50%;
    translate: -50% 0;
    width: min(280px, 70vw);
    text-align: center;
    font-size: 0.75rem;
    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(520px, 86vw);
    text-align: center;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 1.05rem;
    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;
    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: 44px;
    height: 44px;
    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 title card */
.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.03 70 / 0.35), transparent 60%);
}

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

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

.chapter-card h2 {
    margin: 0.4rem 0 0.2rem;
    font-family: 'Cinzel', 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; }
}

/* overlays */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 35;
    display: grid;
    place-items: center;
    padding: calc(4.5rem + var(--safe-top)) 1rem 1.5rem;
    background: color-mix(in oklab, var(--ink-deep) 42%, transparent);
    backdrop-filter: blur(8px);
}

.overlay[hidden] { display: none; }

.overlay-card {
    width: min(860px, 100%);
    background: color-mix(in oklab, oklch(14% 0.03 70) 78%, 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); }

.menu-head h1, .overlay-card h2 {
    font-family: 'Cinzel', 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.1rem);
}

.menu-head h1 span { color: var(--gold); }

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

.menu-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr;
    gap: 1.1rem;
    margin: 1.3rem 0 1.1rem;
}

.menu-section h2 {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    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: 'Cinzel', 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) 12%, 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; }

.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(78% 0.14 82), oklch(58% 0.13 68));
    color: oklch(16% 0.04 70);
    font-weight: 650;
    box-shadow: 0 10px 28px oklch(60% 0.14 82 / 0.35);
}

.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.03 70 / 0.82)); }
.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;
    font-family: 'Cinzel', Georgia, serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--gold);
}

.dialogue-text {
    margin: 0 0 0.8rem;
    font-size: 1.05rem;
    line-height: 1.5;
    color: var(--parchment);
}

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

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

.ring-loader {
    display: inline-block;
    width: 54px;
    height: 54px;
    border: 4px solid oklch(75% 0.14 82 / 0.25);
    border-top-color: var(--gold);
    border-radius: 50%;
    box-shadow: 0 0 24px oklch(75% 0.16 82 / 0.4);
    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 */
.touch-controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.stick {
    pointer-events: auto;
    position: absolute;
    left: calc(1.2rem + var(--safe-left));
    bottom: calc(1.2rem + var(--safe-bottom));
    width: 112px;
    height: 112px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--panel);
    display: grid;
    place-items: center;
}

.stick i {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--gold);
    opacity: 0.85;
}

.stick span {
    position: absolute;
    bottom: -1.2rem;
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.look-zone {
    pointer-events: auto;
    position: absolute;
    right: 0;
    top: 20%;
    width: 48%;
    height: 55%;
}

.touch-buttons {
    pointer-events: auto;
    position: absolute;
    right: calc(1rem + var(--safe-right));
    bottom: calc(1.2rem + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.pad {
    min-width: 72px;
    padding: 0.65rem 0.8rem;
    border-radius: 14px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    color: var(--parchment);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
}

.pad-atk { background: color-mix(in oklab, var(--ember) 35%, var(--panel-strong)); }
.pad-use { background: color-mix(in oklab, var(--gold) 28%, var(--panel-strong)); color: var(--ink); }

@media (max-width: 860px) {
    .menu-grid { grid-template-columns: 1fr; }
    .hud-top { grid-template-columns: 1fr 1fr; }
    .quest-panel { grid-column: 1 / -1; justify-self: stretch; width: auto; }
}

@media (max-width: 560px) {
    .overlay-card { padding: 1.15rem 1rem 1rem; }
    .menu-head h1 { font-size: 1.7rem; }
    .hud-actions { bottom: calc(7.5rem + var(--safe-bottom)); }
}
/* --- lab-responsive-pass --- */
.overlay {
    padding: calc(4.5rem + var(--safe-top, 0px))
             calc(1rem + var(--safe-right, 0px))
             calc(1.5rem + var(--safe-bottom, 0px))
             calc(1rem + var(--safe-left, 0px));
}

@media (max-width: 860px) {
    .menu-grid { grid-template-columns: 1fr; }
}

@media (max-height: 520px) and (orientation: landscape) {
    .stick { width: 96px; height: 96px; bottom: calc(0.8rem + var(--safe-bottom, 0px)); }
    .touch-buttons { flex-direction: row; gap: 0.35rem; bottom: calc(0.8rem + var(--safe-bottom, 0px)); }
    .pad { min-width: 64px; min-height: 44px; padding: 0.5rem 0.65rem; font-size: 0.68rem; }
    .look-zone { height: 70%; top: 15%; }
}

/* --- mobile: HUD, toque, landscape curto --- */
@media (pointer: coarse) {
    .icon-button,
    .icon-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 560px) {
    .overlay,
    .overlay-card,
    .menu-card {
        max-height: min(92dvh, 900px);
    }
    .overlay-card,
    .menu-card {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    /* Abaixo do header compartilhado: em 0.75rem os botões caíam em cima do
       seletor de tema. */
    .hud-actions {
        top: calc(4.4rem + var(--safe-top, env(safe-area-inset-top, 0px)));
        bottom: auto;
        right: calc(0.75rem + var(--safe-right, env(safe-area-inset-right, 0px)));
    }
    .icon-button,
    .icon-btn {
        width: 44px;
        height: 44px;
    }
    /* A camada de toque é ancorada no topo (inset: 0): limitar a altura aqui
       fazia o `bottom` dos filhos medir por uma caixa de ~140px e jogava o
       stick e os botões para fora da tela em paisagem. */
    .stick {
        bottom: calc(0.8rem + var(--safe-bottom, 0px));
    }

    .touch-buttons {
        bottom: calc(0.8rem + var(--safe-bottom, 0px));
    }

    /* Com o stick colado na base, o rótulo embaixo saía da tela. */
    .stick span {
        bottom: auto;
        top: -1.1rem;
    }
}

/* agent-responsive-768 */
@media (max-width: 768px) {
  html, body { overflow-x: clip; }
}
