/* A Jornada até Einstein — identidade visual: caderno de laboratório sob céu noturno */
:root {
  --ink: #0c1030;
  --ink-2: #151a45;
  --ink-3: #20286a;
  --cobalt: #2b3a8f;
  --gold: #f5b83d;
  --gold-d: #b97f0b;
  --teal: #2fc4b2;
  --coral: #ff6f5e;
  --paper: #eef3fb;
  --paper-2: #dfe8f6;
  --line: #b9c8e2;
  --text: #f2f5ff;
  --muted: #b4bdea;
  --txt-dark: #121735;
  --ok: #0b7a4b;
  --ok-bg: #dff5e9;
  --no: #a8321f;
  --no-bg: #fde7e1;
  --display: Rockwell, "Roboto Slab", "Rockwell Nova", Cambria, Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--body); font-size: 16px; line-height: 1.5; color: var(--text);
  background: radial-gradient(1200px 700px at 78% -10%, #27307f 0%, transparent 60%), linear-gradient(180deg, var(--ink) 0%, #080a22 100%);
  background-attachment: fixed;
}
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.15; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
sup, sub { line-height: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nowrap { white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--gold); color: var(--txt-dark); padding: 8px 14px; border-radius: 8px; z-index: 100; font-weight: 700; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.q-dlg :focus-visible, .dlg.small :focus-visible, .dlg.wide :focus-visible { outline-color: var(--cobalt); }
[hidden] { display: none !important; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1000; }
.noscript { padding: 20px; background: var(--coral); color: #fff; text-align: center; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px; border-radius: 12px; border: 2px solid transparent;
  background: transparent; cursor: pointer; font-weight: 700; text-decoration: none;
  transition: transform .12s, background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { min-height: 52px; padding: 10px 26px; font-size: 1.05rem; }
.btn-sm { min-height: 38px; padding: 4px 12px; font-size: .9rem; }
.btn-primary { background: var(--gold); color: var(--txt-dark); box-shadow: 0 4px 0 var(--gold-d); }
.btn-primary:hover:not(:disabled) { background: #ffc956; }
.btn-primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--gold-d); transform: translateY(2px); }
.btn-secondary { border-color: var(--gold); color: var(--gold); }
.btn-secondary:hover { background: rgba(245, 184, 61, .12); }
.btn-ghost { color: var(--muted); border-color: rgba(180, 189, 234, .28); }
.btn-ghost:hover:not(:disabled) { color: #fff; border-color: rgba(180, 189, 234, .6); background: rgba(255, 255, 255, .05); }
.btn-ghost.off { opacity: .8; }
.dlg .btn-ghost, .q-dlg .btn-ghost { color: var(--cobalt); border-color: var(--line); }
.dlg .btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--paper-2); border-color: var(--cobalt); }
.dlg .btn-secondary { color: var(--cobalt); border-color: var(--cobalt); }
.dlg .btn-secondary:hover { background: var(--paper-2); }

/* ---------- barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px clamp(12px, 3vw, 28px); border-bottom: 1px solid rgba(180, 189, 234, .16);
  background: rgba(12, 16, 48, .8); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; border-radius: 10px; }
.brand-mark { font-family: var(--display); font-weight: 800; font-size: .95rem; background: var(--gold); color: var(--txt-dark); padding: 4px 8px; border-radius: 8px; transform: rotate(-3deg); }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.1rem; }
.topnav { display: flex; gap: 8px; flex-wrap: wrap; }
.topnav .btn { min-height: 38px; padding: 4px 12px; font-size: .9rem; }

.screen { max-width: 1320px; margin: 0 auto; padding: clamp(14px, 3vw, 32px); }

/* ---------- tela inicial ---------- */
.start { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.3fr); gap: clamp(20px, 3vw, 40px); align-items: center; min-height: calc(100dvh - 70px); }
.start h1 { font-size: clamp(2rem, 4vw, 3.4rem); font-weight: 800; letter-spacing: -.01em; outline: none; }
.start-lead { margin-top: 18px; font-size: 1.15rem; color: var(--muted); max-width: 34em; }
.start-actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 12px; }
.continue-info { margin-top: 14px; color: var(--gold); font-weight: 600; }
.start-facts { margin: 26px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); font-size: .95rem; }
.start-facts li::before { content: "✓ "; color: var(--teal); font-weight: 800; }

