:root {
  --ink: #161310;
  --smoke: #2a2622;
  --fog: #6e736f;
  --paper: #e6e1d6;
  --paper-2: #d8d2c4;
  --panel: #efeae0;
  --brass: #9a7b4f;
  --seal: #7a2f2f;
  --line: rgba(22, 19, 16, 0.18);
  --shadow: 0 12px 28px rgba(18, 16, 12, 0.22);
  --radius: 4px;
  --font: "Source Serif 4", "Times New Roman", serif;
  --display: "Libre Baskerville", "Times New Roman", serif;
  --ui: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* aliases for older class names */
  --navy: var(--smoke);
  --gold: var(--brass);
  --gold-deep: #7d623c;
  --cream: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 50% -5%, rgba(120, 130, 140, 0.28), transparent 55%),
    linear-gradient(180deg, #c5c8c4 0%, var(--paper) 42%, #d2cdc2 100%);
  min-height: 100dvh;
  padding: 52px 0 calc(76px + var(--safe-b));
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(26, 24, 20, 0.94);
  color: var(--paper);
  border-bottom: 1px solid var(--brass);
}

.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.crest {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 1px solid var(--brass);
  background:
    radial-gradient(circle at 50% 45%, var(--seal) 0 34%, transparent 35%),
    #1a1814;
}

.topbar__org {
  margin: 0;
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.65;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}

.topbar__case {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
}

.topbar__nav {
  display: none;
  gap: 16px;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar__nav a { opacity: 0.75; }
.topbar__nav a:hover { opacity: 1; color: var(--brass); }

.hero {
  position: relative;
  min-height: min(88dvh, 780px);
  display: grid;
  align-items: end;
  overflow: hidden;
  color: var(--paper);
}

.hero__media { position: absolute; inset: 0; }
.hero__bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  filter: grayscale(0.45) contrast(1.05) brightness(0.72);
}
.hero__veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(20,18,16,0.35) 0%, rgba(20,18,16,0.2) 40%, rgba(20,18,16,0.9) 100%),
    linear-gradient(90deg, rgba(20,18,16,0.55), transparent 60%);
}

.hero__content {
  position: relative;
  z-index: 1;
  padding: 28px 18px 36px;
  max-width: 720px;
}

.hero__badge {
  display: inline-block;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--ui);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--brass);
}

.hero__brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.1rem, 8vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero__lead {
  margin: 14px 0 0;
  max-width: 34ch;
  font-size: 1.05rem;
  line-height: 1.45;
  color: rgba(230, 225, 214, 0.88);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-family: var(--ui);
  font-weight: 650;
  font-size: 13px;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
}
.btn--gold {
  background: var(--smoke);
  color: var(--paper);
  border-color: var(--brass);
}
.btn--ghost {
  background: transparent;
  border-color: rgba(230, 225, 214, 0.45);
  color: var(--paper);
}
.btn--ghost-dark {
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  border-radius: var(--radius);
  font-family: var(--ui);
  font-weight: 650;
}
.btn--sm { min-height: 38px; padding: 0 12px; font-size: 12px; }

.strip {
  display: grid;
  gap: 14px;
  padding: 22px 16px 8px;
  max-width: 980px;
  margin: 0 auto;
}

.bubble {
  background: var(--panel);
  border: 1px solid var(--ink);
  border-left: 4px solid var(--seal);
  border-radius: var(--radius);
  padding: 14px 16px;
  max-width: 520px;
}
.bubble p { margin: 0; font-size: 1.05rem; font-weight: 600; line-height: 1.35; }
.bubble span {
  display: block;
  margin-top: 8px;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fog);
}

.cast {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.cast__card {
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}
.cast__card strong {
  display: block;
  font-family: var(--display);
  font-size: 13px;
}
.cast__card span {
  display: block;
  margin-top: 4px;
  font-family: var(--ui);
  font-size: 11px;
  color: var(--fog);
}
.cast__card--accent {
  background: var(--smoke);
  color: var(--paper);
  border-color: var(--brass);
}
.cast__card--accent span { color: rgba(230,225,214,0.7); }

.section-head {
  max-width: 680px;
  margin: 0 auto 16px;
  padding: 0 4px;
}
.section-head h2 {
  margin: 6px 0 8px;
  font-family: var(--display);
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  line-height: 1.15;
}
.section-head p { margin: 0; color: #3d3a34; line-height: 1.5; }

.eyebrow {
  margin: 0;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--seal);
}

.comic, .mr, .flow, .closing, .play, .quiz, .badges {
  padding: 26px 16px;
  max-width: 980px;
  margin: 0 auto;
}

.reader {
  background: var(--smoke);
  border-radius: var(--radius);
  padding: 10px;
  border: 1px solid #0d0c0a;
  box-shadow: var(--shadow);
}
.reader__stage {
  position: relative;
  background: #0d0c0a;
  border: 1px solid rgba(154, 123, 79, 0.35);
  overflow: hidden;
}
.reader__stage img {
  width: 100%;
  height: auto;
  display: block;
}
.reader__bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  color: var(--paper);
}
.reader__meta { display: grid; gap: 6px; justify-items: center; }
#pageLabel { font-family: var(--display); font-size: 13px; }
#pageSlider { width: min(100%, 260px); accent-color: var(--brass); }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid rgba(230,225,214,0.25);
  background: transparent;
  color: var(--paper);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.thumbs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 68px;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 2px 2px;
}
.thumbs button {
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  overflow: hidden;
  background: #0d0c0a;
  cursor: pointer;
  opacity: 0.65;
}
.thumbs button.is-active {
  opacity: 1;
  border-color: var(--brass);
}
.thumbs img { width: 68px; height: 48px; object-fit: cover; filter: grayscale(0.3); }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.steps li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 12px;
}
.steps .n {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--brass);
  background: var(--smoke);
  color: var(--paper);
  font-family: var(--display);
  font-weight: 700;
}
.steps p { margin: 0; font-weight: 600; line-height: 1.3; }

