:root {
  /* Bit Merge voice: warm charcoal, sage match, terracotta heat */
  --paper: #151311;
  --sheet: #1e1b18;
  --ink: #efe8dd;
  --ink-soft: #a39a8c;
  --stamp: #e07a5f;
  --moss: #7fb58a;
  --moss-ink: #151311;
  --ticket: #211e1b;
  --line: #3a352f;
  --pan: #1e1b18;
  --cell: #211e1b;
  --serif: "Fraunces", Georgia, "Iowan Old Style", serif;
  --sans: Inter, system-ui, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.5;
}

::selection {
  background: #4a3226;
  color: var(--ink);
}

.mono {
  font-family: var(--mono);
}

.serif {
  font-family: var(--serif);
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--moss);
  outline-offset: 2px;
}

button,
input {
  font: inherit;
  color: inherit;
  accent-color: var(--moss);
}

.skip {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 10;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--sheet);
  transform: translateY(-150%);
}

.skip:focus {
  transform: none;
}

.shell {
  max-width: 1080px;
  margin: 24px auto 48px;
  background: var(--sheet);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  position: relative;
  overflow: clip;
}

.shell::before {
  content: "";
  display: block;
  height: 8px;
  background: linear-gradient(90deg, #7a4330 0 18%, #964632 18% 36%, #b9553d 36% 54%, #d4614a 54% 72%, #7fb58a 72% 100%);
}

.mast {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 18px 28px 14px;
  border-bottom: 1.5px solid var(--line);
}

.brand {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}

.mast nav {
  display: flex;
  gap: 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.mast a {
  color: var(--ink);
}

.mast a[aria-current="page"] {
  color: var(--moss);
}

.kicker {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--moss);
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

h3 {
  margin: 0 0 4px;
  font-size: 1.55rem;
}

p {
  margin: 0 0 12px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 36px;
  align-items: start;
  padding: 36px 28px 12px;
}

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(3.4rem, 8vw, 6rem);
  line-height: 0.9;
}

.hero h1 em {
  font-style: italic;
  font-weight: 500;
}

.deck {
  max-width: 38rem;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1rem;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}

.button.secondary,
a.button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  box-shadow: none;
}

.button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.best-line {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.tips,
.rules,
.section {
  padding: 8px 28px 28px;
}

.byte-block {
  overflow-x: auto;
  margin: 12px 0 4px;
}

.appliance {
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--pan);
  padding: 16px;
  overflow-x: auto;
}

.demo-order {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.demo-order .lab {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.demo-order strong {
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
}

.demo-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #1a1816;
}

.demo-board.static {
  max-width: 420px;
  margin: 12px 0 4px;
}

.demo-tile {
  aspect-ratio: 1;
  border: 1.5px solid transparent;
  border-radius: 12px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  font: inherit;
  touch-action: manipulation;
}

.demo-board.static .demo-tile {
  cursor: default;
}

.demo-tile.on {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px #efe8dd55;
  transform: translateY(-2px);
}

.demo-tile .v {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.4rem, 4vw, 2rem);
  line-height: 1;
}

.demo-tile .b {
  font-family: var(--mono);
  font-size: 0.75rem;
  opacity: 0.9;
}

.appliance .button {
  margin-top: 12px;
}

.section-head {
  padding: 12px 28px 0;
}

.bench {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
}

.bench li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: baseline;
  border-top: 1.5px solid var(--line);
  padding: 16px 0;
}

.bench .index {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.8rem;
}

.bench h3 a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.bench p {
  margin: 0;
  color: var(--ink-soft);
}

.go,
.later {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.go {
  color: var(--moss);
}

.later {
  color: var(--ink-soft);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  border-top: 1.5px solid var(--line);
  padding-top: 10px;
}

.steps strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.caption {
  color: var(--ink-soft);
}

.colophon {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 28px 22px;
  border-top: 1.5px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.colophon a {
  color: var(--ink);
}

.ruler,
.row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr)) minmax(96px, 148px);
  gap: 6px;
  align-items: stretch;
  animation: none;
}

.ruler {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 1.05rem;
  text-align: center;
}

body[data-game="binary"] .ruler {
  margin: 0 0 8px;
  color: var(--sheet);
  font-size: 1.05rem;
  font-weight: 600;
}

body[data-game="binary"] .ruler .place {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  background: #2a2622;
  color: var(--ink);
  border-radius: 8px;
}

body[data-game="binary"] .ruler .eq {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink);
  font-size: 1.35rem;
}

body[data-game="binary"] .setup {
  display: block;
  padding: 22px 28px 20px;
  border-bottom: 1.5px solid var(--ink);
}

body[data-game="binary"] .setup h1 {
  margin: 0 0 6px;
  font-size: clamp(2.3rem, 4.5vw, 3.3rem);
}

body[data-game="binary"] .banner-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

body[data-game="binary"] .setup .deck {
  margin: 0;
  max-width: 38rem;
  color: var(--ink);
}

body[data-game="binary"] .setup form {
  margin: 0;
  flex: 0 0 auto;
}

body[data-game="binary"] .best-pace {
  margin: 14px 0 0;
  max-width: none;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
}

body[data-game="binary"][data-status="ready"] .hud,
body[data-game="binary"][data-status="ready"] .pressure,
body[data-game="binary"][data-status="ready"] .meter {
  display: none;
}

.ruler .place[data-hidden="true"],
.ruler .eq[data-hidden="true"] {
  color: transparent;
  user-select: none;
}

.ruler .eq {
  align-self: end;
  color: var(--ink);
  font-size: 1rem;
}

.bit {
  display: grid;
  place-items: center;
  height: clamp(68px, 10vw, 88px);
  min-width: 0;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--ticket);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: clamp(1.7rem, 3.4vw, 2.35rem);
  font-weight: 600;
  line-height: 1;
  touch-action: manipulation;
}

button.bit {
  cursor: pointer;
}

button.bit:not(:disabled):hover {
  background: #2a2622;
}

.bit.on {
  background: #2f4434;
  border-color: var(--moss);
  color: var(--ink);
}

.bit:disabled,
.ticket input:disabled {
  opacity: 1;
  cursor: default;
}

.ticket {
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--pan);
}

.ticket.met,
.sum.met {
  background: #2f4434;
}

.target {
  font-family: var(--mono);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 600;
  line-height: 1;
}

.sum,
.left {
  min-height: 1em;
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
}

.sum.exact,
.left.exact {
  color: var(--moss-ink);
}

.sum.over {
  color: var(--stamp);
}

.ticket input {
  width: 100%;
  min-height: 76px;
  border: 0;
  background: transparent;
  text-align: center;
  font-family: var(--mono);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 600;
  padding: 0;
}

.ticket input.wrong {
  color: var(--stamp);
}

.row.selected .ticket {
  box-shadow: inset 0 0 0 2px var(--stamp);
}

.ticket input:focus,
.ticket input:focus-visible {
  outline: none;
}

.row.shake .bit,
.row.shake .ticket {
  animation: shake 180ms ease;
}

.row.clearing {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  animation: none;
}

.lesson {
  grid-column: 1 / -1;
  margin: 0;
  padding: 4px 2px 0;
  font-family: var(--mono);
  font-size: 1.05rem;
  line-height: 1.35;
  color: var(--stamp);
}

.bit.hint {
  box-shadow: inset 0 0 0 3px var(--moss);
}

.bit.miss {
  box-shadow: inset 0 0 0 3px var(--stamp);
  background: #4a2a22;
}

.bit.miss.on {
  background: var(--stamp);
  border-color: var(--stamp);
  color: var(--paper);
}

.guide {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--moss);
  border-radius: 12px;
  background: #2f4434;
  font-family: var(--serif);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.pace-note,
.best-pace {
  max-width: 36rem;
  color: var(--ink-soft);
}

.weak {
  font-family: var(--mono);
  color: var(--stamp);
}

.setup {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 28px;
  padding: 28px 28px 8px;
}