.lineup { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; gap: clamp(2px, 1vw, 12px); }
.stage-item { text-align: center; opacity: 0; animation: rise .7s cubic-bezier(.2, .8, .2, 1) forwards; animation-delay: calc(var(--i) * 140ms + 150ms); }
.stage-item:nth-child(1) .stage-fig { transform: scale(.78); }
.stage-item:nth-child(2) .stage-fig { transform: scale(.84); }
.stage-item:nth-child(3) .stage-fig { transform: scale(.9); }
.stage-item:nth-child(4) .stage-fig { transform: scale(.96); }
.stage-item:nth-child(5) .stage-fig { transform: scale(1.06); filter: drop-shadow(0 0 18px rgba(255, 220, 120, .6)); }
.stage-fig { transform-origin: bottom center; }
.stage-fig svg { width: 100%; height: auto; display: block; }
.stage-name { font-family: var(--display); font-weight: 700; font-size: clamp(.7rem, 1.3vw, .95rem); margin-top: 6px; line-height: 1.15; }
.stage-where { color: var(--muted); font-size: .78rem; }
.start-hero { position: relative; padding: 18px 8px 8px; border-radius: 24px; background: linear-gradient(180deg, rgba(43, 58, 143, .25), rgba(43, 58, 143, 0)); border-bottom: 3px dashed rgba(245, 184, 61, .45); }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* ---------- HUD ---------- */
.game { padding-bottom: 110px; }
.hud {
  display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 2fr) auto auto; gap: 14px 22px; align-items: center;
  background: var(--ink-2); border: 1px solid rgba(180, 189, 234, .2); border-radius: var(--radius); padding: 12px 18px;
}
.hud-region-name { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.hud-level { color: var(--muted); font-size: .88rem; }
.hud-level .stars { color: var(--gold); letter-spacing: 1px; }
.bar { height: 14px; background: rgba(255, 255, 255, .12); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: inherit; transition: width .8s cubic-bezier(.3, .8, .3, 1); }
.bar-text { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.hud-stat { text-align: right; min-width: 80px; }
.hud-num { display: block; font-family: var(--display); font-weight: 800; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hud-lbl { font-size: .8rem; color: var(--muted); }
.hud-lbl small { display: block; }
.flame { margin-left: 4px; filter: grayscale(1) opacity(.5); font-size: 1.2rem; }
.hot .flame { filter: none; animation: flick 1s ease-in-out infinite alternate; }
@keyframes flick { to { transform: scale(1.18) rotate(-6deg); } }

.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; margin-top: 16px; align-items: start; }
.board-wrap { border-radius: 18px; overflow: hidden; border: 1px solid rgba(180, 189, 234, .22); background: #060820; }
.board { width: 100%; }
.board-svg { display: block; width: 100%; height: auto; user-select: none; }

.side { display: grid; gap: 14px; position: sticky; top: 76px; }
.side-card { background: var(--ink-2); border: 1px solid rgba(180, 189, 234, .2); border-radius: var(--radius); padding: 14px; }
.side-char { text-align: center; }
.side-portrait svg { width: 100%; max-width: 190px; height: auto; display: inline-block; }
.side-stage { font-family: var(--display); font-weight: 800; font-size: 1.15rem; margin-top: 4px; }
.side-motto { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.side-dots { list-style: none; display: flex; justify-content: center; gap: 8px; margin: 10px 0 0; padding: 0; }
.side-dots li { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.side-dots li.done { background: var(--teal); border-color: var(--teal); }
.side-dots li.now { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 0 4px rgba(245, 184, 61, .3); }
.side-h { font-size: 1rem; margin-bottom: 8px; }
.float { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.medals { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.medal { position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; border: 2px dashed rgba(180, 189, 234, .4); color: rgba(180, 189, 234, .45); }
.medal .icon { width: 24px; height: 24px; }
.medal-n { position: absolute; right: -4px; bottom: -4px; background: var(--ink); border: 1px solid currentColor; border-radius: 50%; width: 18px; height: 18px; font-size: .7rem; font-weight: 800; display: grid; place-items: center; }
.medal.got { border: 2px solid var(--rc); color: var(--rc); background: rgba(255, 255, 255, .06); box-shadow: 0 0 14px -2px var(--rc); }
.stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats div { background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 8px 10px; }
.stats dt { font-size: .78rem; color: var(--muted); }
.stats dd { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
#btn-review-last { margin-top: 10px; width: 100%; }

/* botão de ação principal */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; justify-content: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, rgba(8, 10, 34, .94) 40%); pointer-events: none; }
body:not([data-screen="game"]) .actionbar { display: none; }
.cta {
  pointer-events: auto; --tc: var(--gold); display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  width: min(100%, 520px); padding: 10px 20px 10px 12px; border-radius: 18px; border: 0;
  background: var(--gold); color: var(--txt-dark); box-shadow: 0 5px 0 var(--gold-d), 0 12px 30px rgba(0, 0, 0, .45);
  transition: transform .12s;
}
.cta:hover:not(:disabled) { transform: translateY(-2px); }
.cta:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--gold-d); }
.cta:disabled { opacity: .6; cursor: progress; }
.cta-ic { width: 46px; height: 46px; border-radius: 50%; background: var(--ink); color: var(--tc); display: grid; place-items: center; flex: none; }
.cta-ic .icon { width: 28px; height: 28px; }
.cta-tx { display: grid; line-height: 1.2; }
.cta-tx strong { font-family: var(--display); font-size: 1.15rem; }
.cta-tx small { font-size: .85rem; opacity: .85; }
.cta:not(:disabled) .cta-ic { animation: ping 2s ease-in-out infinite; }
@keyframes ping { 50% { box-shadow: 0 0 0 8px rgba(12, 16, 48, .15); } }

/* ---------- elementos do SVG do tabuleiro ---------- */
.band-title { font-family: var(--display); font-weight: 800; font-size: 22px; paint-order: stroke; stroke: rgba(0, 0, 0, .35); stroke-width: 3px; }
.band-stars { font-size: 15px; fill: #ffd24d; stroke: none; }
.band-sub { font-size: 14px; fill: #cfd8ff; font-family: var(--body); }
.band-sep { stroke: rgba(255, 255, 255, .22); stroke-dasharray: 3 7; stroke-width: 2; }
.scenery .motif { color: inherit; opacity: .55; fill: none; stroke: currentColor; stroke-width: 2; }
.motif-eq { fill: #fff; opacity: .16; font-family: var(--display); font-size: 22px; font-weight: 700; }
.dust { fill: #fff; }
.road-edge { fill: none; stroke: rgba(0, 0, 0, .45); stroke-width: 34; stroke-linecap: round; stroke-linejoin: round; }
.road { fill: none; stroke: #2c3566; stroke-width: 26; stroke-linecap: round; stroke-linejoin: round; }
.road-dash { fill: none; stroke: rgba(255, 255, 255, .35); stroke-width: 2.5; stroke-dasharray: 2 12; stroke-linecap: round; }
.road-done { fill: none; stroke-width: 26; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.cell { cursor: default; outline: none; }
.cell.is-next { cursor: pointer; }
.cell .c-body { fill: #0f1442; stroke: var(--tc); stroke-width: 4; }
.cell .c-ring { fill: none; stroke: var(--tc); stroke-width: 2; stroke-dasharray: 4 4; opacity: .8; }
.cell .c-icon { color: var(--tc); }
.cell .c-num circle { fill: var(--ink); stroke: var(--tc); stroke-width: 2; }
.cell .c-num text { fill: #fff; font-size: 13px; font-weight: 800; text-anchor: middle; font-family: var(--body); }
.cell .c-label { fill: #e4e9ff; font-size: 12.5px; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: rgba(5, 7, 30, .85); stroke-width: 4px; font-family: var(--body); }
.cell .c-check circle { fill: var(--teal); stroke: var(--ink); stroke-width: 2; }
.cell .c-check use { color: var(--ink); }
.cell.is-future .c-body { stroke-opacity: .45; fill: #0a0e34; }
.cell.is-future .c-icon { opacity: .55; }
.cell.is-future .c-label { opacity: .65; }
.cell.is-done .c-body { fill: #172055; }
.cell.is-done .c-icon { opacity: .7; }
.cell.is-next .c-body { fill: #1b2468; stroke-width: 5; }
.cell.is-next:hover .c-body, .cell.is-next:focus-visible .c-body { fill: #2a3590; }
.cell:focus-visible .c-body { stroke: #fff; stroke-width: 6; }
.cell.is-current .c-body { stroke-width: 5; fill: #1b2468; }
.pulse { fill: none; stroke: var(--tc); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: pulse 2.1s ease-out infinite; }
.pulse2 { animation-delay: 1.05s; }
@keyframes pulse { from { transform: scale(.95); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
.cell.landed .c-body { animation: landed .5s ease-out; }
@keyframes landed { 40% { stroke-width: 10; } }
.finish .flag { fill: #ffcf5a; stroke: #fff; stroke-width: 2.5; stroke-linejoin: round; }
.finish-txt { fill: #fff; font-family: var(--display); font-weight: 800; font-size: 18px; }
.token { transition: transform .34s cubic-bezier(.4, 0, .3, 1); pointer-events: none; }
.token-shadow { fill: rgba(0, 0, 0, .45); }
.token-char { transform-box: fill-box; transform-origin: 50% 100%; }
.token.hop .token-char { animation: hop .34s ease-out; }
@keyframes hop { 40% { transform: translateY(-22px) scale(.97, 1.04); } 100% { transform: none; } }

/* ---------- personagem (animações internas) ---------- */
.eyes { animation: blink 5s infinite; transform-origin: 100px 91px; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.bubbles { animation: bubbles 2.4s ease-in-out infinite; }
@keyframes bubbles { 50% { transform: translateY(-3px); } }
.chalk-glow { animation: glow 2.4s ease-in-out infinite alternate; }
@keyframes glow { to { opacity: .55; } }
.aura { animation: aura 3s ease-in-out infinite alternate; transform-origin: 50% 50%; }
@keyframes aura { to { opacity: .6; } }

/* ---------- diálogos ---------- */
dialog { color: var(--txt-dark); }
dialog::backdrop { background: rgba(5, 7, 28, .72); backdrop-filter: blur(3px); }
.dlg { border: 0; border-radius: 20px; padding: 0; background: var(--paper); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: hidden; }
.dlg[open] { animation: pop .22s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg.small { width: 440px; padding: 24px; }
.dlg.small h2 { font-size: 1.4rem; margin-bottom: 10px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.dlg.wide { width: 720px; grid-template-rows: auto 1fr auto; }
.dlg.wide[open] { display: grid; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 2px solid var(--line); background: var(--paper-2); }
.dlg-head h2 { font-size: 1.4rem; }
.dlg.wide .dlg-actions { margin: 0; padding: 12px 22px; border-top: 2px solid var(--line); }
.dlg-body { padding: 18px 22px; overflow: auto; }
.q-x { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: #fff; color: var(--ink); font-size: 1.6rem; line-height: 1; cursor: pointer; flex: none; }
.q-x:hover { background: var(--paper-2); }

.rules h3 { font-size: 1.1rem; margin: 18px 0 6px; color: var(--cobalt); }
.rules p, .rules li { line-height: 1.55; }
.rules-lead { font-size: 1.05rem; }
.rules-steps { padding-left: 22px; margin: 0; display: grid; gap: 6px; }
.rules-types { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rules-types li { display: flex; gap: 12px; align-items: flex-start; }
.rt-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: var(--tc); display: grid; place-items: center; flex: none; }
.rt-ic .icon { width: 24px; height: 24px; }
.rules-types b { display: block; }
.rules-types span { font-size: .93rem; }
kbd { background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; font-family: var(--body); font-size: .9em; }
.ach-list { list-style: none; margin: 0; display: grid; gap: 8px; }
.ach-list li { display: flex; gap: 12px; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); opacity: .75; }
.ach-list li.got { opacity: 1; border-color: var(--ok); background: var(--ok-bg); }
.ach-list b { display: block; }
.ach-list span { display: block; font-size: .9rem; }
.ach-list em { font-size: .8rem; font-style: normal; font-weight: 700; color: var(--cobalt); }
.ach-list li.got em { color: var(--ok); }
.ach-ic { width: 34px; height: 34px; flex: none; color: var(--cobalt); }
.ach-ic .icon { width: 100%; height: 100%; }

/* ---------- questão: caderno quadriculado ---------- */
.q-dlg {
  width: min(860px, calc(100vw - 20px)); height: min(920px, calc(100dvh - 20px)); display: none; flex-direction: column;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(43, 58, 143, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(43, 58, 143, .08) 1px, transparent 1px);
  background-size: 24px 24px;
}
.q-dlg[open] { display: flex; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 12px 22px; background: var(--ink); color: #fff; border-bottom: 4px solid var(--gold); }
.q-title { font-size: 1.25rem; display: flex; align-items: center; gap: 12px; outline: none; }
.q-cell { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--tc); color: var(--tc); display: grid; place-items: center; flex: none; background: #0f1442; }
.q-cell .icon { width: 24px; height: 24px; }
.q-head .q-x { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .4); }
.q-head .q-x:hover { background: rgba(255, 255, 255, .12); }
.q-body { flex: 1; overflow-y: auto; padding: 16px 22px 8px; overscroll-behavior: contain; }
.q-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { font-size: .85rem; font-weight: 700; padding: 3px 12px; border-radius: 999px; background: #fff; border: 2px solid var(--line); color: var(--txt-dark); }
.chip-region { border-color: var(--rc); box-shadow: inset 0 0 0 1px var(--rc); }
.chip-level span[aria-hidden] { color: var(--gold-d); letter-spacing: 1px; }
.q-note { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; background: #fff6dc; border: 1px solid #e9cf86; border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; color: #4a3600; }
.q-note .icon { width: 20px; height: 20px; flex: none; color: var(--gold-d); }
.q-note.good { background: var(--ok-bg); border-color: #9fd7b8; color: #0a4a2d; }
.q-statement { font-size: 1.08rem; line-height: 1.6; max-width: 70ch; }
.q-statement p + p { margin-top: 10px; }
.q-figure { margin: 4px 0 14px; padding: 10px; background: #fff; border: 2px solid var(--line); border-radius: 12px; overflow-x: auto; }
.q-figure figcaption { font-size: .88rem; color: #3a4270; margin-bottom: 6px; font-weight: 600; }
.q-figure table { border-collapse: collapse; width: 100%; font-size: .98rem; font-variant-numeric: tabular-nums; }
.q-figure caption { text-align: left; font-weight: 700; padding-bottom: 6px; color: #3a4270; }
.q-figure th, .q-figure td { border: 1px solid var(--line); padding: 5px 10px; text-align: center; }
.q-figure th { background: var(--paper-2); }
.q-figure svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.fig-grid { stroke: #d5def0; stroke-width: 1; }
.fig-axis { stroke: #1b2250; stroke-width: 2; fill: none; }
.fig-line { stroke: var(--cobalt); stroke-width: 3; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.fig-dot { fill: var(--coral); stroke: #fff; stroke-width: 1.5; }
.fig-tick, .fig-label { fill: #1b2250; font-size: 12px; font-family: var(--body); }
.fig-circuit { color: #1b2250; }
fieldset.q-fieldset { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
.q-options { display: grid; gap: 10px; }
.opt {
  position: relative; display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px;
  min-height: 56px; padding: 8px 14px 8px 8px; background: #fff; border: 2px solid var(--line); border-radius: 14px; cursor: pointer;
  transition: border-color .12s, background-color .12s, transform .12s;
}
.opt:hover { border-color: var(--cobalt); transform: translateX(3px); }
.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt-letter { width: 40px; height: 40px; border-radius: 12px; background: var(--paper-2); color: var(--ink); font-family: var(--display); font-weight: 800; font-size: 1.2rem; display: grid; place-items: center; border: 2px solid var(--line); }
.opt-text { font-size: 1.02rem; line-height: 1.4; }
.opt-flag { font-size: .82rem; font-weight: 800; white-space: nowrap; }
.opt:focus-within { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.opt.sel { border-color: var(--cobalt); background: #e6ecff; box-shadow: 0 0 0 2px var(--cobalt); }
.opt.sel .opt-letter { background: var(--cobalt); color: #fff; border-color: var(--cobalt); }
.opt[data-state="eliminated"] { opacity: .5; cursor: not-allowed; background: #eef0f6; }
.opt[data-state="eliminated"] .opt-text { text-decoration: line-through; }
.opt[data-state="eliminated"]:hover { transform: none; border-color: var(--line); }
.opt[data-state="eliminated"] input { cursor: not-allowed; }
.opt[data-state="correct"] { border-color: var(--ok); background: var(--ok-bg); opacity: 1; box-shadow: 0 0 0 2px var(--ok); }
.opt[data-state="correct"] .opt-letter { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt[data-state="correct"] .opt-flag { color: var(--ok); }
.opt[data-state="wrong"] { border-color: var(--no); background: var(--no-bg); box-shadow: 0 0 0 2px var(--no); }
.opt[data-state="wrong"] .opt-letter { background: var(--no); color: #fff; border-color: var(--no); }
.opt[data-state="wrong"] .opt-flag { color: var(--no); }
.opt[data-state="correct"], .opt[data-state="wrong"] { cursor: default; }
.opt[data-state="correct"]:hover, .opt[data-state="wrong"]:hover { transform: none; }
.q-hint { margin-top: 12px; background: #fff6dc; border-left: 5px solid var(--gold); border-radius: 8px; padding: 10px 14px; }

.q-result { margin: 18px 0 10px; display: grid; gap: 12px; }
.result-banner { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 14px; border: 2px solid; }
.result-banner h3 { font-size: 1.25rem; }
.result-banner.ok { background: var(--ok-bg); border-color: var(--ok); color: #073d27; }
.result-banner.no { background: #fff4de; border-color: #d99a1e; color: #4f3300; }
.rb-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--ok); color: #fff; }
.no .rb-ic { background: #d99a1e; }
.rb-ic .icon { width: 26px; height: 26px; }
.chips-pts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips-pts li { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: .9rem; }
.chips-pts li.total { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips-pts b { font-variant-numeric: tabular-nums; }
.move-note, .correct-is { font-weight: 600; }
.why, .solution { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.why h4, .solution h4 { font-size: 1.05rem; margin-bottom: 6px; color: var(--cobalt); }
.solution p + p { margin-top: 8px; }
.tag { display: inline-block; font-family: var(--body); font-size: .78rem; padding: 1px 9px; border-radius: 999px; border: 1.5px solid; margin-left: 6px; vertical-align: middle; }
.tag-conceitual { color: #6a2fb3; border-color: #6a2fb3; background: #f3eaff; }
.tag-calculo { color: #0b5e8a; border-color: #0b5e8a; background: #e5f4fc; }
.q-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; padding: 12px 22px calc(12px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .92); border-top: 2px solid var(--line); }
.q-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.q-tools small { opacity: .8; font-weight: 500; }
.q-foot > .btn-primary { margin-left: auto; }

/* ---------- cerimônias ---------- */
.ceremony { width: min(560px, calc(100vw - 24px)); padding: 26px 24px 22px; text-align: center; background: linear-gradient(180deg, #fff, var(--paper)); }
.ceremony[open] { display: block; }
.dlg.small[open] { display: block; }
.ceremony h2 { font-size: 1.7rem; margin-top: 10px; }
.cer-lead { margin: 10px auto 18px; max-width: 40ch; font-size: 1.05rem; }
.cer-stage-name { font-family: var(--display); font-weight: 800; font-size: 1.3rem; color: var(--cobalt); margin-top: 4px; }
.medal-big { position: relative; width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; color: var(--rc); background: var(--ink); border: 6px solid var(--rc); box-shadow: 0 0 40px -4px var(--rc); animation: spin-in .9s cubic-bezier(.2, 1.2, .3, 1); }
.medal-big .icon { width: 66px; height: 66px; }
.medal-big span { position: absolute; bottom: -8px; right: -8px; width: 38px; height: 38px; border-radius: 50%; background: var(--rc); color: var(--ink); font-family: var(--display); font-weight: 800; font-size: 1.2rem; display: grid; place-items: center; border: 3px solid #fff; }
@keyframes spin-in { from { transform: rotate(-200deg) scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.morph { position: relative; width: 220px; height: 260px; margin: 0 auto; }
.morph svg { width: 100%; height: 100%; }
.morph > div { position: absolute; inset: 0; }
.morph-from { animation: morph-out 1.1s .35s ease-in forwards; }
.morph-to { opacity: 0; animation: morph-in 1.1s .8s ease-out forwards; }
.morph-to.static { opacity: 1; animation: none; }
.flash { background: radial-gradient(circle, #fff 0%, rgba(255, 244, 190, .9) 25%, transparent 65%); opacity: 0; animation: flash 1.1s .55s ease-in-out; }
@keyframes morph-out { to { opacity: 0; transform: scale(.85); filter: brightness(3) blur(3px); } }
@keyframes morph-in { from { opacity: 0; transform: scale(.85); filter: brightness(3) blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes flash { 40% { opacity: 1; } 100% { opacity: 0; } }

.cer-victory { width: min(640px, calc(100vw - 24px)); background: radial-gradient(circle at 50% 30%, #2a3499 0%, #0c1030 75%); color: #fff; }
.cer-victory dialog, .cer-victory { color: #fff; }
.victory-stage { position: relative; width: min(360px, 80vw); height: min(420px, 52dvh); margin: 0 auto; overflow: hidden; border-radius: 20px; }
.vc { position: absolute; inset: 0; display: grid; place-items: center; }
.vc svg { height: 100%; width: auto; max-width: 100%; }
.vc-new { opacity: 0; }
.vflash { position: absolute; inset: 0; background: radial-gradient(circle, #fff 0, rgba(255, 244, 190, .9) 30%, transparent 70%); opacity: 0; pointer-events: none; }
.cer-victory.charging .vc-old { animation: charge 2s ease-in forwards; }
.cer-victory.charging .vflash { animation: vflash 2.4s ease-in forwards; }
.cer-victory.transformed .vc-old { display: none; }
.cer-victory.transformed .vc-new { opacity: 1; animation: reveal 1.3s cubic-bezier(.2, .9, .3, 1); }
.cer-victory.transformed .vflash { animation: vflash-out 1.3s ease-out; }
@keyframes charge { 0% { transform: scale(1); } 60% { transform: scale(1.05) translateX(-3px); filter: brightness(1.3); } 80% { transform: scale(1.08) translateX(3px); filter: brightness(2); } 100% { transform: scale(1.1); filter: brightness(5) blur(2px); } }
@keyframes vflash { 0% { opacity: 0; } 85% { opacity: .1; } 100% { opacity: 1; } }
@keyframes vflash-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes reveal { from { transform: scale(.7) rotate(-4deg); filter: brightness(3); } to { transform: none; filter: none; } }
.eq-layer { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.vc { z-index: 1; }
.eq-float { position: absolute; bottom: -30px; color: #ffe08a; font-family: var(--display); font-weight: 700; white-space: nowrap; opacity: 0; text-shadow: 0 0 10px rgba(255, 224, 138, .7); animation: eq-up 7s ease-in infinite; }
@keyframes eq-up { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: .55; } 85% { opacity: .4; } 100% { transform: translateY(-420px) rotate(6deg); opacity: 0; } }
.victory-title { font-size: clamp(1.5rem, 5vw, 2.1rem); margin-top: 14px; color: var(--gold); }
.victory-lead { color: #dfe5ff; }
.victory-btn { margin-top: 4px; }
#cer-ok { margin-top: 4px; }

/* ---------- tela final ---------- */
.end { display: grid; gap: 28px; }
.end-hero { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 32px; align-items: center; }
.end-char svg { width: 100%; height: auto; filter: drop-shadow(0 0 24px rgba(255, 224, 138, .5)); }
.end h1 { font-size: clamp(2rem, 5vw, 3.2rem); outline: none; }
.end-lead { color: var(--muted); font-size: 1.15rem; margin-top: 10px; max-width: 36em; }
.end-score { display: flex; align-items: baseline; gap: 10px; margin: 18px 0; }
.end-score span:first-child { font-family: var(--display); font-weight: 800; font-size: clamp(3rem, 8vw, 5rem); color: var(--gold); line-height: 1; font-variant-numeric: tabular-nums; }
.end-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0; }
.end-stats div { background: var(--ink-2); border: 1px solid rgba(180, 189, 234, .2); border-radius: var(--radius); padding: 14px 16px; }
.end-stats dt { color: var(--muted); font-size: .88rem; }
.end-stats dd { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.end-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; }
.end-cols h2 { font-size: 1.3rem; margin-bottom: 12px; }
.themes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.themes li { display: grid; grid-template-columns: minmax(110px, 170px) 1fr minmax(100px, auto); gap: 10px; align-items: center; font-size: .92rem; }
.th-bar { height: 12px; background: rgba(255, 255, 255, .12); border-radius: 999px; overflow: hidden; }
.th-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: inherit; }
.th-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.end-tip { margin-top: 14px; padding: 10px 14px; border-left: 4px solid var(--gold); background: rgba(245, 184, 61, .1); border-radius: 6px; }
.ach-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ach-mini li { background: var(--ink-2); border: 1px solid rgba(180, 189, 234, .2); border-radius: 10px; padding: 8px 12px; }
.ach-mini b { display: block; }
.ach-mini span { color: var(--muted); font-size: .88rem; }
.end-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.end .medals .medal { width: 52px; height: 52px; }

.toasts { position: fixed; top: 74px; right: 14px; z-index: 900; display: grid; gap: 8px; width: min(340px, calc(100vw - 28px)); pointer-events: none; }
.toast { background: var(--paper); color: var(--txt-dark); border-left: 6px solid var(--cobalt); border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); animation: toast-in .3s ease-out; transition: opacity .5s, transform .5s; }
.toast.out { opacity: 0; transform: translateX(20px); }
.toast-warn { border-left-color: var(--coral); }
.toast-good { border-left-color: var(--teal); }
.toast-ach { border-left-color: var(--gold); }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } }

/* ---------- responsivo ---------- */
@media (max-width: 1000px) {
  .game-grid { grid-template-columns: 1fr; }
  .side { position: static; grid-template-columns: 1fr 1fr; }
  .side-char { grid-row: span 2; }
  .hud { grid-template-columns: 1fr 1fr; }
  .hud-progress { grid-column: 1 / -1; order: 3; }
  .hud-stat { text-align: left; }
}
@media (max-width: 820px) {
  .start { grid-template-columns: 1fr; min-height: 0; }
  .start-hero { order: -1; }
  .end-hero, .end-cols { grid-template-columns: 1fr; }
  .end-char { max-width: 220px; margin: 0 auto; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .brand-name { font-size: .95rem; }
  .topnav { width: 100%; }
  .topnav .btn { flex: 1; padding-inline: 6px; font-size: .82rem; }
  .side { grid-template-columns: 1fr; }
  .side-char { grid-row: auto; }
  .hud { padding: 10px 12px; gap: 10px 14px; }
  .hud-num { font-size: 1.35rem; }
  .q-dlg { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .q-head { padding: 8px 10px 8px 14px; }
  .q-title { font-size: 1.05rem; gap: 8px; }
  .q-cell { width: 34px; height: 34px; }
  .q-body { padding: 12px 14px 6px; }
  .q-statement { font-size: 1rem; }
  .opt { grid-template-columns: 40px 1fr; padding-right: 10px; }
  .opt-letter { width: 34px; height: 34px; }
  .opt-flag { grid-column: 2; }
  .opt-flag:empty { display: none; }
  .q-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .q-foot > .btn-primary { flex: 1 1 100%; margin-left: 0; }
  .q-tools { width: 100%; }
  .q-tools .btn { flex: 1; font-size: .8rem; padding-inline: 8px; }
  .themes li { grid-template-columns: 1fr auto; }
  .th-bar { grid-column: 1 / -1; grid-row: 2; }
  .dlg.wide, .dlg.small { width: calc(100vw - 20px); }
  .cta-tx small { display: none; }
  .toasts { top: auto; bottom: 90px; right: 8px; }
}

/* ---------- reduzir animações ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .stage-item { opacity: 1; }
  .morph-to { opacity: 1; }
  .morph-from, .flash { display: none; }
  .eq-float { opacity: .6; bottom: auto; top: calc(10% + 60% * var(--r, .5)); }
}