.chapters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.chapters button,
.chapters > a.item {
  text-align: left;
  border: 1px solid var(--ink);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  min-height: 78px;
  display: block;
}
.chapters button.is-active {
  background: var(--smoke);
  color: var(--paper);
}
.chapters .num {
  display: block;
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 4px;
}
.chapters strong { display: block; font-family: var(--display); font-size: 13px; line-height: 1.25; }

.panel { display: none; }
.panel.is-active { display: block; }
.panel__hint {
  display: inline-block;
  margin: 0 0 12px;
  padding: 8px 12px;
  background: #ebe4d4;
  border: 1px solid var(--ink);
  border-left: 4px solid var(--seal);
  font-weight: 700;
  font-size: 13px;
}

.stack { display: grid; gap: 8px; }
.item {
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 14px;
}
.item h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.25;
}
.item p { margin: 0; color: #3a3731; line-height: 1.5; font-size: 0.95rem; }

.meta-grid { display: grid; gap: 8px; margin-top: 10px; }
.meta {
  background: #e4dfd2;
  border-radius: 2px;
  padding: 10px 12px;
}
.meta b {
  display: block;
  font-family: var(--ui);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fog);
  margin-bottom: 4px;
}
.meta span { font-size: 0.9rem; font-weight: 600; line-height: 1.4; }

.closing__panel {
  background: var(--smoke);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 26px 18px;
  border: 1px solid var(--brass);
}
.closing__panel .eyebrow { color: var(--brass); }
.closing__panel h2 {
  margin: 8px 0 10px;
  font-family: var(--display);
  font-size: clamp(1.35rem, 4.5vw, 1.9rem);
  line-height: 1.15;
}
.closing__panel p {
  margin: 0 0 16px;
  color: rgba(230,225,214,0.8);
  max-width: 42ch;
  line-height: 1.5;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(10px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 2px;
  padding: 6px;
  border-radius: var(--radius);
  background: rgba(26, 24, 20, 0.95);
  border: 1px solid var(--brass);
}
.dock a {
  color: var(--paper);
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 11px;
}

.game-card {
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.game-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.game-card__head h3 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 1.15rem;
}
.game-text { margin: 0 0 12px; color: #3a3731; line-height: 1.5; font-weight: 600; }
.choices { display: grid; gap: 8px; }
.choice {
  text-align: left;
  border: 1px solid var(--ink);
  background: #f4f0e7;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 650;
  line-height: 1.35;
  cursor: pointer;
}
.choice.is-picked { background: #e7e0d2; border-color: var(--brass); }
.choice.is-correct { background: #dde8d8; border-color: #355538; }
.choice.is-wrong { background: #ead8d4; border-color: var(--seal); }
.feedback {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #ebe4d4;
  border: 1px solid var(--ink);
  border-left: 4px solid var(--seal);
  font-weight: 650;
  line-height: 1.4;
}
.feedback.is-bad { background: #ead8d4; border-left-color: var(--seal); }

.stamp {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border: 2px solid var(--seal);
  color: var(--seal);
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.08em;
  transform: rotate(-12deg);
  background: rgba(239, 234, 224, 0.88);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 55;
  background: var(--smoke);
  color: var(--paper);
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}
.toast.is-on { opacity: 1; }

.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
.hud { display: none; }

.home-simple {
  padding: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}
.simple {
  width: min(100%, 420px);
  padding: 28px 20px;
  text-align: center;
}
.simple h1 {
  margin: 8px 0 12px;
  font-family: var(--display);
  font-size: clamp(2rem, 8vw, 2.8rem);
  line-height: 1.05;
}
.simple__lead {
  margin: 0 0 22px;
  color: #3d3a34;
  font-weight: 600;
}
.simple__actions {
  display: grid;
  gap: 10px;
}
.simple__actions .btn { width: 100%; }
.simple .tiny { margin-top: 18px; }
.home-qr {
  margin: 0 auto 22px;
  width: min(100%, 240px);
  padding: 12px;
  background: #e6e1d6;
  border: 1px solid #0d0c0a;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.home-qr img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}
.home-qr .tiny {
  margin: 10px 0 0;
  color: #3d3a34;
  font-weight: 600;
  line-height: 1.35;
}

.round-results {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.round-results li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--ink);
  background: #f4f0e7;
  font-size: 13px;
  font-weight: 700;
}
.round-results .ok { color: #355538; }
.round-results .bad { color: var(--seal); }

@media (min-width: 760px) {
  body { padding-bottom: 36px; }
  .topbar { padding: 12px 24px; }
  .topbar__nav { display: flex; }
  .dock { display: none; }
  .hero__content { padding: 48px 40px 56px; }
  .strip, .comic, .mr, .flow, .closing, .play { padding-left: 24px; padding-right: 24px; }
  .chapters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .steps li { grid-template-columns: 1fr; text-align: center; min-height: 130px; align-content: center; }
  .steps .n { margin: 0 auto 8px; }
  .cast { max-width: 520px; }
}

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