/* Jogo Binário — estilos compartilhados (jogo + aprenda)
   Layout: barra azul no topo; jogo em tela única com tabuleiro de 10 linhas;
   página de estudo com índice lateral e matérias em coluna de leitura. */
:root {
  --blue: #004A8D;
  --blue-deep: #00305C;
  --orange: #F7941D;
  --orange-ink: #3A2000;
  --bg: #EEF3F9;
  --surface: #FFFFFF;
  --slot: #E3EBF4;
  --tint: #DCE8F5;
  --ink: #0D2236;
  --muted: #587089;
  --line: #C7D5E5;
  --bit-off: #F5F8FC;
  --bit-fixed: #004A8D;
  --bit-fixed-ink: #FFFFFF;
  --good: #1E9E6A;
  --bad: #D2423A;
  --hud-bg: #004A8D;
  --hud-ink: #FFFFFF;
  --shadow: 0 10px 30px -12px rgba(0, 48, 92, .35);

  --font-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Martian Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --gap: clamp(4px, .85vh, 7px);
  --col-gap: clamp(3px, 1vw, 7px);
  --nib: clamp(4px, 1.4vw, 10px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #3C8AD8; --blue-deep: #0A2846; --orange: #F7941D; --orange-ink: #2A1700;
    --bg: #06172A; --surface: #0C2540; --slot: #10304F; --tint: #12355A; --ink: #E4EDF7; --muted: #8FA7C0;
    --line: #1D4268; --bit-off: #0F2C4A; --bit-fixed: #2F78C4; --bit-fixed-ink: #FFFFFF;
    --good: #35C08A; --bad: #F06B62; --hud-bg: #00315F; --hud-ink: #FFFFFF;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --blue: #3C8AD8; --blue-deep: #0A2846; --orange: #F7941D; --orange-ink: #2A1700;
  --bg: #06172A; --surface: #0C2540; --slot: #10304F; --tint: #12355A; --ink: #E4EDF7; --muted: #8FA7C0;
  --line: #1D4268; --bit-off: #0F2C4A; --bit-fixed: #2F78C4; --bit-fixed-ink: #FFFFFF;
  --good: #35C08A; --bad: #F06B62; --hud-bg: #00315F; --hud-ink: #FFFFFF;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Barra superior ---------- */
.hud {
  background: var(--hud-bg);
  color: var(--hud-ink);
  display: flex;
  justify-content: center;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top);
}
.hud-inner {
  width: 100%;
  max-width: 620px;
  padding-block: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.page-learn .hud-inner { max-width: 1120px; }
.brand {
  font-family: var(--font-display);
  font-stretch: 70%;
  font-weight: 900;
  font-size: 26px;
  letter-spacing: .01em;
  text-transform: uppercase;
  line-height: 1;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}
.brand b { color: var(--orange); font-family: var(--font-mono); font-size: 14px; font-weight: 800; letter-spacing: .08em; }
.stats { display: flex; gap: 18px; margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.stat span { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; opacity: .75; }
.stat strong { font-family: var(--font-mono); font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-btns { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.08);
  color: var(--hud-ink);
  cursor: pointer;
  display: grid; place-items: center;
  padding: 0;
  text-decoration: none;
}
.icon-btn:hover { background: rgba(255,255,255,.18); }
.nav { display: flex; gap: 6px; margin-left: auto; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--hud-ink); text-decoration: none;
  font-weight: 700; font-size: 14px;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.28);
}
.nav a:hover { background: rgba(255,255,255,.12); }
.nav a[aria-current="page"] { background: var(--orange); border-color: var(--orange); color: var(--orange-ink); }

/* ---------- Crédito ---------- */
.credit {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  letter-spacing: .02em;
}
.credit a { color: var(--blue); font-weight: 700; text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* =========================================================
   JOGO
   ========================================================= */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.app > .play {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  padding-block: 10px max(10px, env(safe-area-inset-bottom));
}
.stage {
  position: relative;
  width: 100%;
  max-width: 620px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.levelbar {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
}
.levelbar .pips { display: flex; gap: 3px; flex: 1; min-width: 40px; }
.pip { height: 6px; flex: 1; border-radius: 3px; background: var(--line); transition: background .3s; }
.pip.on { background: var(--orange); }
.pip.live { background: var(--blue); }
.chip-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: none;
  cursor: pointer;
}
.chip-btn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #FFFFFF; }

/* 8 bits em dois grupos de 4 (nibbles) + coluna decimal */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) var(--nib) repeat(4, minmax(0, 1fr)) minmax(66px, 1.7fr);
  column-gap: var(--col-gap);
}
.grid > .nib { width: 0; }

