/* ==========================================================================
   A FORJA · THE FORGE · LA FORJA (IRAGNUS Studios) — Gótico Vitoriano, toque moderno.
   Linguagem visual herdada do "A Forja Pro": ameixa-escuro e pergaminho, ouro
   velho, vinho, Cinzel nos títulos, painéis de vidro com filete dourado e o
   "vitral" com cantoneiras. Dois temas: escuro (padrão) e claro (pergaminho).
   Desktop: vitral à esquerda + controles à direita (mão do mouse) · Mobile: vitral fixo no topo.
   ========================================================================== */
:root {
  --paper: #ECE3D1; --paper-2: #E2D6BE; --paper-3: #D6C7A9;
  --ink: #1E1A20; --ink-2: #463C44; --muted: #7D7068;
  --gold: #9C722C; --gold-2: #C59D52; --gold-3: #E3C27E;
  --wine: #5E1520; --wine-2: #7E2232; --wine-3: #33090F; --teal: #1F3B3E;
  --sapphire: #2A5CA8; --ruby: #8C1D24; --emerald: #1F6B4B; --beryl: #D8E2F0;

  --f-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --f-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* tema claro = pergaminho */
  --bg: var(--paper);
  --bg-2: var(--paper-2);
  --surface: rgba(255, 252, 244, .55);
  --surface-2: rgba(255, 252, 244, .8);
  --solid: #F3ECDD;
  --text: var(--ink);
  --text-2: var(--ink-2);
  --text-3: var(--muted);
  --accent: var(--gold);
  --accent-2: var(--wine);
  --line: rgba(30, 26, 32, .18);
  --line-2: rgba(30, 26, 32, .09);
  --field: rgba(255, 255, 255, .6);
  --glow: rgba(156, 114, 44, .25);
  --shadow: 0 18px 50px -24px rgba(30, 26, 32, .45);
  --plate-shadow: rgba(30, 26, 32, .3);
}
:root[data-theme="dark"] {
  --bg: #120F14;
  --bg-2: #1A161C;
  --surface: rgba(36, 30, 38, .62);
  --surface-2: rgba(44, 36, 46, .9);
  --solid: #1C171E;
  --text: var(--paper);
  --text-2: #CDBFA8;
  --text-3: #8E8178;
  --accent: var(--gold-2);
  --accent-2: var(--wine-2);
  --line: rgba(197, 157, 82, .22);
  --line-2: rgba(236, 227, 209, .08);
  --field: rgba(10, 8, 12, .55);
  --glow: rgba(197, 157, 82, .28);
  --shadow: 0 24px 70px -30px rgba(0, 0, 0, .9);
  --plate-shadow: rgba(0, 0, 0, .6);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, color-mix(in srgb, var(--accent-2) 30%, transparent), transparent 70%),
    radial-gradient(900px 600px at 100% 110%, color-mix(in srgb, var(--teal) 35%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 500 17px/1.4 var(--f-serif);
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
.mono { font-family: var(--f-mono); font-size: 12px; letter-spacing: .02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--bg); }

/* gemas (conquistas) */
.gem { display: inline-block; width: 9px; height: 9px; flex: none; transform: rotate(45deg); background: var(--accent);
  box-shadow: inset 1.5px 1.5px 0 rgba(255, 255, 255, .5), inset -1.5px -1.5px 0 rgba(0, 0, 0, .22), 0 0 0 1.5px var(--gold); }
.gem--gold { background: var(--gold-2); } .gem--sapphire { background: var(--sapphire); } .gem--ruby { background: var(--wine-2); }
.gem--emerald { background: var(--emerald); } .gem--beryl { background: var(--beryl); }

/* ---------- Topo ---------- */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, var(--surface-2), transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.topbar::after { /* filete duplo dourado */
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .55;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { display: block; width: 150px; flex: none; color: var(--accent); transition: opacity .2s; }
.logo:hover { opacity: .82; }
.logo svg { width: 100%; height: auto; }
.brand-sep { color: var(--accent); font-size: 14px; opacity: .8; }
.brand-title { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-title h1 { font: 600 26px/1 var(--f-display); letter-spacing: .14em; text-transform: uppercase; }
.brand-title small { font: italic 500 15px var(--f-serif); color: var(--text-3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.free { align-self: flex-end; padding: 3px 7px 2px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Botões ---------- */
.ghost, .icon, .primary, .btn, .tog, .opt, .palb, .journey .step, .tabs button, .langs, .seg {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; transition: all .2s var(--ease); color: var(--text);
}
.ghost, .btn { padding: 7px 14px; min-height: 36px; font: 500 12px var(--f-mono); letter-spacing: .04em; text-transform: uppercase; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.ghost:hover, .icon:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
.ghost svg, .btn svg, .primary svg { width: 14px; height: 14px; flex: none; }
.icon { width: 36px; height: 36px; display: inline-grid; place-items: center; font-size: 17px; flex: none; }
.ghost[disabled], .btn[disabled] { opacity: .5; cursor: progress; }
.dice svg { width: 17px; height: 17px; }
.dice.roll svg { animation: roll .6s var(--ease); }
@keyframes roll { 50% { transform: rotate(200deg) scale(1.25); } 100% { transform: rotate(360deg); } }
#btn-medals.ping { animation: ping .7s var(--ease); }
@keyframes ping { 40% { transform: scale(1.12); border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); } }

.primary, .btn--gold {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  padding: 13px 18px; border: 1px solid var(--gold);
  background: linear-gradient(160deg, var(--wine-2), var(--wine) 60%, var(--wine-3));
  color: var(--paper); font: 600 14px var(--f-display); letter-spacing: .2em; text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(227, 194, 126, .25), 0 10px 30px -12px var(--wine);
}
.primary::before, .btn--gold::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(227, 194, 126, .35) 50%, transparent 70%);
  transform: translateX(-100%); transition: transform .8s var(--ease);
}
.primary:hover::before, .btn--gold:hover::before { transform: translateX(100%); }
.primary:hover, .btn--gold:hover { color: var(--paper); border-color: var(--gold-3); }
.primary:disabled, .btn--gold:disabled { opacity: .55; cursor: progress; }
.btn--gold.btn--sm { padding: 9px 13px; font-size: 11px; letter-spacing: .16em; min-height: 38px; }

.langs { display: inline-flex; overflow: hidden; }
.langs button { padding: 0 10px; height: 34px; min-width: 36px; font: 500 12px var(--f-mono); color: var(--text-2); transition: all .2s; }
.langs button + button { border-left: 1px solid var(--line); }
.langs button:hover { color: var(--accent); }
.langs button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }

/* ---------- Jornada (4 etapas) ---------- */
.journey { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 16px 24px 0; max-width: 760px; width: 100%; margin: 0 auto; }
.journey .step { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 9px 8px; font: 600 11px var(--f-display); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.journey .step-n { font: italic 600 15px var(--f-serif); letter-spacing: 0; text-transform: none; color: var(--accent); white-space: nowrap; }
.journey .step:hover { border-color: var(--accent); color: var(--text); }
.journey .step.done .step-n::after { content: " ✓"; font-style: normal; font-size: 11px; }
.journey .step[aria-current="step"] { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px var(--glow); }

/* ---------- Layout ---------- */
.layout {
  position: relative; z-index: 1; flex: 1;
  display: grid; grid-template-columns: 1fr minmax(340px, 430px);
  gap: 20px; padding: 18px 24px 16px; min-height: 0;
}
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.controls .scroll { overflow: auto; flex: 1; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

.p-head { padding: 18px 18px 12px; }
.p-kick { color: var(--accent); letter-spacing: .12em; text-transform: uppercase; font-size: 11px; margin-bottom: 8px; }
.p-head h2 { font: 600 18px/1.25 var(--f-display); letter-spacing: .1em; text-transform: uppercase; }
.p-head p:last-child { margin-top: 7px; font-style: italic; color: var(--text-3); font-size: 17px; line-height: 1.3; }
.tabs { position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  background: var(--solid); }
.tabs:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, 1fr); }
.tabs button { padding: 9px 6px; font: 600 10.5px var(--f-display); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.tabs button:hover { border-color: var(--accent); }
.tabs button[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); color: var(--text); }
.p-body { padding: 4px 18px 18px; }

.grp { margin-top: 16px; }
.grp > h3, .fld > span, .terms h3 { display: block; font: 600 11px var(--f-display); letter-spacing: .16em; text-transform: uppercase; color: var(--text-2); margin-bottom: 8px; }
.hint { margin-top: 10px; color: var(--text-3); font-size: 15.5px; font-style: italic; line-height: 1.3; }

.opts { display: grid; gap: 7px; margin-top: 14px; }
.grp .opts { margin-top: 0; }
.opts--3 { grid-template-columns: repeat(3, 1fr); } .opts--4 { grid-template-columns: repeat(4, 1fr); } .opts--5 { grid-template-columns: repeat(5, 1fr); }
.opt { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 9px 5px 8px; background: var(--field); }
.opt:hover { border-color: var(--accent); transform: translateY(-1px); }
.opt-th { display: grid; place-items: center; width: 100%; aspect-ratio: 1; color: var(--text-3); }
.opt-th svg { max-width: 100%; max-height: 100%; width: auto; height: auto; }
.opts--3 .opt-th { aspect-ratio: 3 / 2; }
.opt-lb { font: 500 10px/1.2 var(--f-mono); letter-spacing: .03em; text-transform: uppercase; text-align: center; color: var(--text-2); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: 0 0 0 3px var(--glow); animation: stamp .3s var(--ease); }
.opt[aria-pressed="true"] .opt-lb { color: var(--accent); }
.opt.locked { opacity: .55; }
/* selo PRO: rubi com filete dourado — reservado a recursos avançados futuros */
.pro { display: inline-block; font: 600 9.5px var(--f-mono); font-style: normal; letter-spacing: .14em; padding: 3px 7px 2px; color: var(--paper);
  background: linear-gradient(160deg, #A8252F, var(--ruby)); border: 1px solid var(--gold-2); border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(227, 194, 126, .2); }
.opt .pro { position: absolute; top: 4px; right: 4px; font-size: 8.5px; padding: 2px 5px; }
.pro-note { display: flex; align-items: flex-start; gap: 12px; margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; font-size: 15.5px; line-height: 1.35; color: var(--text-3); font-style: italic; }
.pro-note b { font-style: normal; color: var(--text-2); }
.pro-note .pro { flex: none; margin-top: 2px; }
@keyframes stamp { 0% { transform: scale(.94); } 60% { transform: scale(1.03); } }

.togs { display: flex; flex-wrap: wrap; gap: 6px; }
.tog { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 11px; font: 500 12px var(--f-mono); color: var(--text-2); }
.tog::before { content: ""; width: 9px; height: 9px; flex: none; transform: rotate(45deg); border: 1.5px solid var(--text-3); border-radius: 1px; transition: all .2s; }
.tog:hover { border-color: var(--accent); }
.tog[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.tog[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 8px var(--glow); }
.tog small { font-size: 10.5px; color: var(--text-3); }
.tog--icon { padding: 0; width: 36px; justify-content: center; } .tog--icon::before { display: none; } .tog--icon svg { width: 16px; height: 16px; }
.grp .togs + .cols, .grp .seg + .togs, .grp .seg + .flds, .grp .togs + .seg { margin-top: 10px; }

.seg { display: inline-flex; flex-wrap: wrap; overflow: hidden; background: var(--field); }
.seg button { min-height: 34px; padding: 6px 12px; font: 500 12px var(--f-mono); color: var(--text-2); transition: all .2s; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--accent); }
.seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

.pals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.palb { display: flex; flex-direction: column; gap: 6px; padding: 7px; background: var(--field); font: 500 10.5px var(--f-mono); text-transform: uppercase; color: var(--text-2); text-align: left; }
.palb:hover { border-color: var(--accent); }
.palb[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: 0 0 0 3px var(--glow); }
.pal-sw { display: flex; height: 22px; border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.pal-sw i { flex: 1; }
.cols { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.col { position: relative; display: grid; grid-template-columns: 32px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 7px 10px;
  background: var(--field); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .2s, box-shadow .2s; }
.col:hover, .col:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.col input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.col-sw { grid-row: 1 / 3; width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--line); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .22); }
.col-lb { font: 600 10px var(--f-display); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.col code { font: 400 11.5px var(--f-mono); color: var(--accent); }
.sync { margin-top: 10px; } .sync .ok { color: var(--text-3); font-style: normal; } .sync .ok::before { content: "✦ "; color: var(--accent); }
.flds { display: grid; gap: 12px; margin-top: 14px; }
.grp .flds { margin-top: 10px; }
.fld > span { margin-bottom: 6px; }
.fld input {
  width: 100%; height: 46px; border: 1px solid var(--line); background: var(--field); border-radius: 10px;
  padding: 0 12px; outline: none; transition: border-color .2s, box-shadow .2s;
  font: 600 19px var(--f-serif); letter-spacing: .05em; text-transform: uppercase;
}
.fld input::placeholder { color: var(--text-3); font-weight: 400; font-style: italic; text-transform: none; letter-spacing: 0; }
.fld input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }

.ex-lead { margin-top: 12px; color: var(--text-2); font-style: italic; }
.exs { display: grid; gap: 7px; margin-top: 12px; }
.ex { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; }
.ex b { display: block; font: 600 12.5px var(--f-display); letter-spacing: .12em; text-transform: uppercase; }
.ex div > span { display: block; margin-top: 3px; font-size: 15px; line-height: 1.25; color: var(--text-3); font-style: italic; }
.ex .btn { flex: none; }
.terms { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--wine) 22%, transparent); font-size: 15.5px; line-height: 1.35; color: var(--text-2); }
.terms h3 { color: var(--accent); } .terms b { color: var(--text); } .terms p + p { margin-top: 8px; }
.reset { margin-top: 16px; }

.forge-actions { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--line-2); }
.forge-actions .primary { flex: 1; }
.forge-actions .ghost[disabled] { visibility: hidden; }

/* ---------- Vitral ---------- */
.stage { display: flex; flex-direction: column; align-items: stretch; gap: 12px; min-width: 0; min-height: 0; }
.arch {
  position: relative; width: 100%; flex: 1; min-height: 360px;
  padding: 10px; border: 1px solid var(--accent); border-radius: 4px;
  background: linear-gradient(var(--surface), var(--surface)), radial-gradient(circle at 50% 40%, var(--glow), transparent 70%);
  box-shadow: var(--shadow), inset 0 0 0 4px var(--bg), inset 0 0 0 5px var(--line);
}
.arch-inner {
  position: absolute; inset: 10px; overflow: hidden; border-radius: 2px;
  background:
    radial-gradient(60% 55% at 50% 45%, var(--glow), transparent 75%),
    repeating-linear-gradient(45deg, var(--line-2) 0 1px, transparent 1px 18px),
    repeating-linear-gradient(-45deg, var(--line-2) 0 1px, transparent 1px 18px);
}
/* cantoneiras góticas: esquadro duplo + losango */
.corner { position: absolute; width: 30px; height: 30px; pointer-events: none; }
.corner::before, .corner::after { content: ""; position: absolute; }
.corner::before { inset: 0; border: 2px solid var(--accent); }
.corner::after { width: 7px; height: 7px; background: var(--accent); transform: rotate(45deg); }
.corner.tl { left: -7px; top: -7px; } .corner.tl::before { border-right: 0; border-bottom: 0; } .corner.tl::after { left: 9px; top: 9px; }
.corner.tr { right: -7px; top: -7px; } .corner.tr::before { border-left: 0; border-bottom: 0; } .corner.tr::after { right: 9px; top: 9px; }
.corner.bl { left: -7px; bottom: -7px; } .corner.bl::before { border-right: 0; border-top: 0; } .corner.bl::after { left: 9px; bottom: 9px; }
.corner.br { right: -7px; bottom: -7px; } .corner.br::before { border-left: 0; border-top: 0; } .corner.br::after { right: 9px; bottom: 9px; }

.stage-view { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: clamp(20px, 3.4vw, 44px); }
.stage-view.on { display: flex; }
.plate { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; filter: drop-shadow(0 22px 26px var(--plate-shadow)); }
.plate svg { max-width: 100%; max-height: 100%; width: auto; height: 100%; }
.plate--crest svg { height: min(100%, 640px); }
.plate--flag { position: relative; padding-left: 26px; }
.plate--flag svg { height: auto; width: min(100%, 760px); max-height: 100%; }
.pole { position: absolute; left: 0; top: 6%; bottom: -4%; width: 9px; border-radius: 5px; background: linear-gradient(90deg, var(--gold), var(--gold-3) 45%, var(--gold)); }
.pole::before { content: ""; position: absolute; left: -4px; top: -14px; width: 17px; height: 17px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1c8, var(--gold-2) 55%, var(--gold)); }
.plate--flat svg { height: auto; width: min(100%, 900px); }
.arch.pop .stage-view.on .plate { animation: pop .42s var(--ease); }
@keyframes pop { 0% { transform: scale(.965); filter: drop-shadow(0 22px 26px var(--plate-shadow)) blur(2px); } 55% { transform: scale(1.012); } 100% { transform: scale(1); } }

#view-uni { padding: 0; }
#uni3d { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
#uni3d:active { cursor: grabbing; }
#view-uni.flat #uni3d { visibility: hidden; }
#uni-flat { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 14px; padding: 104px 28px 36px; }
#view-uni.flat #uni-flat { display: flex; }
.nogl { color: var(--text-3); font-style: italic; text-align: center; max-width: 420px; }
.hud { position: absolute; left: 14px; right: 14px; top: 14px; z-index: 3; display: flex; flex-direction: column; gap: 7px; pointer-events: none; }
.hud-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.hud-row > * { pointer-events: auto; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.hud .seg, .hud .tog { background: var(--surface-2); }
.hud-hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: var(--text-3); z-index: 3; pointer-events: none; font-size: 11px; }
.crew { display: inline-flex; gap: 4px; }
.crew button { width: 34px; height: 34px; border-radius: 9px; font: 500 12px var(--f-mono); border: 1px solid var(--line); }
.crew .crew-m { background: var(--sapphire); color: #fff; border-color: color-mix(in srgb, var(--sapphire) 60%, #fff); }
.crew .crew-f { background: var(--wine-2); color: #fff; border-color: var(--gold-2); }

.summary { display: grid; grid-template-columns: 1fr 1.25fr .8fr; gap: clamp(14px, 2.4vw, 34px); align-items: center; width: 100%; max-width: 980px; }
.sum { display: flex; flex-direction: column; align-items: center; gap: 12px; filter: drop-shadow(0 16px 20px var(--plate-shadow)); }
.sum svg, .sum img { width: 100%; height: auto; max-height: 440px; object-fit: contain; }
.sum figcaption { color: var(--accent); letter-spacing: .14em; text-transform: uppercase; font-size: 11px; }
#sum-uni { width: 100%; }

.progress { position: relative; width: 100%; }
.bar { height: 3px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--wine-2), var(--accent), var(--gold-3)); transition: width .8s var(--ease); }
.ptext { display: flex; justify-content: space-between; margin-top: 6px; color: var(--text-3); }
.ptext span:first-child { color: var(--accent); }
.spark { position: absolute; left: var(--x, 50%); top: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--gold-3); opacity: 0; pointer-events: none; }
.strike .spark { animation: spark .7s ease-out; }
.strike .s1 { --x: 22%; --dx: -26px; --dy: -22px; } .strike .s2 { --x: 48%; --dx: 18px; --dy: -28px; animation-delay: .05s; }
.strike .s3 { --x: 66%; --dx: -12px; --dy: -18px; animation-delay: .1s; } .strike .s4 { --x: 82%; --dx: 24px; --dy: -24px; animation-delay: .02s; }
@keyframes spark { 0% { opacity: 1; transform: translate(0, 0) scale(1.4); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); } }