.setup h1 {
  margin: 0 0 10px;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
}

fieldset {
  border: 0;
  margin: 0 0 14px;
  padding: 0;
}

legend {
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.paces {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pace {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-height: 100%;
  padding: 10px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--ticket);
  cursor: pointer;
}

.pace strong,
.pace small {
  display: block;
}

.pace small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.35;
}

.pace:has(input:checked) {
  background: var(--ink);
  color: var(--paper);
}

.pace:has(input:checked) small {
  color: var(--ink-soft);
}

.pace input {
  margin-top: 4px;
}

.results {
  margin: 22px 28px 0;
  padding: 16px 18px 8px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--ticket);
}

.review {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.95rem;
}

.review li {
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.review-note {
  margin-bottom: 4px;
  color: var(--ink-soft);
}

.hud {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: flex-end;
  padding: 12px 28px;
  background: rgba(30, 27, 24, 0.96);
  border-bottom: 1px solid var(--line);
}

.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat span,
.check,
.hud-controls {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stat strong {
  font-family: var(--mono);
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
}

body[data-game="binary"] .hud {
  align-items: start;
  flex-wrap: nowrap;
  column-gap: 32px;
}

body[data-game="binary"] .hud-controls {
  align-items: center;
  height: 2rem;
  margin-top: calc(1rem + 3px);
}

body[data-game="binary"] .stat {
  display: grid;
  grid-template-rows: 1rem 2rem 1rem;
  row-gap: 3px;
  align-content: start;
}

body[data-game="binary"] .stat > span,
body[data-game="binary"] .stat > strong {
  align-self: end;
  line-height: 1;
}

body[data-game="binary"] .mult,
body[data-game="binary"] .pips {
  align-self: start;
  margin-top: 0;
}

.pace-name {
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.pace-name.clock {
  font-size: 2rem;
}

body[data-game="binary"] .pace-name,
body[data-game="binary"] .pace-name.clock {
  font-size: 1.9rem;
}

.mult {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-style: normal;
  color: var(--ink-soft);
}

.mult.hot {
  color: var(--stamp);
}

.mult.pop {
  animation: bump 420ms ease;
}

.pips {
  display: flex;
  gap: 3px;
  margin-top: 5px;
}

.pip {
  width: 8px;
  height: 8px;
  border: 1px solid var(--ink);
  background: transparent;
}

.pip.on {
  background: var(--ink);
}

.gain {
  position: absolute;
  left: calc(100% + 8px);
  top: 16px;
  opacity: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-style: normal;
  color: var(--moss);
  white-space: nowrap;
  pointer-events: none;
}

.gain.pop {
  animation: float 700ms ease forwards;
}

.hud-controls {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.85rem;
}

.check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.85rem;
  color: var(--ink);
}

.hud-controls .button {
  min-height: 36px;
  padding: 0 10px;
  box-shadow: none;
}

.toast {
  flex: 1 0 100%;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--moss);
}

.stage {
  padding: 8px 0 12px;
}

.play-layout {
  display: block;
  padding: 16px 28px 8px;
}

body[data-game="binary"] .shell {
  margin-top: 12px;
}

body[data-game="binary"] .play-layout {
  padding-top: 8px;
  padding-bottom: 0;
}

.play {
  min-width: 0;
}

.play.full .board-wrap {
  outline: 2px solid var(--stamp);
  outline-offset: 3px;
}

.pressure {
  min-height: 1.3em;
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.play.full .pressure {
  color: var(--stamp);
}

.meter {
  height: 8px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: #2a2622;
  overflow: hidden;
  border-radius: 999px;
}

body[data-game="binary"] .meter {
  margin-bottom: 4px;
}

body[data-game="binary"] .pressure {
  margin-bottom: 2px;
}

body:not([data-status="playing"]) .meter {
  visibility: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--stamp);
  transform: scaleX(0);
  transform-origin: left center;
}

.board-wrap {
  position: relative;
  overflow: visible;
  padding-bottom: 4px;
}

.board {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  min-height: 0;
  overflow: visible;
}

.play.topout .board {
  animation: well-hit 640ms ease;
}

.play.topout .board::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: var(--stamp);
  animation: top-flash 640ms ease;
}

.play.ended {
  position: relative;
}

.play.ended::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(13, 12, 11, 0.62);
  pointer-events: none;
  animation: grey-in 480ms ease;
}

.play.ended .board {
  filter: grayscale(0.9);
}

.empty {
  margin: 0;
  color: var(--ink-soft);
}

.keypad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--sheet);
  border-top: 1.5px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
}

.keypad button {
  min-height: 52px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--ticket);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.keypad [data-key="back"] {
  font-family: var(--sans);
  font-size: 1rem;
}

.keypad [data-key="enter"] {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--moss-ink);
  font-family: var(--sans);
  font-size: 1.05rem;
}

body.keypad-open {
  padding-bottom: 292px;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 12, 11, 0.88);
}

.card {
  width: min(100% - 24px, 320px);
  padding: 18px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--pan);
  box-shadow: none;
}

.card h2 {
  font-size: 2rem;
}

.howto {
  margin: 4px 28px 16px;
  padding: 14px 16px 6px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--ticket);
}

.howto h2 {
  font-size: 1.6rem;
}

.howto ol {
  margin: 0 0 10px;
  padding-left: 1.1rem;
}

.howto li + li {
  margin-top: 8px;
}

.keys {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 21;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(260px, calc(100vw - 24px));
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--ticket);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.menu-panel .button {
  width: 100%;
  box-shadow: none;
}

.choose {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(13, 12, 11, 0.88);
}

.choose[hidden] {
  display: none !important;
}

.choose .card h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 2.4rem;
  letter-spacing: -0.04em;
}

.time-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.time-choices .button {
  width: 100%;
  min-height: 56px;
  font-size: 1.25rem;
}

.moment {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(13, 12, 11, 0.88);
  color: var(--ink);
  text-align: center;
}

.moment .kicker {
  color: var(--stamp);
}

.moment strong {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(3.2rem, 12vw, 6rem);
  letter-spacing: -0.04em;
  line-height: 0.9;
}

.tips ul {
  margin: 0;
  padding-left: 1.1rem;
  max-width: 40rem;
}

