/* main.css — estética dark minimalista/tática, mobile-first (360px–430px+). */
:root {
  --accent: #e11d48;
  --bg: #0b0d12;
  --surface: #12151d;
  --surface-2: #181c27;
  --line: #262b3a;
  --text: #e6e8ee;
  --muted: #8a90a2;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #f43f5e;
  --radius: 14px;
  --ad-footer-h: 60px;
  --font-display: 'Rajdhani', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 var(--font-body);
}
/* Reserva de espaço do anúncio de rodapé: só existe com anúncios ligados (body.ads-on). */
body.ads-on.has-ad-footer { padding-bottom: calc(var(--ad-footer-h) + 32px + env(safe-area-inset-bottom)); }

h1, h2, h3, .brand, .btn, .scene-tag, .rarity, .nav-btn { font-family: var(--font-display); letter-spacing: .02em; }
h1 { font-size: clamp(2rem, 9vw, 3rem); line-height: 1.05; margin: .25rem 0 .5rem; }
h2 { font-size: 1.45rem; margin: 1.75rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; color: var(--muted); text-transform: uppercase; }
p { margin: 0 0 1rem; }
a { color: var(--text); text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(100% - 32px, 640px); margin-inline: auto; }

/* Topo */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; text-transform: uppercase; white-space: nowrap; }
.brand::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: var(--accent); transform: rotate(45deg); }
.topbar nav { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--muted); }
.topbar nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.topbar nav a:hover { color: var(--text); }
.nav-btn {
  min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--muted); font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.nav-btn:hover { color: var(--text); }
.nav-btn[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }
.lang-toggle .nav-btn { min-width: 40px; }
/* Durante a partida o cabeçalho mostra só "← Catálogo" e "Som" (evita sair sem querer). */
body.in-game .lang-switch { display: none; }