.ruler { padding-inline: 9px; }
.pv {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  background: var(--tint);
  color: var(--blue);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: clamp(12px, 3vw, 17px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  position: relative;
  transition: background .12s, color .12s;
}
.pv::after {
  content: "";
  position: absolute; bottom: -5px; left: 50%;
  width: 8px; height: 8px; margin-left: -4px;
  background: inherit;
  transform: rotate(45deg);
  border-radius: 1px;
}
.pv .pow { display: none; font-weight: 400; font-size: .64em; color: var(--muted); }
.show-pow .pv .pow { display: block; }
.pv.hot { background: var(--orange); color: var(--orange-ink); }
.pv.hot .pow { color: var(--orange-ink); }
.ruler .dec-head {
  display: grid; place-items: center;
  color: var(--orange); font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em;
}

.board-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  overflow: hidden;
  /* Ocupa a altura que sobra na tela; as 10 linhas se ajustam a ela */
  flex: 1 1 0;
  min-height: calc(10 * 28px + 9 * 4px + 18px);
  max-height: calc(10 * 48px + 9 * 7px + 18px);
  container-type: size;
}
.board {
  --row-h: clamp(28px, (100cqh - 9 * var(--gap)) / 10, 48px);
  position: relative;
  height: calc(10 * var(--row-h) + 9 * var(--gap));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--gap);
  background:
    repeating-linear-gradient(to top,
      var(--slot) 0, var(--slot) var(--row-h),
      transparent var(--row-h), transparent calc(var(--row-h) + var(--gap)));
  border-radius: 8px;
  transition: filter .25s;
}
.board-wrap.danger { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad), var(--shadow); }
.paused .board { filter: blur(9px); }

.row {
  height: var(--row-h);
  flex: 0 0 auto;
  animation: drop .32s cubic-bezier(.2,.9,.3,1.2);
}
.row.solved { animation: clear .45s ease-in forwards; pointer-events: none; }
.row.shake { animation: shake .35s; }

.bit {
  height: 100%;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--bit-off);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: clamp(14px, 3.6vw, 20px);
  color: var(--muted);
  display: grid; place-items: center;
  padding: 0;
  user-select: none;
  transition: background .12s, color .12s, transform .08s, border-color .12s;
}
button.bit { cursor: pointer; }
@media (hover: hover) { button.bit:hover { border-color: var(--orange); } }
button.bit:active { transform: scale(.94); }
button.bit[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); color: var(--orange-ink); }
.bit.fixed { border-style: dashed; background: transparent; }
.bit.fixed.one { background: var(--bit-fixed); border: 1.5px solid var(--bit-fixed); color: var(--bit-fixed-ink); }