.tips li + li {
  margin-top: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes well-hit {
  0%, 100% { transform: none; }
  18% { transform: translateY(-10px); }
  36% { transform: translateY(4px); }
  54% { transform: translateY(-5px); }
  72% { transform: translateY(2px); }
}

@keyframes top-flash {
  0%, 100% { opacity: 0; }
  25%, 55% { opacity: 1; }
}

@keyframes grey-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes shake {
  0%,
  100% { transform: translateX(0); }
  30% { transform: translateX(-5px); }
  70% { transform: translateX(5px); }
}

@keyframes float {
  0% { opacity: 0; transform: translateY(6px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-16px); }
}

@keyframes clear-row {
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

@keyframes bump {
  50% { transform: scale(1.28); }
}

@media (max-width: 860px) {
  .hero,
  .setup,
  .play-layout,
  .steps {
    grid-template-columns: 1fr;
  }

  .paces {
    grid-template-columns: 1fr;
  }

  .hud-controls {
    justify-content: flex-start;
  }

  .ruler,
  .row {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .ticket {
    grid-column: 1 / -1;
    min-height: 72px;
  }

  .ticket input {
    min-height: 68px;
    font-size: 2.5rem;
  }

  .target {
    font-size: 2.5rem;
  }

  .ruler {
    font-size: 1rem;
  }

  .ruler .eq {
    display: none;
  }

  .bit {
    height: 80px;
    font-size: 2.15rem;
  }

  body[data-game="binary"] .ruler,
  body[data-game="binary"] .row {
    grid-template-columns: repeat(8, minmax(0, 1fr)) minmax(54px, 68px);
    gap: 3px;
  }

  body[data-game="binary"] .ticket {
    grid-column: auto;
    min-height: 0;
    height: 100%;
    padding: 1px 2px;
  }

  body[data-game="binary"] .bit {
    height: 46px;
    font-size: 1.15rem;
  }

  body[data-game="binary"] .ticket input,
  body[data-game="binary"] .target {
    min-height: 0;
    font-size: 1.05rem;
  }

  body[data-game="binary"] .sum,
  body[data-game="binary"] .left {
    min-height: 0;
    font-size: 0.62rem;
    line-height: 1.1;
  }

  body[data-game="binary"] .ruler {
    margin: 0 0 6px;
    font-size: 0.78rem;
  }

  body[data-game="binary"] .ruler .place {
    min-height: 30px;
  }

  body[data-game="binary"] .ruler .eq {
    display: none;
  }

  body[data-game="binary"] .banner-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  body[data-game="binary"] .setup {
    padding: 16px 16px 14px;
  }

  body[data-game="binary"] .best-pace {
    margin-top: 12px;
  }

  body[data-game="binary"] .board {
    gap: 3px;
  }

  .board {
    gap: 4px;
  }

  .guide {
    font-size: 1.25rem;
  }

  .play-layout,
  .hud {
    padding-left: 8px;
    padding-right: 8px;
  }

  .ruler,
  .row {
    gap: 4px;
  }

  .shell {
    margin: 0 0 32px;
    border-left: 0;
    border-right: 0;
  }

  body[data-game="binary"] .hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr) minmax(0, 1fr);
    align-items: start;
    column-gap: 10px;
    row-gap: 14px;
  }

  body[data-game="binary"] .stat {
    grid-template-rows: 1rem 1.8rem 1rem;
  }

  body[data-game="binary"] .stat > strong,
  body[data-game="binary"] .pace-name,
  body[data-game="binary"] .pace-name.clock {
    font-size: 1.65rem;
  }

  body[data-game="binary"] .hud-controls {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
    align-self: start;
    margin: calc(1rem + 3px) 0 0;
    height: 1.8rem;
    justify-content: flex-end;
  }

  body[data-game="binary"] .toast {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .mast,
  .hero,
  .appliance,
  .byte-block,
  .tips,
  .rules,
  .section,
  .section-head,
  .setup,
  .play-layout,
  .colophon,
  .hud {
    padding-left: 16px;
    padding-right: 16px;
  }

  .bench {
    padding-left: 16px;
    padding-right: 16px;
  }

  .bench li {
    grid-template-columns: auto 1fr;
  }

  .bench .go,
  .bench .later {
    grid-column: 2;
  }

  .results {
    margin-left: 16px;
    margin-right: 16px;
  }

  body[data-game="binary"] .play-layout,
  body[data-game="binary"] .hud {
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* ——— Logic Gate Lab ——— */

.gate-setup .gate-levels {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gate-setup .pace.locked {
  opacity: 0.72;
  background: #2a2622;
}

.unlock-meter {
  margin: 12px 0 8px;
}

.unlock-track {
  height: 8px;
  border: 1px solid var(--ink);
  background: #2a2622;
  overflow: hidden;
  margin-bottom: 6px;
}

.unlock-track span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--moss);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms ease;
}

.unlock-meter p,
.session-unlock {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.session-unlock {
  margin-top: 10px;
}

.pace-check {
  display: inline-flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.gate-stage {
  position: relative;
}

.gate-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.8fr);
  gap: 22px;
  padding: 16px 28px 20px;
}

.expr-banner {
  padding: 14px 16px;
  border: 1.5px solid var(--ink);
  background: var(--ticket);
  margin-bottom: 12px;
}

.expr {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(1.15rem, 3vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  word-break: break-word;
}

.hint-line {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--moss);
}

.bench-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--ticket);
}

.chip.input-chip {
  background: #2f4434;
}

.chip.gate-chip {
  background: #4a2a22;
}

.bench-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bench-actions .button {
  min-height: 38px;
  box-shadow: none;
}

.circuit-board {
  position: relative;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #1a1816;
  min-height: 220px;
  padding: 12px 12px 28px;
  overflow: hidden;
}

.circuit-board.picking {
  min-height: 340px;
}

.circuit-scroll {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px 10px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.schematic-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.schematic {
  display: block;
  max-width: 100%;
  overflow: visible;
}

.sch-wire {
  stroke: #efe8dd;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: square;
}

.sch-wire[data-signal="0"] {
  stroke: #a39a8c;
}

.sch-wire[data-signal="1"] {
  stroke: var(--moss);
  stroke-width: 2.6;
}

.circuit-board.pulse .sch-wire[data-signal="1"] {
  animation: wire-pulse 700ms ease;
}

.sch-dot {
  fill: #efe8dd;
  stroke: none;
}

.sch-dot[data-signal="1"] {
  fill: var(--moss);
}

.gate-body {
  stroke: #efe8dd;
  pointer-events: none;
}

.gate-body path,
.gate-body polygon,
.gate-body circle,
.gate-body rect {
  stroke: inherit;
}

.sch-gate[data-signal="1"] .gate-body {
  stroke: var(--moss);
}

.circuit-board.pulse .sch-gate[data-signal="1"] .gate-body {
  animation: gate-flash 700ms ease;
}

.sch-hit {
  fill: transparent;
  stroke: none;
  cursor: pointer;
  touch-action: manipulation;
}

.sch-hit:focus,
.sch-port:focus {
  outline: none;
}

.sch-hit:focus-visible {
  stroke: var(--stamp);
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

.sch-port {
  fill: #efe8dd;
  stroke: #1a1816;
  stroke-width: 1.5;
  cursor: pointer;
  touch-action: manipulation;
}

.sch-port.empty {
  fill: #1a1816;
  stroke: #efe8dd;
  stroke-width: 2;
  stroke-dasharray: 3 2;
}

.sch-port:focus-visible {
  stroke: var(--stamp);
  stroke-width: 3;
  stroke-dasharray: none;
}

.sch-input-label,
.sch-output-label,
.gate-fallback-label {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  fill: #efe8dd;
  pointer-events: none;
}

.sch-bit {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  fill: var(--moss);
  pointer-events: none;
}

.lamp-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding-right: 4px;
}

.lamp {
  position: relative;
  width: 64px;
  height: 64px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: #3a352f;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.lamp-glass {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: #2a2622;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.lamp[data-on="1"] .lamp-glass {
  background: #f2d56b;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.35),
    0 0 0 4px rgba(242, 213, 107, 0.25);
}

.lamp[data-celebrate="1"] {
  animation: lamp-pop 900ms ease;
}

.lamp-label {
  position: absolute;
  bottom: -1.35rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.picker {
  position: absolute;
  inset: 8px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1.5px solid var(--ink);
  background: rgba(30, 27, 24, 0.97);
  box-shadow: 4px 4px 0 var(--ink);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100% - 16px);
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  flex: 0 0 auto;
}

.picker-grid button {
  min-height: 44px;
  border: 1.5px solid var(--ink);
  background: var(--ticket);
  font-family: var(--mono);
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
}

@media (max-width: 640px) {
  .circuit-board {
    min-height: 300px;
  }

  .picker {
    inset: 6px;
    padding: 10px;
    gap: 8px;
  }

  .picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .picker-grid button {
    min-height: 40px;
    font-size: 0.84rem;
  }

  .palette .chip {
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .bench-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .bench-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bench-actions #check {
    grid-column: 1 / -1;
  }
}

.picker-grid button:hover {
  background: #fff;
}

.feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--ink);
  background: var(--ticket);
}

.feedback.ok {
  background: #2f4434;
}

.feedback.bad {
  background: #4a2a22;
}

.feedback-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 1.25rem;
}

.feedback ul {
  margin: 0 0 8px;
  padding-left: 1.1rem;
  font-family: var(--mono);
  font-size: 0.88rem;
}

.feedback .button {
  margin-top: 4px;
}

.anim-bar {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.anim-status {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--ink-soft);
  min-height: 1.3em;
}