.lead { font-size: 1.08rem; color: #c9ccd6; }
.muted { color: var(--muted); }
.scene-tag { display: inline-block; font-size: .82rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .14em; margin-bottom: .35rem; }
.hero { padding-top: 1.5rem; }
.intro ul, .legal ul { padding-left: 1.2rem; }
.intro li, .legal li { margin-bottom: .4rem; }
.intro .btn.primary { margin: .25rem 0 1rem; }

/* ---------- Backdrop tático dinâmico (sem imagem) / imagem com overlay ---------- */
.visual {
  --bd-a: color-mix(in srgb, var(--accent) 30%, transparent);
  --bd-top: #1a1f2c;
  --bd-pos: 80% 15%;
  position: relative; overflow: hidden;
  width: 100%; aspect-ratio: 16 / 9; max-height: 185px; margin: 1rem 0 .85rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(70% 95% at var(--bd-pos), var(--bd-a), transparent 72%),
    linear-gradient(160deg, var(--bd-top), #07080c);
  transition: border-color .3s;
}
.visual::before { /* linha de scan */
  content: ''; position: absolute; left: 0; right: 0; top: -45%; height: 45%;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.07), transparent);
  animation: scan 4.8s linear infinite;
}
.visual::after { /* vinheta */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 100% at 50% 50%, transparent 55%, rgba(0,0,0,.55));
}
@keyframes scan { to { top: 100%; } }
.act-1 { --bd-pos: 80% 15%; --bd-top: #1a1f2c; }
.act-2 { --bd-pos: 15% 25%; --bd-top: #1d1a2b; }
.act-3 { --bd-pos: 50% 100%; --bd-top: #10202a; }
.act-4 { --bd-pos: 88% 85%; --bd-top: #26141b; --bd-a: color-mix(in srgb, var(--accent) 42%, transparent); }
.bd-hidden { --bd-a: rgba(245,158,11,.34); border-color: rgba(245,158,11,.5); }
.bd-death { --bd-a: rgba(225,29,72,.6); --bd-top: #2a0b12; --bd-pos: 50% 50%; border-color: rgba(244,63,94,.65); }
.bd-death::after { background: radial-gradient(100% 100% at 50% 50%, transparent 30%, rgba(120,0,20,.75)); }
.bd-ending { --bd-a: rgba(52,211,153,.38); --bd-top: #0c2420; border-color: rgba(52,211,153,.5); }
.bd-ending.rar-raro { --bd-a: rgba(34,211,238,.4); --bd-top: #0b1f2a; border-color: rgba(34,211,238,.5); }
.bd-ending.rar-secreto { --bd-a: rgba(250,204,21,.4); --bd-top: #231d0a; border-color: rgba(250,204,21,.55); }
.visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.visual.has-img::before { display: none; }
.visual.has-img::after { background: linear-gradient(180deg, rgba(5,6,10,.2), rgba(5,6,10,.85)); }
.visual.slim { max-height: 92px; margin-bottom: .6rem; }
.visual.thumb { margin: 0; border: 0; border-radius: 0; aspect-ratio: auto; height: 70px; max-height: 70px; }

/* ---------- Cenas ---------- */
.screen { padding-top: 4px; }
.scene, .ending { position: relative; }
.enter { animation: enter .3s ease-out both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.scene-text { font-size: 1.06rem; line-height: 1.7; }

.choices { display: grid; gap: 12px; margin-top: 1rem; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  width: 100%; min-height: 58px; padding: 15px 18px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: var(--radius);
  font: 500 1rem/1.45 var(--font-body); text-align: left; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  touch-action: manipulation;
}
.choice:hover { background: var(--surface-2); border-left-color: var(--accent); }
.choice:active { transform: scale(.985); }
.choice.gated { border-left-color: var(--warn); background: linear-gradient(90deg, rgba(245,158,11,.08), var(--surface) 55%); }
.badge { font: 600 .72rem/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--warn); }
.badge::before { content: '◆ '; }

/* Micro-feedback (toasts) sobre o banner da cena: não bloqueia cliques. */
.toasts {
  position: absolute; top: calc(1rem + 10px); left: 10px; right: 10px; z-index: 3;
  display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none;
}
.toast {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(8,10,16,.88); backdrop-filter: blur(4px);
  font: 700 .76rem/1.3 var(--font-display); letter-spacing: .08em; text-transform: uppercase;
  animation: toast 2.6s ease both;
}
.toast.pos { color: #4ade80; border-color: rgba(74,222,128,.4); }
.toast.neg { color: #fb7185; border-color: rgba(251,113,133,.4); }
.toast.mem { color: var(--warn); border-color: rgba(245,158,11,.45); }
@keyframes toast {
  0% { opacity: 0; transform: translateY(-6px) scale(.96); }
  10%, 78% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-4px); }
}

/* Barra de progresso da simulação */
.progress { position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: 3px; background: rgba(255,255,255,.06); }
.progress span { display: block; width: 0; height: 100%; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: width .45s ease; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 54px; padding: 0 18px; width: 100%;
  border-radius: var(--radius); border: 1px solid var(--line);
  font-size: 1.05rem; font-weight: 700; text-transform: uppercase; cursor: pointer;
  transition: filter .15s, transform .1s, background .15s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 1rem; }
.actions .btn { font-size: .95rem; padding: 0 10px; }
.share-status { min-height: 1.4em; margin: .4rem 0 0; color: var(--muted); font-size: .88rem; }

/* ---------- Finais + Patente ---------- */
.ending-head { display: flex; align-items: center; gap: 14px; margin: .1rem 0 .8rem; }
.ending-head h2 { font-size: clamp(1.55rem, 7vw, 2.2rem); line-height: 1.05; margin: .25rem 0 0; }
.archetype { color: var(--accent); font: 600 1rem var(--font-display); text-transform: uppercase; margin: .2rem 0 0; }
.rank-seal {
  --rank: #94a3b8;
  flex: 0 0 auto; width: 84px; height: 84px;
  display: grid; place-items: center; align-content: center;
  border: 2px solid var(--rank); border-radius: 16px; color: var(--rank);
  background: color-mix(in srgb, var(--rank) 12%, var(--bg));
  box-shadow: 0 0 26px color-mix(in srgb, var(--rank) 35%, transparent);
  font-family: var(--font-display);
  animation: stamp .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
.rank-seal span { font-size: .68rem; font-weight: 700; letter-spacing: .28em; }
.rank-seal strong { font-size: 2.7rem; line-height: .95; }
.rank-s { --rank: #facc15; }
.rank-a { --rank: #22d3ee; }
.rank-b { --rank: #34d399; }
.rank-c { --rank: #94a3b8; }
.rank-f { --rank: #f43f5e; }
@keyframes stamp { from { opacity: 0; transform: scale(1.6) rotate(-8deg); } to { opacity: 1; transform: none; } }
.rarity { display: inline-block; padding: 2px 10px; border: 2px solid currentColor; border-radius: 999px; font-weight: 700; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; }
.rarity-comum { color: #94a3b8; }
.rarity-raro { color: #38bdf8; }
.rarity-secreto { color: #f59e0b; }
.key-line { margin: .8rem 0 0; padding-left: 12px; border-left: 3px solid var(--accent); font-size: .95rem; line-height: 1.55; color: #d5d8e2; }
.is-death .key-line { border-left-color: var(--danger); }
.profile { padding: 14px 16px; background: var(--surface); border-left: 3px solid var(--accent); border-radius: 8px; }
.insights { padding-left: 1.2rem; }
.insights li { margin-bottom: .5rem; }
.is-final .scene-text { margin-top: 1.5rem; }

/* Mini-painel de atributos */
.mini-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 4px; font: 600 .82rem var(--font-display); text-transform: uppercase; letter-spacing: .04em; }
.track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.fill { display: block; height: 100%; background: #5b6478; border-radius: inherit; transition: width .6s ease-out; }
.fill.dominant { background: var(--accent); }

/* Impacto de morte: flash carmesim nas bordas + tremor curto */
body.fx-death::after {
  content: ''; position: fixed; inset: 0; z-index: 50; pointer-events: none;
  box-shadow: inset 0 0 0 3px rgba(244,63,94,.9), inset 0 0 110px rgba(225,29,72,.55);
  animation: flash .85s ease-out both;
}
body.fx-death #screen { animation: shake .42s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* Coleção */
.collection { margin: 0 0 1.25rem; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ending .collection { margin-top: 1.5rem; }
.collection-count { margin: 0 0 .4rem; font: 700 .95rem var(--font-display); text-transform: uppercase; }
.collection-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .9rem; }
.collection-list .locked { color: var(--muted); }
.collection-list .open::before { content: '✓ '; color: var(--ok); }

/* ---------- Catálogo ---------- */
.catalog-grid { display: grid; gap: 14px; }
.story-card {
  display: block; overflow: hidden; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius);
  transition: transform .15s, background .15s;
}
.story-card:hover { transform: translateY(-2px); background: var(--surface-2); }
.card-body { padding: 14px 18px 18px; }
.story-card h3 { margin: 0 0 .2rem; color: var(--text); text-transform: none; font-size: 1.5rem; }
.story-card .sub { color: var(--muted); font-style: italic; margin-bottom: .6rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 .75rem; font-size: .8rem; color: var(--muted); }
.card-meta span { padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; }
.progress-badge.has { color: var(--ok); border-color: rgba(34,197,94,.45); }
.cta { font: 700 1rem var(--font-display); color: var(--accent); text-transform: uppercase; }

/* ---------- Anúncios (3 slots). Ocultos enquanto CONFIG.ADS_ENABLED = false ---------- */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 10px, var(--surface-2) 10px, var(--surface-2) 20px);
  border: 1px dashed var(--line); color: #4b5163;
}
body:not(.ads-on) .ad-slot { display: none; }
.ad-slot::before { content: 'Publicidade'; font: 600 .7rem var(--font-display); letter-spacing: .2em; text-transform: uppercase; }
html[lang^="en"] .ad-slot::before { content: 'Advertisement'; }
.ad-inline { min-height: 250px; margin: 1.5rem 0; border-radius: var(--radius); }
.ad-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--ad-footer-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-width: 1px 0 0;
}

/* Rodapé do site e páginas legais */
.site-footer { margin-top: 3rem; padding: 24px 16px; border-top: 1px solid var(--line); text-align: center; font-size: .88rem; color: var(--muted); }
.site-footer a { color: var(--muted); margin: 0 8px; display: inline-block; }
.legal { padding: 1.5rem 0 2rem; }
.error { color: #fda4af; }

/* Auditor (?validate=1) */
.validator {
  position: fixed; top: 64px; right: 12px; z-index: 30; max-width: min(92vw, 360px);
  padding: 12px 36px 12px 14px; border-radius: 10px; font-size: .82rem;
  background: rgba(12,14,20,.95); border: 1px solid var(--ok); box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.validator.fail { border-color: var(--danger); }
.validator strong { color: var(--ok); }
.validator.fail strong { color: var(--danger); }
.validator p { margin: 4px 0 0; color: var(--muted); }
.validator ul { margin: 8px 0 0; padding-left: 1rem; }
.validator button { position: absolute; top: 4px; right: 6px; background: none; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer; }

@media (max-width: 380px) {
  .topbar { padding: 10px 12px; }
  .brand { font-size: 1rem; }
  .topbar nav { gap: 8px; font-size: .82rem; }
}
@media (min-width: 720px) {
  .catalog-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .toast { opacity: 1; }
}