.dec {
  height: 100%;
  border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: clamp(16px, 4vw, 22px);
  font-variant-numeric: tabular-nums;
}
.dec.target { background: var(--blue); color: #FFFFFF; }
.dec input {
  width: 100%; height: 100%;
  border-radius: 8px;
  border: 2px solid var(--orange);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: center;
  padding: 0;
  caret-color: var(--orange);
}
.dec input::placeholder { color: var(--muted); opacity: .55; font-weight: 400; }
.dec input:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--orange) 35%, transparent); }
.row.wrong .dec input { border-color: var(--bad); color: var(--bad); }
.row.solved .bit, .row.solved .dec, .row.solved .dec input { background: var(--good); border-color: var(--good); color: #FFFFFF; }

.timer { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.timer i { display: block; height: 100%; width: 0; background: var(--orange); }
.footnote { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); letter-spacing: .04em; }

.float {
  position: absolute; right: 18px;
  font-family: var(--font-mono); font-weight: 800; font-size: 15px;
  color: var(--good);
  pointer-events: none;
  animation: floatUp .9s ease-out forwards;
  z-index: 3;
}

/* ---------- Telas sobrepostas ---------- */
.overlay {
  position: absolute; inset: 0;
  z-index: 5;
  display: grid; place-items: center;
  padding: 12px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(3px);
}
.card {
  width: 100%; max-width: 440px;
  max-height: 100%;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px 22px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-stretch: 72%;
  font-weight: 900;
  font-size: 34px;
  line-height: .95;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--blue);
}
.card h2 em { font-style: normal; color: var(--orange); }
.card p { margin: 0; line-height: 1.5; color: var(--ink); }
.card .muted { color: var(--muted); font-size: 13px; }
.howto { display: flex; flex-direction: column; gap: 10px; }
.howto-item { display: flex; flex-direction: column; gap: 6px; }
.howto-item p { font-size: 13.5px; }
.mini { display: grid; grid-template-columns: repeat(4, 1fr) 2px repeat(4, 1fr) 1.6fr; gap: 3px; }
.mini span {
  height: 24px; border-radius: 5px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 800;
  border: 1px solid var(--line); color: var(--muted); background: var(--bit-off);
}
.mini .o { background: var(--orange); border-color: var(--orange); color: var(--orange-ink); }
.mini .f { background: var(--bit-fixed); border-color: var(--bit-fixed); color: var(--bit-fixed-ink); }
.mini .t { background: var(--blue); border-color: var(--blue); color: #FFFFFF; }
.mini .i { border: 2px solid var(--orange); background: var(--surface); color: var(--ink); }
.big-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.big-stats div { background: var(--slot); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.big-stats span { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.big-stats strong { font-family: var(--font-mono); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  flex: 1 1 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 13px 18px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  background: var(--orange);
  color: var(--orange-ink);
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: transparent; color: var(--blue); border: 2px solid var(--blue); }
kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; }

/* =========================================================
   APRENDA
   ========================================================= */
.learn {
  max-width: 1120px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 28px 40px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
.toc {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 20px);
  display: flex; flex-direction: column; gap: 4px;
}
.toc h2 { margin: 0 0 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.toc a {
  display: grid; grid-template-columns: 34px 1fr; align-items: baseline;
  padding: 7px 10px; border-radius: 8px;
  text-decoration: none; color: var(--ink); font-size: 14px; line-height: 1.3;
}
.toc a span { font-family: var(--font-mono); font-size: 11px; font-weight: 800; color: var(--blue); }
.toc a:hover { background: var(--tint); }
.toc a.active { background: var(--blue); color: #FFFFFF; }
.toc a.active span { color: var(--orange); }

.lessons { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.intro { display: flex; flex-direction: column; gap: 12px; padding-bottom: 6px; }
.intro h1 {
  margin: 0;
  font-family: var(--font-display);
  font-stretch: 68%;
  font-weight: 900;
  font-size: clamp(44px, 8vw, 76px);
  line-height: .9;
  text-transform: uppercase;
  color: var(--blue);
  text-wrap: balance;
}
.intro h1 em { font-style: normal; color: var(--orange); }
.intro p { margin: 0; max-width: 62ch; font-size: 17px; line-height: 1.55; }
.intro .strip { font-family: var(--font-mono); font-size: 13px; color: var(--muted); letter-spacing: .3em; overflow-wrap: anywhere; }

.lesson {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(18px, 3vw, 30px);
  display: flex; flex-direction: column; gap: 14px;
  scroll-margin-top: 16px;
}
.eyebrow { font-family: var(--font-mono); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--orange); }
.lesson h2 {
  margin: 0;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-weight: 900;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1;
  text-wrap: balance;
  color: var(--ink);
}
.lesson h3 { margin: 8px 0 0; font-size: 16px; font-weight: 800; color: var(--blue); }
.lesson p, .lesson li { max-width: 66ch; font-size: 16px; line-height: 1.62; margin: 0; }
.lesson ul, .lesson ol { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.num { font-family: var(--font-mono); font-weight: 600; font-size: .92em; word-spacing: -.3em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.hl { color: var(--orange); font-weight: 800; }

.callout {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--tint);
  border-radius: 12px;
  padding: 14px 16px;
}
.callout .icon { color: var(--blue); margin-top: 3px; }
.callout p { font-size: 15px; }

.scroll-x { overflow-x: auto; }
table.t {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  min-width: 100%;
}
table.t th, table.t td { padding: 8px 12px; text-align: center; border-bottom: 1px solid var(--line); font-size: 14px; }
table.t th { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
table.t td.m { font-family: var(--font-mono); font-weight: 600; }
table.t td.l { text-align: left; }
table.t tr.yes td { background: color-mix(in srgb, var(--orange) 14%, transparent); }

/* Posições do decimal (unidade, dezena, centena) */
.places { display: flex; gap: 10px; flex-wrap: wrap; }
.place {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 86px; padding: 12px 10px;
  border-radius: 12px; background: var(--slot);
}
.place b { font-family: var(--font-mono); font-size: 30px; color: var(--blue); }
.place span { font-size: 12px; color: var(--muted); text-align: center; }

/* Linha do tempo */
.timeline { list-style: none; padding: 0 !important; gap: 0 !important; }
.timeline li {
  display: grid; grid-template-columns: 92px 1fr; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--line);
  max-width: none;
}
.timeline li:first-child { border-top: 0; }
.timeline time { font-family: var(--font-mono); font-weight: 800; color: var(--blue); font-size: 14px; padding-top: 3px; }
.timeline strong { display: block; }

/* Tamanhos: bit, nibble, byte */
.sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.size { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.size .cells { display: flex; gap: 3px; flex-wrap: wrap; }
.size .cells i { width: 14px; height: 18px; border-radius: 3px; background: var(--orange); }
.size .cells i.g { margin-left: 5px; }
.size strong { font-size: 18px; }
.size p { font-size: 14px; line-height: 1.45; color: var(--muted); }

/* Escada de potências */
.powers { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.power { border-radius: 10px; background: var(--slot); padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.power b { font-family: var(--font-mono); font-size: clamp(13px, 2.4vw, 18px); color: var(--blue); }
.power span { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.power .bar { width: 70%; background: var(--orange); border-radius: 3px; }

/* Laboratórios interativos */
.lab {
  border: 2px solid var(--blue);
  border-radius: 14px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.lab-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--blue); }
.lab-head .icon { color: var(--orange); }
.lab .grid { grid-template-columns: repeat(4, minmax(0, 1fr)) var(--nib) repeat(4, minmax(0, 1fr)); row-gap: 8px; }
.lab .pv { min-height: 30px; }
.lab .bit { height: 46px; }
.lab-out { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.lab-out .expr { font-family: var(--font-mono); font-size: 14px; color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
.lab-out .res { font-family: var(--font-mono); font-size: 34px; font-weight: 800; color: var(--orange); font-variant-numeric: tabular-nums; }
.lab-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.small-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 7px 12px; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--ink);
}
.small-btn:hover { border-color: var(--orange); }
.lab input[type="number"] {
  width: 110px; padding: 9px 10px;
  border-radius: 8px; border: 2px solid var(--orange);
  background: var(--surface); color: var(--ink);
  font-family: var(--font-mono); font-size: 18px; font-weight: 800;
}
.lab input[type="range"] { flex: 1 1 160px; accent-color: var(--orange); }
.lab label { font-size: 13px; font-weight: 700; color: var(--muted); }

.byte-line { display: flex; gap: 4px; flex-wrap: wrap; font-family: var(--font-mono); font-weight: 800; }
.byte-line span { padding: 5px 7px; border-radius: 6px; background: var(--slot); font-size: 14px; }
.byte-line span.one { background: var(--orange); color: var(--orange-ink); }
.byte-line .sep { background: none; padding: 5px 0; color: var(--muted); }

.swatch { display: inline-block; width: 1em; height: 1em; border-radius: 3px; vertical-align: -2px; background: var(--orange); }

.cta {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--blue); color: #FFFFFF;
  border-radius: 16px; padding: 22px clamp(18px, 3vw, 30px);
}
.cta h2 { margin: 0; font-family: var(--font-display); font-stretch: 72%; font-weight: 900; font-size: 28px; text-transform: uppercase; }
.cta p { margin: 4px 0 0; opacity: .85; }
.cta .btn { flex: 0 0 auto; }

.page-footer { padding-inline: 16px; padding-block: 0 max(28px, env(safe-area-inset-bottom)); }

@keyframes drop { from { transform: translateY(-120%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes clear { 0% { transform: none; opacity: 1; } 40% { transform: scale(1.02); } 100% { transform: translateX(30%) scaleY(.4); opacity: 0; } }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes floatUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-36px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
html { scroll-behavior: smooth; }

@media (max-width: 900px) {
  .learn { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .toc { position: static; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
}
@media (max-width: 560px) {
  .sizes { grid-template-columns: minmax(0, 1fr); }
  .powers { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
/* Celulares: barra superior em uma linha só, cartões mais compactos */
@media (max-width: 480px) {
  .hud-inner { gap: 10px; padding-block: 8px; flex-wrap: nowrap; }
  .page-game .brand { font-size: 21px; }
  .page-game .brand b { display: none; }
  .stats { gap: 10px; }
  .stat span { font-size: 9px; letter-spacing: .08em; }
  .stat strong { font-size: 15px; }
  .hud-btns { gap: 4px; }
  .icon-btn { width: 32px; height: 32px; }
  .stage { gap: 6px; }
  .levelbar { gap: 8px; letter-spacing: .06em; }
  .card { padding: 18px 16px 16px; gap: 12px; border-radius: 14px; }
  .card h2 { font-size: 30px; }
  .big-stats strong { font-size: 18px; }
  .btn { padding: 12px 14px; font-size: 14px; }
  .lesson p, .lesson li { font-size: 15px; }
  .intro p { font-size: 16px; }
  .lab { padding: 12px; }
  .lab .bit { height: 42px; }
  .cta .btn { flex: 1 1 auto; }
}
@media (max-width: 359px) {
  .page-game .brand { display: none; }
  .stats { margin-left: 0; }
  .hud-btns { margin-left: auto; }
}
/* Celular deitado: o tabuleiro de 10 linhas não cabe, pede para girar */
.rotate { display: none; }
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  .page-game .rotate {
    position: fixed; inset: 0; z-index: 20;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    background: var(--bg); color: var(--blue);
    font-weight: 800; text-align: center; padding: 24px;
  }
  .rotate .icon { width: 44px; height: 44px; }
  .rotate p { margin: 0; color: var(--ink); }
}
/* Telas de toque: sem dicas de teclado */
@media (pointer: coarse) {
  .kbd-hint { display: none; }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)) var(--nib) repeat(4, minmax(0, 1fr)) minmax(52px, 1.5fr); }
  .board-wrap { padding: 6px; }
  .ruler { padding-inline: 7px; }
  .bit, .dec, .dec input, .pv { border-radius: 6px; }
  .nav a span { display: none; }
}

/* Expoentes: sobrescrito em fonte de texto, legível em qualquer tamanho */
sup { font-family: var(--font-body); font-weight: 800; font-size: .68em; line-height: 0; vertical-align: .55em; margin-left: 1px; }
.power { justify-content: flex-end; }

/* O nome no topo é o <h1> da página (SEO); display: contents deixa o visual igual ao do link sozinho. */
.brand-title { display: contents; }