.anim-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.anim-controls .button {
  min-height: 36px;
  box-shadow: none;
}

.gate-side .truth-panel,
.gate-side .gate-glossary {
  margin-bottom: 16px;
}

.truth-wrap {
  overflow-x: auto;
  border: 1.5px solid var(--ink);
  background: var(--ticket);
}

.truth {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.92rem;
}

.truth th,
.truth td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.truth th {
  background: #2a2622;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.truth tr.active {
  background: #2f4434;
  outline: 2px solid var(--moss);
  outline-offset: -2px;
}

.truth tr.mismatch {
  background: #4a2a22;
}

.truth tr.ok .out-cell {
  color: var(--moss);
  font-weight: 600;
}

.truth td[data-bit="1"] {
  font-weight: 600;
}

.gate-glossary ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gate-glossary li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.gate-glossary strong {
  color: var(--ink);
  font-family: var(--mono);
}

.speed-meter {
  width: 72px;
  height: 6px;
  margin-top: 5px;
  border: 1px solid var(--ink);
  background: #2a2622;
  overflow: hidden;
}

.speed-meter span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--stamp);
  transform-origin: left center;
  transform: scaleX(1);
}

.celebrate {
  position: relative;
  margin-top: 10px;
  min-height: 0;
}

.celebrate-banner {
  margin: 0;
  padding: 10px 14px;
  border: 1.5px solid var(--ink);
  background: var(--moss);
  color: var(--moss-ink);
  font-family: var(--serif);
  font-size: 1.6rem;
  text-align: center;
}

.celebrate.show .celebrate-banner {
  animation: banner-in 500ms ease;
}

.celebrate.show::before,
.celebrate.show::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--stamp);
  background: #f2d56b;
  animation: spark 700ms ease forwards;
}

.celebrate.show::before { left: 12%; }
.celebrate.show::after { right: 12%; animation-delay: 80ms; }

.unlock-overlay .unlock-card {
  text-align: left;
}

.unlock-card h2 {
  color: var(--stamp);
}

@keyframes wire-pulse {
  0%, 100% { stroke-width: 2.6; }
  40% { stroke-width: 3.6; }
}

@keyframes gate-flash {
  0%, 100% { stroke-width: 2.2; }
  40% { stroke-width: 3.4; }
}

@keyframes lamp-pop {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.08); }
}

@keyframes banner-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes spark {
  0% { opacity: 0; transform: translateY(0) scale(0.6); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px) scale(1.2); }
}