/* ---------- Rodapé ---------- */
.foot { position: relative; z-index: 1; text-align: center; color: var(--text-3); padding: 0 16px 14px; }
.foot .mono { font-size: 11.5px; } .foot b { color: var(--text-2); font-weight: 500; }
.foot .lic { margin: 4px auto 0; max-width: 860px; font-size: 14.5px; font-style: italic; line-height: 1.3; }

/* ---------- Avisos e conquistas ---------- */
.toasts { position: fixed; right: 18px; top: 86px; z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 13px; padding: 12px 16px; background: var(--surface-2); color: var(--text); border: 1px solid var(--accent); border-radius: 12px;
  box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); animation: tin .45s var(--ease); transition: opacity .5s, transform .5s; }
.toast b { display: block; font: 600 11px var(--f-display); letter-spacing: .12em; text-transform: uppercase; }
.toast i { display: block; font-size: 16.5px; color: var(--text-2); }
.toast.out { opacity: 0; transform: translateX(20px); }
@keyframes tin { from { opacity: 0; transform: translateX(30px); } }
.medals { border: 0; padding: 0; background: transparent; color: var(--text); }
.medals::backdrop { background: rgba(8, 6, 10, .82); }
.medals-in { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 60px); overflow: auto; padding: 22px; background: var(--solid); border: 1px solid var(--accent); border-radius: 18px; box-shadow: var(--shadow); }
.medals-in h2 { font: 600 16px var(--f-display); letter-spacing: .2em; text-transform: uppercase; margin-bottom: 14px; }
.medals-in ul { display: grid; gap: 6px; margin-bottom: 16px; }
.medal { display: flex; align-items: center; gap: 14px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; opacity: .42; }
.medal.on { opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.medal b { display: block; font: 600 11px var(--f-display); letter-spacing: .12em; text-transform: uppercase; }
.medal i { display: block; font-size: 16px; color: var(--text-2); }

/* ---------- Desktop: tudo cabe na janela ---------- */
@media (min-width: 900px) {
  body { height: 100dvh; overflow: hidden; }
  .layout { overflow: hidden; }
}
@media (min-width: 900px) and (max-height: 720px) {
  .topbar { padding: 9px 24px; } .journey { padding-top: 10px; } .layout { padding-top: 12px; }
  .foot .lic { display: none; }
}
@media (max-width: 1180px) {
  .brand-title small, .free { display: none; }
  .dice span { display: none; }
}

/* ---------- Mobile: vitral fixo no topo, controles confortáveis ao toque ---------- */
@media (max-width: 899px) {
  body { display: block; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: nowrap; }
  .logo { width: 84px; }
  .brand { gap: 9px; }
  .brand-sep { display: none; }
  .brand-title h1 { font-size: 17px; letter-spacing: .1em; }
  .top-actions { gap: 6px; flex-wrap: nowrap; }
  .top-actions .ghost { padding: 0 9px; min-height: 36px; }
  .langs button { padding: 0 7px; min-width: 30px; height: 34px; }
  .journey { padding: 12px 12px 0; gap: 4px; }
  .journey .step { padding: 9px 2px; gap: 5px; font-size: 9.5px; letter-spacing: .06em; }
  .journey .step-n { font-size: 13px; }
  .layout { display: flex; flex-direction: column; padding: 12px 12px 8px; gap: 12px; }
  .stage { order: -1; position: sticky; top: 0; z-index: 10; height: 44vh; height: 44svh; min-height: 260px; margin: 0 -12px; padding: 12px 12px 8px; gap: 8px;
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: 0 14px 24px -18px rgba(0, 0, 0, .7); }
  body[data-stage="3"] .stage { height: 54vh; height: 54svh; }
  .arch { min-height: 0; }
  .corner { width: 22px; height: 22px; } .corner::after { width: 5px; height: 5px; }
  .corner.tl::after { left: 6px; top: 6px; } .corner.tr::after { right: 6px; top: 6px; } .corner.bl::after { left: 6px; bottom: 6px; } .corner.br::after { right: 6px; bottom: 6px; }
  .stage-view { padding: 16px; }
  .ptext { margin-top: 4px; font-size: 10.5px; }
  .panel { overflow: visible; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--solid); }
  .controls .scroll { overflow: visible; }
  /* embaixo do vitral: o painel rola na vertical; abas e opções deslizam na horizontal */
  body { overflow-x: clip; }
  .tabs { top: 44vh; top: 44svh; border-radius: 0; display: flex; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar, .opts::-webkit-scrollbar, .pals::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; padding: 12px 16px; scroll-snap-align: start; }
  .opts, .pals { display: flex; overflow-x: auto; margin-inline: -18px; padding: 3px 18px 10px; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .opts .opt { flex: none; width: 96px; scroll-snap-align: start; }
  .opts--3 .opt { width: 132px; }
  .pals .palb { flex: none; width: 124px; scroll-snap-align: start; }
  body[data-stage="3"] .tabs { top: 54vh; top: 54svh; }
  .tog, .seg button { min-height: 44px; }
  .forge-actions .primary { font-size: 12px; letter-spacing: .14em; padding: 12px 12px; }
  .forge-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--solid); border-top: 1px solid var(--accent); }
  .hud { left: 0; right: 0; top: 8px; gap: 5px; }
  .hud-row { flex-wrap: nowrap; overflow-x: auto; padding: 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .hud-row::-webkit-scrollbar { display: none; }
  .hud-row > * { flex: none; }
  .hud .seg { flex-wrap: nowrap; }
  .hud .seg--mini { display: none; }
  .hud .seg button, .hud .tog { min-height: 34px; padding: 5px 9px; font-size: 11px; }
  .hud .tog small { display: none; }
  .hud-hint { bottom: 6px; font-size: 9.5px; }
  #uni-flat { padding: 88px 12px 20px; }
  .summary { gap: 10px; }
  .toasts { top: auto; bottom: calc(84px + env(safe-area-inset-bottom)); right: 10px; left: 10px; max-width: none; }
  .foot { padding-top: 6px; z-index: 0; }
  .layout { z-index: 2; }
}
@media (max-width: 430px) {
  #btn-medals { display: none; }
  .brand-title h1 { font-size: 15px; }
  .logo { width: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
