/* ================================================================
   João e o Pé de Feijão — interface
   Paleta: folha, feijão-violeta, ouro da galinha, cabana ao entardecer.
   ================================================================ */

:root {
    --ink: oklch(14% 0.04 145);
    --ink-deep: oklch(10% 0.035 145);
    --leaf: oklch(62% 0.16 142);
    --leaf-deep: oklch(42% 0.12 145);
    --gold: oklch(80% 0.15 85);
    --gold-deep: oklch(64% 0.14 75);
    --bean: oklch(58% 0.18 310);
    --bean-glow: oklch(72% 0.16 310);
    --cream: oklch(94% 0.03 95);
    --blood: oklch(54% 0.19 25);

    --text: oklch(96% 0.02 95);
    --text-soft: oklch(82% 0.04 100);
    --text-dim: oklch(64% 0.03 120);

    --panel: color-mix(in oklab, oklch(16% 0.04 145) 64%, transparent);
    --panel-strong: color-mix(in oklab, oklch(12% 0.04 145) 86%, transparent);
    --line: color-mix(in oklab, var(--gold) 32%, transparent);
    --line-soft: color-mix(in oklab, var(--cream) 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(24% 0.06 145) 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: #06140a;
    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 40%, oklch(18% 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; }
}

.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: 'Fraunces', Georgia, serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: 0.98rem;
    color: var(--cream);
    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(--leaf);
    border-radius: 50%;
    color: var(--gold);
    box-shadow: 0 0 12px oklch(62% 0.16 142 / 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 {
    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: 'Fraunces', Georgia, serif;
    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(140px, 1fr) minmax(220px, 2fr) minmax(120px, 1fr);
    gap: 0.75rem;
}

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

.heart {
    width: 16px;
    height: 16px;
    display: inline-block;
    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);
}

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

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

.objective {
    margin: 0.35rem 0 0;
    font-size: 0.92rem;
    color: var(--cream);
    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 90);
}

.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(--leaf), var(--gold));
}

.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: 'Fraunces', Georgia, serif;
    font-size: 1.05rem;
    color: var(--cream);
    text-shadow: 0 2px 18px #000;
    opacity: 0;
}

.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(--cream);
    font-size: 0.88rem;
}

.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: 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(12% 0.04 145 / 0.4), transparent 60%);
}

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

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

.chapter-card h2 {
    margin: 0.4rem 0 0.2rem;
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(2rem, 6vw, 3.6rem);
    font-weight: 700;
    color: var(--cream);
    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; }
}

.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(16% 0.05 145) 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); }

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

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

.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: 'Fraunces', 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: 'Fraunces', Georgia, serif;
    color: var(--gold);
    min-width: 1.4rem;
}

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

.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(--cream);
}

.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(70% 0.16 142), oklch(48% 0.13 145));
    color: oklch(16% 0.04 145);
    font-weight: 750;
    box-shadow: 0 10px 28px oklch(55% 0.14 142 / 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(--cream); }

.dialogue-overlay { align-items: end; background: linear-gradient(transparent, oklch(10% 0.04 145 / 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: 'Fraunces', 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(--cream);
}

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

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

.bean-loader {
    display: inline-block;
    width: 54px;
    height: 54px;
    border: 4px solid oklch(62% 0.16 142 / 0.25);
    border-top-color: var(--gold);
    border-radius: 50%;
    box-shadow: 0 0 24px oklch(62% 0.16 142 / 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(--leaf-deep), var(--gold));
    box-shadow: 0 0 12px var(--leaf);
}

.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(--leaf);
    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: 54px;
    min-height: 44px;
    padding: 0.65rem 0.8rem;
    border-radius: 14px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    color: var(--cream);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pad-atk { background: color-mix(in oklab, var(--bean) 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 {
        max-height: min(92dvh, 640px);
        overflow-y: auto;
        padding: 1.15rem 1rem 1rem;
    }
    .menu-head h1 { font-size: 1.7rem; }
    .hud-actions { bottom: calc(7.5rem + var(--safe-bottom)); }
}

@media (max-height: 520px) and (orientation: landscape) {
    .overlay-card {
        max-height: min(92dvh, 420px);
        overflow-y: auto;
        padding: 0.85rem 1rem;
    }
    .menu-head h1 { font-size: 1.4rem; }
    .menu-head p { font-size: 0.82rem; margin-bottom: 0.4rem; }
    .stick {
        width: 84px;
        height: 84px;
        bottom: calc(0.6rem + var(--safe-bottom));
        left: calc(0.8rem + var(--safe-left));
    }
    .stick i { width: 32px; height: 32px; }
    .touch-buttons {
        bottom: calc(0.6rem + var(--safe-bottom));
        right: calc(0.8rem + var(--safe-right));
        gap: 0.3rem;
    }
    .pad {
        min-height: 38px;
        padding: 0.35rem 0.6rem;
        font-size: 0.68rem;
    }
    .dialogue-card {
        margin-bottom: 0.6rem;
        padding: 0.75rem 1rem;
    }
    .dialogue-text { font-size: 0.92rem; margin-bottom: 0.5rem; }
}

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