@media (max-width: 860px) {
  .gate-layout,
  .gate-setup .gate-levels {
    grid-template-columns: 1fr;
  }

  .lamp-wrap {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  .gate-layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .bench-actions {
    width: 100%;
  }

  .bench-actions .button {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .celebrate.show::before,
  .celebrate.show::after {
    display: none;
  }

  .lamp[data-on="1"] .lamp-glass {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  }

}

/* ——— Hex Match ——— */

body[data-game="hex"] .ruler,
body[data-game="hex"] .row {
  gap: 6px;
  align-items: stretch;
}

body[data-game="hex"] .ruler[data-width="4"],
body[data-game="hex"] .row[data-width="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(96px, 148px);
}

body[data-game="hex"] .ruler[data-width="8"],
body[data-game="hex"] .row[data-width="8"] {
  grid-template-columns: repeat(8, minmax(0, 1fr)) minmax(96px, 148px);
}

body[data-game="hex"] .ruler {
  margin: 0 0 8px;
  color: var(--sheet);
  font-size: 1.05rem;
  font-weight: 600;
}

body[data-game="hex"] .ruler .place {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  background: #2a2622;
  color: var(--ink);
  border-radius: 8px;
}

body[data-game="hex"] .ruler .eq {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink);
  font-size: 1.35rem;
}

body[data-game="hex"] .bit.nibble-gap,
body[data-game="hex"] .ruler .place.nibble-gap {
  margin-right: 10px;
}

body[data-game="hex"] .ticket .target.hex {
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

body[data-game="hex"] .hex-keys {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
}

body[data-game="hex"] .hex-keys [data-key="back"] {
  grid-column: span 2;
}

body[data-game="hex"] .hex-keys [data-key="enter"] {
  grid-column: span 2;
}

body[data-game="hex"][data-status="ready"] .hud,
body[data-game="hex"][data-status="ready"] .pressure,
body[data-game="hex"][data-status="ready"] .meter {
  display: none;
}

@media (max-width: 720px) {
  body[data-game="hex"] .ruler[data-width="4"],
  body[data-game="hex"] .row[data-width="4"] {
    grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(54px, 68px);
    gap: 3px;
  }

  body[data-game="hex"] .ruler[data-width="8"],
  body[data-game="hex"] .row[data-width="8"] {
    grid-template-columns: repeat(8, minmax(0, 1fr)) minmax(54px, 68px);
    gap: 3px;
  }

  body[data-game="hex"] .bit {
    height: 46px;
    font-size: 1.15rem;
  }

  body[data-game="hex"] .ticket input,
  body[data-game="hex"] .target {
    min-height: 0;
    font-size: 1.05rem;
  }

  body[data-game="hex"] .sum {
    min-height: 0;
    font-size: 0.62rem;
    line-height: 1.1;
  }

  body[data-game="hex"] .bit.nibble-gap,
  body[data-game="hex"] .ruler .place.nibble-gap {
    margin-right: 6px;
  }

  body[data-game="hex"] .ruler .eq {
    display: none;
  }
}

/* ——— Bit Merge ——— */

body[data-game="bit-merge"] .shell {
  max-width: 520px;
  margin-top: 12px;
}

body[data-game="bit-merge"] .bm-main {
  padding-bottom: 8px;
}

.bm-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 14px 14px 8px;
}

.bm-hd {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bm-pause {
  width: 48px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.bm-pause span {
  display: inline-flex;
  gap: 4px;
}

.bm-pause i {
  display: inline-block;
  width: 4px;
  height: 16px;
  background: var(--ink);
  border-radius: 1px;
}

.bm-lv span {
  display: block;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.2;
}

.bm-lv b {
  font: 700 24px/1.1 var(--serif);
}

.bm-stats {
  margin-left: auto;
  display: flex;
  gap: 14px;
  text-align: center;
}

.bm-stats span {
  display: block;
  color: var(--ink-soft);
  font-size: 13px;
}

.bm-stats b {
  font: 500 19px var(--mono);
  white-space: nowrap;
}

.bm-ticket {
  margin-top: 14px;
  background: var(--pan);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px 14px;
  transition: border-color 0.2s;
}

.bm-ticket.hit {
  border-color: var(--moss);
}

.bm-ticket.shake {
  animation: shake 0.3s;
}

.bm-trow {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.bm-lab {
  color: var(--ink-soft);
  font-size: 14px;
}

.bm-ticket .order {
  font: 700 clamp(44px, 13vw, 64px)/1 var(--serif);
  margin-top: 4px;
}

.bm-ticket .order.bin {
  font: 700 clamp(28px, 8.6vw, 44px)/1.1 var(--mono);
  margin-top: 8px;
}

.bm-next {
  text-align: right;
}

.bm-next div {
  margin-top: 4px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 2px 10px;
  font: 600 22px var(--serif);
  color: var(--ink-soft);
}

.bm-next div.bin {
  font: 500 18px var(--mono);
}

.bm-reg {
  display: grid;
  grid-template-columns: repeat(var(--n, 8), minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.bm-reg div {
  border: 1.5px solid var(--line);
  border-radius: 8px;
  text-align: center;
  padding: 4px 0 2px;
  font: 500 12px var(--mono);
  color: var(--ink-soft);
  transition: background 0.15s;
}

.bm-reg div::before {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  margin: 2px auto 4px;
  border-radius: 50%;
  background: var(--ink-soft);
}

.bm-reg div.on {
  background: #3b3a2c;
  color: var(--ink);
}

.bm-reg div.on::before {
  background: var(--ink);
  width: 8px;
  height: 8px;
  margin-top: 0;
  margin-bottom: 3px;
}

.bm-reg div.on.ok {
  background: #2f4434;
  border-color: var(--moss);
}

.bm-reg div.on.no {
  background: #4a2a22;
  border-color: var(--stamp);
}

.bm-reg div.want {
  border-color: #6d6455;
}

.bm-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.bm-msg {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font: 500 13px var(--mono);
  color: var(--ink-soft);
}

body[data-game="bit-merge"] #clear {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  color: var(--ink-soft);
  background: transparent;
  min-height: 46px;
  font: 600 17px var(--sans);
  cursor: pointer;
}

.bm-eq {
  height: 30px;
  margin: 8px 0 6px;
  text-align: center;
  font: 500 15px var(--mono);
  color: var(--moss);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.bm-eq.over {
  color: var(--stamp);
}

.bm-eq .fly {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  border: 2px solid var(--moss);
  border-radius: 999px;
  padding: 0 14px;
  font: 700 28px var(--serif);
  color: var(--moss);
  background: #151311cc;
  animation: bm-fly 1s ease-out forwards;
  pointer-events: none;
}

@keyframes bm-fly {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -26px); }
}

.bm-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  padding: 9px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #1a1816;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.bm-board .cell {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--cell);
}

.bm-board .tile {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  color: var(--ink);
}

.bm-board .tile .v {
  font: 700 clamp(26px, 8.5vw, 40px)/1 var(--serif);
}

.bm-board .tile .b {
  font: 500 clamp(9px, 2.6vw, 13px) var(--mono);
  opacity: 0.9;
  white-space: nowrap;
}

.bm-board .tile .d {
  display: flex;
  gap: 2px;
  margin-top: 3px;
}

.bm-board .tile .d i {
  width: clamp(4px, 1.3vw, 7px);
  height: 3px;
  border-radius: 2px;
  background: #ffffff40;
}

.bm-board .tile .d i.m {
  background: #fff;
  height: 6px;
  width: 6px;
  margin-top: -1.5px;
  border-radius: 1px;
}

.bm-board .tile.sel {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px #efe8dd55;
  transform: translateY(-3px);
}

.bm-board .tile.hint {
  animation: bm-glow 1s ease-in-out 3;
}

@keyframes bm-glow {
  50% { box-shadow: 0 0 0 4px var(--moss); }
}

.bm-board .tile.pop {
  animation: bm-pop 0.2s ease-out 0.13s backwards;
}

@keyframes bm-pop {
  from { transform: scale(0.5); opacity: 0; }
}

.bm-board .slide {
  position: relative;
  z-index: 2;
}

.bm-board .ghost {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  transition: transform 0.13s cubic-bezier(0.3, 0.7, 0.4, 1), opacity 0.13s;
}

.bm-board .tile.mg {
  animation: bm-wiggle 0.5s ease-in-out 0.12s;
}

@keyframes bm-wiggle {
  0% { transform: none; }
  15% { transform: scale(1.14) rotate(-9deg); }
  30% { transform: scale(1.12) rotate(8deg); }
  45% { transform: scale(1.08) rotate(-6deg); }
  60% { transform: scale(1.05) rotate(4deg); }
  75% { transform: rotate(-2deg); }
  90% { transform: rotate(1deg); }
  100% { transform: none; }
}

.bm-ctl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.bm-ctl button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 10px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: 600 17px var(--sans);
  cursor: pointer;
}

.bm-ctl button:disabled {
  opacity: 0.35;
  cursor: default;
}

.bm-ctl svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.bm-tip {
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
  margin: 12px 0 0;
}

.bm-ov {
  position: fixed;
  inset: 0;
  background: #0d0c0bea;
  display: none;
  place-items: center;
  padding: 20px;
  z-index: 5;
}

.bm-ov.on {
  display: grid;
}

.bm-card {
  width: min(400px, 100%);
  background: var(--pan);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  max-height: 92vh;
  overflow: auto;
}

.bm-card h2 {
  font: 700 28px var(--serif);
  margin: 0 0 6px;
}

.bm-card p {
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.bm-card .lvl {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.bm-card .lvl button {
  text-align: left;
  display: block;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: 600 17px var(--sans);
  height: auto;
  cursor: pointer;
}

.bm-card .lvl button.cur {
  border-color: var(--moss);
}

.bm-card .lvl small {
  display: block;
  color: var(--ink-soft);
  font-weight: 400;
  font-size: 13px;
}

.bm-card .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.bm-card .row button {
  min-height: 46px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: 600 17px var(--sans);
  cursor: pointer;
}

.bm-card .go {
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

.bm-card ul {
  color: var(--ink-soft);
  padding-left: 18px;
  margin: 0 0 14px;
  font-size: 15px;
}

@media (max-width: 380px) {
  .bm-stats {
    gap: 9px;
  }

  .bm-stats b {
    font-size: 16px;
  }

  .bm-lv b {
    font-size: 20px;
  }
}

@media (max-width: 640px) {
  body[data-game="bit-merge"] .shell {
    border-radius: 0;
  }
}

/* ——— Hex Defender ——— */

body[data-game="hex-defender"] {
  --hd-bg: #0b0714;
  --hd-pan: #151022;
  --hd-line: #2c2342;
  --hd-ink: #f3eefc;
  --hd-soft: #9d92b8;
  --hd-mint: #5ef2c2;
  --hd-coral: #ff7a59;
  --hd-gold: #ffd166;
  --hd-ice: #8fb8ff;
  --hd-bad: #ff4d6d;
  --hd-display: "Chakra Petch", system-ui, sans-serif;
}

body[data-game="hex-defender"] .hd-shell {
  max-width: 560px;
  margin-top: 12px;
  background: var(--hd-bg);
  border-color: var(--hd-line);
}

body[data-game="hex-defender"] .mast {
  border-bottom-color: var(--hd-line);
}

body[data-game="hex-defender"] .mast a[aria-current="page"] {
  color: var(--hd-mint);
}

body[data-game="hex-defender"] .colophon {
  border-top-color: var(--hd-line);
}

.hd-main {
  padding-bottom: 4px;
}

.hd-app {
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 720px);
  padding: 0 10px 10px;
}

.hd-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px 8px;
}

.hd-ic {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--hd-line);
  background: var(--hd-pan);
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  color: var(--hd-ink);
  cursor: pointer;
}

.hd-ic svg {
  width: 20px;
  height: 20px;
}

.hd-build {
  margin-left: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #5ef2c266;
  background: #5ef2c218;
  color: #5ef2c2;
  font: 700 11px/1 var(--mono, "JetBrains Mono", monospace);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  white-space: nowrap;
}

.hd-st {
  display: flex;
  gap: 12px;
  margin-left: auto;
  text-align: right;
}

.hd-st span {
  display: block;
  font-size: 11px;
  color: var(--hd-soft);
  text-transform: lowercase;
  font-family: var(--mono);
}

.hd-st b {
  font: 700 19px var(--hd-display);
  white-space: nowrap;
  color: var(--hd-ink);
}

body[data-game="hex-defender"] #lives {
  color: var(--hd-bad);
}

body[data-game="hex-defender"] #gold {
  color: var(--hd-gold);
}

.hd-field {
  position: relative;
  flex: 1;
  min-height: 280px;
  border-radius: 18px;
  overflow: hidden;
  border: 1.5px solid var(--hd-line);
  background: radial-gradient(120% 80% at 50% 110%, #2a1745 0%, #120b20 55%, #0b0714 100%);
  touch-action: manipulation;
}

.hd-field canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hd-tip {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--hd-soft);
  background: #0b0714cc;
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
  max-width: 52%;
  font-family: var(--mono);
  z-index: 1;
}

.hd-next {
  position: absolute;
  right: 10px;
  top: 10px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--hd-gold);
  background: #0b0714e6;
  color: var(--hd-gold);
  font: 700 15px var(--hd-display);
  display: none;
  cursor: pointer;
  z-index: 1;
  text-align: left;
}

.hd-next.on {
  display: block;
}

.hd-next small {
  font: 500 11px var(--mono);
  color: var(--hd-soft);
  display: block;
  margin-top: -2px;
}

.hd-pop {
  position: absolute;
  width: 196px;
  background: #151022f5;
  border: 1.5px solid var(--hd-line);
  border-radius: 14px;
  padding: 8px;
  display: none;
  z-index: 2;
  box-shadow: 0 10px 30px #0008;
  color: var(--hd-ink);
  font-family: var(--mono);
}

.hd-pop.on {
  display: block;
}

.hd-pop h3 {
  margin: 2px 4px 6px;
  font: 700 15px var(--hd-display);
  color: var(--hd-ink);
}

.hd-pop button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--hd-line);
  border-radius: 10px;
  background: #0b0714;
  padding: 4px 8px;
  margin-top: 5px;
  text-align: left;
  font-size: 13px;
  color: var(--hd-ink);
  cursor: pointer;
  font-family: var(--mono);
}

.hd-pop button:disabled {
  opacity: 0.4;
  cursor: default;
}

.hd-pop button i {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex: none;
}

.hd-pop button span {
  flex: 1;
  line-height: 1.15;
}

.hd-pop button span small {
  display: block;
  color: var(--hd-soft);
  font-size: 11px;
}

.hd-pop button em {
  font-style: normal;
  color: var(--hd-gold);
  font-weight: 700;
  white-space: nowrap;
}

.hd-pop-max {
  margin: 4px;
  font-size: 12px;
  color: var(--hd-soft);
}

.hd-banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.hd-banner.go {
  animation: hd-ban 2.2s ease-out;
}

.hd-banner b {
  display: block;
  font: 700 clamp(34px, 10vw, 52px)/1 var(--hd-display);
  color: var(--hd-gold);
  text-shadow: 0 0 24px #ffd16688;
}

.hd-banner span {
  display: inline-block;
  margin-top: 8px;
  font-size: 14px;
  color: var(--hd-ink);
  background: #0b0714cc;
  padding: 4px 12px;
  border-radius: 999px;
  font-family: var(--mono);
}

@keyframes hd-ban {
  0% { opacity: 0; transform: scale(0.8); }
  12% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.hd-typed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 8px;
  min-height: 62px;
  font-family: var(--mono);
  position: relative;
}

.hd-typed .hd-p {
  color: var(--hd-mint);
  font: 700 20px var(--mono);
}

.hd-typed .hd-cb {
  position: absolute;
  right: 4px;
  font: 700 18px var(--hd-display);
  color: var(--hd-gold);
}

.hd-slot {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid var(--hd-line);
  display: grid;
  place-items: center;
  font: 700 26px var(--hd-display);
  background: var(--hd-pan);
  color: var(--hd-ink);
}

.hd-slot.f {
  border-color: var(--hd-mint);
  color: var(--hd-mint);
  box-shadow: 0 0 14px #5ef2c244;
}

.hd-typed.bad .hd-slot {
  border-color: var(--hd-bad);
  color: var(--hd-bad);
}

.hd-typed.bad {
  animation: hd-sh 0.28s;
}

@keyframes hd-sh {
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.hd-keys {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.hd-k {
  height: clamp(50px, 8.5vh, 64px);
  border-radius: 11px;
  border: 1.5px solid var(--hd-line);
  background: linear-gradient(#1e1630, #151022);
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 0;
  color: var(--hd-ink);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.hd-k b {
  font: 700 clamp(20px, 5.6vw, 26px)/1 var(--hd-display);
}

.hd-k small {
  font-size: 10px;
  color: var(--hd-soft);
  line-height: 1.2;
  margin-top: 2px;
  font-family: var(--mono);
}

.hd-k.hit {
  background: var(--hd-mint);
  color: #0b0714;
  border-color: var(--hd-mint);
}

.hd-k.hit small {
  color: #0b0714;
}

.hd-ov {
  position: fixed;
  inset: 0;
  background: #0b0714e6;
  display: none;
  place-items: center;
  padding: 18px;
  z-index: 5;
  overflow: auto;
}

.hd-ov.on {
  display: grid;
}

.hd-card {
  width: min(420px, 100%);
  background: var(--hd-pan);
  border: 1.5px solid var(--hd-line);
  border-radius: 20px;
  padding: 22px;
  color: var(--hd-ink);
  font-family: var(--mono);
}

.hd-card h1 {
  font: 700 clamp(40px, 12vw, 58px)/0.95 var(--hd-display);
  margin: 0;
  color: var(--hd-mint);
  text-shadow: 0 0 30px #5ef2c255;
}

.hd-card h2 {
  font: 700 30px var(--hd-display);
  margin: 0 0 4px;
  color: var(--hd-ink);
}

.hd-card p {
  color: var(--hd-soft);
  margin: 10px 0;
}

.hd-card ul {
  color: var(--hd-soft);
  padding-left: 18px;
  margin: 10px 0;
  font-size: 14px;
}

.hd-card li {
  margin: 4px 0;
}

.hd-card li b {
  color: var(--hd-ink);
}

.hd-mint {
  color: var(--hd-mint);
}

.hd-start-label {
  margin-bottom: 4px !important;
}

.hd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 16px;
}

.hd-chips button {
  border: 1.5px solid var(--hd-line);
  background: transparent;
  border-radius: 999px;
  min-height: 40px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--hd-ink);
  cursor: pointer;
  font-family: var(--mono);
}

.hd-chips button.on {
  border-color: var(--hd-mint);
  color: var(--hd-mint);
}

.hd-play {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 14px;
  background: var(--hd-mint);
  color: #0b0714;
  font: 700 22px var(--hd-display);
  cursor: pointer;
}

.hd-sec {
  width: 100%;
  min-height: 46px;
  border: 1.5px solid var(--hd-line);
  background: transparent;
  border-radius: 14px;
  margin-top: 8px;
  font-weight: 700;
  color: var(--hd-ink);
  cursor: pointer;
  font-family: var(--mono);
}

.hd-best {
  text-align: center;
  margin-bottom: 0 !important;
}

.hd-big {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.hd-big div {
  background: #0b0714;
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}

.hd-big b {
  display: block;
  font: 700 24px var(--hd-display);
  color: var(--hd-ink);
}

.hd-big span {
  font-size: 11px;
  color: var(--hd-soft);
}

.hd-miss-label {
  margin-bottom: 4px !important;
}

.hd-miss {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 14px;
}

.hd-miss span {
  background: #0b0714;
  border: 1px solid var(--hd-line);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.hd-miss em {
  font-style: normal;
  color: var(--hd-mint);
}

@media (max-width: 640px) {
  body[data-game="hex-defender"] .hd-shell {
    border-radius: 0;
  }

  .hd-app {
    min-height: min(78vh, 780px);
  }
}

/* ——— Logic Heist ——— */

body[data-game="logic-heist"] {
  --lh-bg: #0b100e;
  --lh-pan: #121a17;
  --lh-line: #24332d;
  --lh-ink: #eef3ea;
  --lh-soft: #8fa398;
  --lh-sig: #a6ff4d;
  --lh-brass: #e8b04a;
  --lh-red: #ff4f5e;
  --lh-display: Bungee, system-ui, sans-serif;
  --lh-body: "IBM Plex Sans", system-ui, sans-serif;
  --lh-mono: "IBM Plex Mono", ui-monospace, monospace;
}

body[data-game="logic-heist"] .lh-shell {
  max-width: 580px;
  margin-top: 12px;
  background: var(--lh-bg);
  border-color: var(--lh-line);
}

body[data-game="logic-heist"] .mast {
  border-bottom-color: var(--lh-line);
}

body[data-game="logic-heist"] .mast a[aria-current="page"] {
  color: var(--lh-brass);
}

body[data-game="logic-heist"] .colophon {
  border-top-color: var(--lh-line);
}

body[data-game="logic-heist"] .tips h2 {
  font-family: var(--lh-display);
  font-weight: 400;
  color: var(--lh-brass);
}

.lh-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 12px 8px;
  font-family: var(--lh-body);
  color: var(--lh-ink);
}

.lh-hd {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lh-ic {
  width: 46px;
  height: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
  border: 1.5px solid var(--lh-line);
  border-radius: 12px;
  background: transparent;
  color: var(--lh-ink);
  cursor: pointer;
}

.lh-hd h1 {
  font: 400 22px/1.1 var(--lh-display);
  margin: 0;
  color: var(--lh-brass);
  letter-spacing: 0.02em;
}

.lh-sub {
  font: 500 13px var(--lh-mono);
  color: var(--lh-soft);
}

.lh-rt {
  margin-left: auto;
  text-align: right;
  font: 500 13px var(--lh-mono);
  color: var(--lh-soft);
}

.lh-rt b {
  display: block;
  font: 700 20px var(--lh-mono);
  color: var(--lh-ink);
}

.lh-story {
  margin-top: 12px;
  background: var(--lh-pan);
  border: 1.5px solid var(--lh-line);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 15px;
  color: #cdd9d1;
}

.lh-story b {
  color: var(--lh-brass);
}

.lh-board {
  position: relative;
  margin-top: 12px;
  border: 1.5px solid var(--lh-line);
  border-radius: 16px;
  background: radial-gradient(130% 90% at 80% 0%, #16231e, #0b100e 70%);
  overflow: hidden;
}

.lh-board::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(#ffffff06 1px, transparent 1px),
    linear-gradient(90deg, #ffffff06 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

.lh-board svg {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.lh-board .w {
  fill: none;
  stroke: #34463e;
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke 0.2s;
}

.lh-board .w.on {
  stroke: var(--lh-sig);
  filter: drop-shadow(0 0 4px #a6ff4d99);
}

.lh-board .flow {
  fill: none;
  stroke: #efffd6;
  stroke-width: 2;
  stroke-dasharray: 3 14;
  animation: lh-flow 0.7s linear infinite;
  opacity: 0.9;
}

@keyframes lh-flow {
  to { stroke-dashoffset: -17; }
}

.lh-board .g path,
.lh-board .g circle.b {
  fill: #1b2722;
  stroke: #7d9488;
  stroke-width: 2;
  transition: fill 0.2s, stroke 0.2s;
}

.lh-board .g.on path,
.lh-board .g.on circle.b {
  stroke: var(--lh-sig);
  fill: #22361a;
}

.lh-board .g text {
  font: 700 10px var(--lh-mono);
  fill: var(--lh-soft);
  text-anchor: middle;
}

.lh-board .g {
  cursor: pointer;
}

.lh-board .g.slot path {
  stroke-dasharray: 4 3;
  stroke: var(--lh-brass);
}

.lh-board .g.slot rect {
  fill: #2a2213;
  stroke: var(--lh-brass);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.lh-board .g .q {
  font: 700 22px var(--lh-display);
  fill: var(--lh-brass);
}

.lh-board .sw {
  cursor: pointer;
}

.lh-board .sw rect.t {
  fill: #1b2722;
  stroke: #7d9488;
  stroke-width: 2;
  transition: fill 0.2s;
}

.lh-board .sw circle {
  fill: #9fb1a7;
  transition: transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1), fill 0.2s;
}

.lh-board .sw.on rect.t {
  fill: #30501c;
  stroke: var(--lh-sig);
}

.lh-board .sw.on circle {
  fill: var(--lh-sig);
  transform: translateX(18px);
}

.lh-board .sw text {
  font: 700 15px var(--lh-mono);
  fill: var(--lh-ink);
}

.lh-board .sw text.v {
  font-size: 11px;
  fill: var(--lh-soft);
}

.lh-board .lock circle.dial {
  fill: #1d1a12;
  stroke: #6d5a33;
  stroke-width: 3;
  transition: fill 0.3s, stroke 0.3s;
}

.lh-board .lock .spk {
  stroke: #6d5a33;
  stroke-width: 3;
  transition: transform 0.6s cubic-bezier(0.3, 1.3, 0.5, 1);
}

.lh-board .lock.on circle.dial {
  fill: #3d2f10;
  stroke: var(--lh-brass);
  filter: drop-shadow(0 0 10px #e8b04aaa);
}

.lh-board .lock.on .spk {
  stroke: var(--lh-brass);
  transform: rotate(180deg);
}

.lh-board .lock text,
.lh-board .alarm text {
  font: 700 10px var(--lh-mono);
  text-anchor: middle;
  fill: var(--lh-soft);
}

.lh-board .lock.on text.s {
  fill: var(--lh-brass);
}

.lh-board .alarm path {
  fill: #2a1416;
  stroke: #6b3036;
  stroke-width: 2.5;
}

.lh-board .alarm.on path {
  fill: var(--lh-red);
  stroke: #ffb3ba;
  animation: lh-siren 0.4s steps(2) infinite;
}

.lh-board .alarm.on text.s {
  fill: var(--lh-red);
}

@keyframes lh-siren {
  50% { fill: #7a1c24; }
}

.lh-board.alarmed {
  animation: lh-redflash 0.5s 2;
}

@keyframes lh-redflash {
  50% {
    box-shadow: inset 0 0 0 999px #ff4f5e22;
    border-color: var(--lh-red);
  }
}

.lh-panel {
  margin-top: 12px;
  background: var(--lh-pan);
  border: 1.5px solid var(--lh-line);
  border-radius: 14px;
  padding: 12px 14px;
}

.lh-goal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  font: 500 14px var(--lh-mono);
  color: var(--lh-soft);
}

.lh-goal b {
  color: var(--lh-ink);
}

.lh-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  border: 1.5px solid var(--lh-line);
  white-space: nowrap;
}

.lh-pill.ok {
  border-color: var(--lh-sig);
  color: var(--lh-sig);
}

.lh-pill.bad {
  border-color: var(--lh-red);
  color: var(--lh-red);
}

.lh-heat {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
}

.lh-heat i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #2a3a33;
  display: inline-block;
}

.lh-heat i.h {
  background: var(--lh-red);
  box-shadow: 0 0 6px var(--lh-red);
}

.lh-panel table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font: 500 14px var(--lh-mono);
  text-align: center;
}

.lh-panel th {
  color: var(--lh-soft);
  font-weight: 500;
  font-size: 12px;
  padding: 4px;
}

.lh-panel td {
  padding: 5px 4px;
  border-top: 1px solid var(--lh-line);
}

.lh-panel tr.cur td {
  background: #a6ff4d14;
}

.lh-panel td.pass,
.lh-toast td.pass {
  color: var(--lh-sig);
}

.lh-panel td.fail {
  color: var(--lh-red);
}

.lh-panel td.need {
  color: var(--lh-brass);
  font-weight: 700;
}

.lh-fail {
  margin: 8px 0 0;
  color: var(--lh-red);
  font: 500 14px var(--lh-mono);
}

.lh-ctl {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.lh-ctl button,
.lh-ov button {
  font: 600 16px var(--lh-body);
  color: var(--lh-ink);
  background: transparent;
  border: 1.5px solid var(--lh-line);
  border-radius: 12px;
  min-height: 46px;
  padding: 0 14px;
  cursor: pointer;
}

.lh-ctl button {
  flex: 1;
}

.lh-go {
  background: var(--lh-brass) !important;
  color: #1a1205 !important;
  border-color: var(--lh-brass) !important;
}

.lh-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 20px);
  background: #1b2722;
  border: 1.5px solid var(--lh-line);
  border-radius: 14px;
  padding: 10px 14px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 4;
  width: min(92vw, 360px);
  font-size: 14px;
  color: var(--lh-ink);
  font-family: var(--lh-body);
}

.lh-toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.lh-toast table {
  margin-top: 6px;
  width: 100%;
  border-collapse: collapse;
  font: 500 13px var(--lh-mono);
  text-align: center;
}

.lh-toast-t {
  color: var(--lh-brass);
  font-family: var(--lh-mono);
}

.lh-ov {
  position: fixed;
  inset: 0;
  background: #070b09ee;
  display: none;
  place-items: center;
  padding: 16px;
  z-index: 5;
  overflow: auto;
}

.lh-ov.on {
  display: grid;
}

.lh-card {
  width: min(460px, 100%);
  background: var(--lh-pan);
  border: 1.5px solid var(--lh-line);
  border-radius: 20px;
  padding: 20px;
  max-height: 94vh;
  overflow: auto;
  color: var(--lh-ink);
  font-family: var(--lh-body);
}

.lh-card h2 {
  font: 400 30px/1.05 var(--lh-display);
  margin: 0 0 6px;
  color: var(--lh-brass);
}

.lh-card p {
  color: var(--lh-soft);
  margin: 6px 0 12px;
}

.lh-center {
  text-align: center;
}

.lh-brass {
  color: var(--lh-brass);
}

.lh-red {
  color: var(--lh-red);
}

.lh-vaults {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.lh-vaults button {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid #6d5a33;
  background: radial-gradient(circle at 35% 30%, #3a3220, #16130c);
  display: grid;
  place-content: center;
  gap: 0;
  padding: 0;
  color: var(--lh-brass);
  min-height: 0;
}

.lh-vaults button b {
  font: 400 20px var(--lh-display);
  line-height: 1;
}

.lh-vaults button small {
  font: 700 11px var(--lh-mono);
  letter-spacing: 0.1em;
}

.lh-vaults button.done {
  border-color: var(--lh-brass);
}

.lh-vaults button.fix {
  border-style: dashed;
}

.lh-rush {
  width: 100%;
  margin-top: 4px;
  background: var(--lh-red) !important;
  border-color: var(--lh-red) !important;
  color: #fff !important;
  font: 400 18px var(--lh-display) !important;
}

.lh-rush-note,
.lh-stars-total {
  font-size: 13px;
  margin: 6px 0 10px;
  color: var(--lh-soft);
}

.lh-full {
  width: 100%;
}

.lh-door {
  width: 130px;
  height: 130px;
  margin: 6px auto 10px;
  perspective: 400px;
}

.lh-door div {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 6px solid var(--lh-brass);
  background: radial-gradient(circle, #3d2f10 0 18%, #1d1a12 19% 60%, #2a2416 61%);
  transform-origin: left center;
  animation: lh-swing 1.1s 0.2s cubic-bezier(0.3, 1, 0.4, 1) forwards;
  box-shadow: 0 0 30px #e8b04a66;
}

@keyframes lh-swing {
  to { transform: rotateY(-70deg); }
}

.lh-stars {
  text-align: center;
  font: 400 34px var(--lh-display);
  letter-spacing: 6px;
  color: #3a3220;
}

.lh-stars .y {
  color: var(--lh-brass);
}

.lh-gl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.lh-gl div {
  background: #0b100e;
  border-radius: 12px;
  padding: 8px;
}

.lh-gl svg {
  width: 70px;
  height: 40px;
  display: block;
}

.lh-gl b {
  font: 700 13px var(--lh-mono);
  color: var(--lh-brass);
}

.lh-gl-desc {
  font-size: 12px;
  color: var(--lh-soft);
}

.lh-gl .g path,
.lh-gl .g circle.b {
  fill: #1b2722;
  stroke: #7d9488;
  stroke-width: 2;
}

.lh-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 640px) {
  body[data-game="logic-heist"] .lh-shell {
    border-radius: 0;
  }
}

/* ——— Large screens: Bit Merge, Hex Defender, Logic Heist ——— */

@media (min-width: 900px) {
  body[data-game="bit-merge"] .shell {
    max-width: 1040px;
    margin-top: 28px;
  }

  body[data-game="bit-merge"] .bm-wrap {
    max-width: 980px;
    padding: 22px 28px 18px;
    display: grid;
    grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.15fr);
    column-gap: 28px;
    row-gap: 12px;
    align-items: start;
  }

  .bm-hd {
    grid-column: 1 / -1;
  }

  .bm-ticket {
    grid-column: 1;
    margin-top: 0;
  }

  .bm-bar,
  .bm-eq {
    grid-column: 1;
  }

  .bm-board {
    grid-column: 2;
    grid-row: 2 / 5;
    max-width: none;
    margin: 0;
    gap: 12px;
    padding: 12px;
  }

  .bm-ctl {
    grid-column: 1 / -1;
    max-width: 560px;
  }

  .bm-tip {
    grid-column: 1 / -1;
  }

  .bm-ticket .order {
    font-size: clamp(52px, 5.5vw, 76px);
  }

  .bm-ticket .order.bin {
    font-size: clamp(34px, 3.6vw, 52px);
  }

  .bm-board .tile .v {
    font-size: clamp(34px, 3.8vw, 54px);
  }

  .bm-board .tile .b {
    font-size: clamp(11px, 1.3vw, 15px);
  }

  .bm-board .tile .d i {
    width: 7px;
    height: 4px;
  }

  .bm-ctl button {
    min-height: 52px;
    font-size: 18px;
  }

  .bm-stats b {
    font-size: 22px;
  }

  .bm-lv b {
    font-size: 28px;
  }

  .bm-card {
    width: min(480px, 100%);
  }

  body[data-game="hex-defender"] .hd-shell {
    max-width: 1120px;
    margin-top: 28px;
  }

  .hd-app {
    min-height: min(86vh, 920px);
    padding: 0 18px 18px;
    gap: 10px;
  }

  .hd-field {
    min-height: 420px;
  }

  .hd-st b {
    font-size: 22px;
  }

  .hd-k {
    height: clamp(56px, 7vh, 72px);
  }

  .hd-k b {
    font-size: clamp(22px, 2.2vw, 30px);
  }

  .hd-k small {
    font-size: 11px;
  }

  .hd-slot {
    width: 52px;
    height: 52px;
    font-size: 30px;
  }

  .hd-card {
    width: min(480px, 100%);
  }

  .hd-banner b {
    font-size: clamp(40px, 5vw, 64px);
  }

  body[data-game="logic-heist"] .lh-shell {
    max-width: 1120px;
    margin-top: 28px;
  }

  .lh-wrap {
    max-width: 1060px;
    padding: 18px 22px 14px;
  }

  .lh-hd h1 {
    font-size: 28px;
  }

  .lh-story {
    font-size: 16px;
  }

  .lh-ctl button,
  .lh-ov button {
    min-height: 50px;
    font-size: 17px;
  }
}

@media (min-width: 1020px) {
  .hd-app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: stretch;
    column-gap: 16px;
    row-gap: 8px;
  }

  .hd-hud {
    grid-column: 1 / -1;
  }

  .hd-field {
    grid-column: 1;
    grid-row: 2 / 4;
    min-height: 560px;
  }

  .hd-typed {
    grid-column: 2;
    grid-row: 2;
    padding: 4px 0 8px;
    align-self: start;
  }

  .hd-keys {
    grid-column: 2;
    grid-row: 3;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-self: end;
  }

  .hd-k {
    height: 68px;
  }

  .lh-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
    column-gap: 18px;
    row-gap: 12px;
    align-items: start;
  }

  .lh-hd,
  .lh-story,
  .lh-ctl {
    grid-column: 1 / -1;
  }

  .lh-board {
    grid-column: 1;
    margin-top: 0;
    min-height: 320px;
  }

  .lh-panel {
    grid-column: 2;
    margin-top: 0;
    position: sticky;
    top: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lh-board .flow,
  .lh-board .alarm.on path,
  .lh-board.alarmed,
  .lh-door div {
    animation: none !important;
  }
}
