:root {
  --bg: #f3eee4;
  --bg-warm: #ebe4d6;
  --surface: #faf7f0;
  --ink: #1a1916;
  --ink-soft: #3a372f;
  --muted: #6f6a60;
  --line: #ddd6c8;
  --forest: #1b4d3e;
  --forest-deep: #12352c;
  --forest-fg: #f4efe4;
  --star: #c4a035;
  --flag-red: #9b2335;
  --ok: #2f6b4f;
  --danger: #8f2d2d;
  --display: "Fraunces", "Georgia", "Iowan Old Style", serif;
  --sans: "Figtree", "Segoe UI", system-ui, sans-serif;
  --shadow: 0 0 0 1px rgba(26, 25, 22, 0.06), 0 1px 2px -1px rgba(26, 25, 22, 0.06);
  --mark: #3a2ed6;
  --grade: #19164f;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button:not(:disabled), [role="button"] { cursor: pointer; }

.kente {
  height: 4px;
  background: linear-gradient(90deg, var(--flag-red) 0 33.3%, var(--star) 33.3% 66.6%, var(--forest) 66.6% 100%);
}

/* App logo — blue book mark + Grade / Masta lockup */
.gm-mark {
  display: block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.gm-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.gm-lockup {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.05;
}
.gm-grade,
.gm-masta {
  display: block;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.035em;
}
.gm-grade { color: var(--grade); }
.gm-masta { color: var(--mark); }
.gm-word {
  display: block;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}
.gm-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.gm-logo.invert .gm-grade { color: var(--forest-fg); }
.gm-logo.invert .gm-masta { color: #c4c9ff; }
.gm-logo.invert .gm-word { color: var(--forest-fg); }
.gm-logo.invert .gm-sub { color: rgba(244, 239, 228, 0.7); }

.brandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 15;
}

.share-hit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--forest);
  color: var(--forest-fg);
  font-weight: 600;
  font-size: 0.9rem;
}
.share-hit.ghost {
  background: var(--bg-warm);
  color: var(--ink);
}
.share-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 72px;
  z-index: 40;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow), 0 12px 40px rgba(26, 25, 22, 0.16);
  padding: 8px;
}
.share-sheet[hidden] { display: none; }
.share-sheet h3 {
  margin: 8px 12px 4px;
  font-size: 1rem;
}
.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-align: left;
}
.share-row:hover, .share-row:focus { background: var(--bg-warm); }
.share-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--forest);
  color: var(--forest-fg);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.share-dot.wa { background: #1b4d3e; }
.share-dot.fb { background: #0f4c5c; }
.share-dot.x { background: #1a1916; }
.share-dot.copy { background: var(--bg-warm); color: var(--ink); }

.wrap { max-width: 512px; margin: 0 auto; padding: 20px 16px 108px; }
h1, h2 { font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.eyebrow { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 16px; margin: 0; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.play-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.play-tile {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}
.play-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--forest);
  flex-shrink: 0;
}
.play-title { font-weight: 600; margin: 0; }
.stack { display: grid; gap: 28px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 0;
  background: var(--forest); color: var(--forest-fg); font-weight: 600;
}
.btn.star { background: var(--star); color: var(--ink); }
.btn.ghost { background: var(--bg-warm); color: var(--ink); }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.45; }
.choice {
  display: flex; gap: 10px; width: 100%; text-align: left; min-height: 48px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 10px 12px;
}
.choice.ok { border-color: var(--ok); background: #e7efe9; }
.choice.bad { border-color: var(--danger); background: #f8ecec; }
.letter {
  width: 28px; height: 28px; border-radius: 8px; background: var(--bg-warm);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
input, select, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); padding: 8px 12px; color: var(--ink);
}
textarea { min-height: 88px; resize: vertical; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 10px 0 6px; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(250,247,240,0.96);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--muted); gap: 2px;
}
.nav a.on { color: var(--forest); }
.hero { min-height: 100vh; background: var(--forest); color: var(--forest-fg); }
.hero .wrap { padding-top: 48px; max-width: 512px; }
.hero input, .hero select {
  background: var(--forest-deep); color: var(--forest-fg); border-color: rgba(244,239,228,0.2);
}
.hero .muted { color: rgba(244,239,228,0.7); }
.pick {
  border: 1px solid rgba(244,239,228,0.15); background: rgba(18,53,44,0.4); color: var(--forest-fg);
  border-radius: 12px; padding: 12px; text-align: left; min-height: 64px; width: 100%;
}
.pick.on { border-color: var(--star); background: var(--forest-deep); }
.hall-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.avatar {
  width: 48px; height: 48px; border-radius: 999px; background: var(--forest);
  color: var(--forest-fg); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.prize-btn {
  width: 48px; height: 48px; border-radius: 16px; background: var(--star); color: var(--ink);
  display: grid; place-items: center; flex-shrink: 0;
}
.rankbar {
  border-radius: 24px; background: linear-gradient(135deg, var(--forest), var(--forest-deep));
  color: var(--forest-fg); padding: 20px 8px; display: grid; grid-template-columns: 1fr 1fr 1fr;
}
.rankbar > div { text-align: center; border-left: 1px solid rgba(255,255,255,0.15); }
.rankbar > div:first-child { border-left: 0; }
.rankbar .lbl { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(244,239,228,0.7); }
.rankbar .num { font-family: var(--display); font-size: 1.85rem; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.zone-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.zone-head a { font-size: 14px; font-weight: 600; color: var(--forest); }
.quiz-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-radius: 16px; padding: 16px; box-shadow: var(--shadow);
}
.quiz-row + .quiz-row { margin-top: 8px; }
.chev { font-size: 22px; color: var(--muted); }
.tile {
  min-height: 144px; background: var(--surface); border-radius: 16px; padding: 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: space-between;
}
.tile p { margin: 4px 0 0; }
.contest { background: var(--surface); border-radius: 16px; padding: 32px 16px; text-align: center; box-shadow: var(--shadow); }
.list { display: grid; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.opt { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.opt input[type="text"] { flex: 1; }
.prog { height: 6px; background: var(--bg-warm); border-radius: 99px; overflow: hidden; }
.prog > span { display: block; height: 100%; background: var(--forest); }
.alert { border-left: 4px solid var(--danger); }
.okbox { border-left: 4px solid var(--ok); }
@media (min-width: 800px) {
  .wrap { padding-top: 28px; }
}

html[data-hall="cocoa"] {
  --bg: #f6efe4; --bg-warm: #eadcc8; --surface: #fbf6ee; --ink: #2a1c12;
  --ink-soft: #4a3424; --muted: #7a624c; --line: #e2d2bc;
  --forest: #5c3317; --forest-deep: #3d220f; --forest-fg: #f7efe4;
}
html[data-hall="volta"] {
  --bg: #eaf3f1; --bg-warm: #d5e6e2; --surface: #f4faf8; --ink: #12211e;
  --ink-soft: #2b403c; --muted: #5b736e; --line: #c9ddd8;
  --forest: #0f4c5c; --forest-deep: #0a3340; --forest-fg: #eef7f5;
}
html[data-hall="night"] {
  --bg: #121614; --bg-warm: #1c2320; --surface: #1a211e; --ink: #ece7dc;
  --ink-soft: #d4cfc3; --muted: #9a958a; --line: #2c3531;
  --forest: #2f6b54; --forest-deep: #1b3d32; --forest-fg: #f4efe4;
}
html[data-bg="paper"] body {
  background-image: repeating-linear-gradient(transparent, transparent 27px, rgba(26,25,22,0.08) 27px, rgba(26,25,22,0.08) 28px);
}
html[data-bg="kente"] body {
  background-image: repeating-linear-gradient(90deg, color-mix(in srgb, var(--flag-red) 14%, var(--bg)) 0 10px, color-mix(in srgb, var(--star) 16%, var(--bg)) 10px 20px, color-mix(in srgb, var(--forest) 12%, var(--bg)) 20px 32px);
}
html[data-bg="mesh"] body {
  background-image: radial-gradient(at 12% 0%, color-mix(in srgb, var(--forest) 20%, transparent), transparent 46%), radial-gradient(at 92% 8%, color-mix(in srgb, var(--star) 16%, transparent), transparent 40%);
}
html[data-kente="off"] .kente { display: none; }
html[data-serif="off"] { --display: var(--sans); }
html[data-density="compact"] .stack { gap: 16px; }
html[data-corners="soft"] .card,
html[data-corners="soft"] .tile,
html[data-corners="soft"] .quiz-row,
html[data-corners="soft"] .contest,
html[data-corners="soft"] .rankbar,
html[data-corners="soft"] .share-sheet { border-radius: 12px; }
html[data-corners="sharp"] .card,
html[data-corners="sharp"] .tile,
html[data-corners="sharp"] .quiz-row,
html[data-corners="sharp"] .contest,
html[data-corners="sharp"] .rankbar,
html[data-corners="sharp"] .share-sheet { border-radius: 8px; }
html[data-type="large"] { font-size: 17.5px; }
html[data-card="flat"] { --shadow: 0 0 0 1px rgba(26, 25, 22, 0.1); }
html[data-bar="forest"] .nav,
html[data-bar="forest"] .hall-bar {
  background: var(--forest);
  border-top-color: transparent;
}
html[data-bar="forest"] .nav a { color: rgba(244,239,228,0.72); }
html[data-bar="forest"] .nav a.on { color: var(--star); }
html[data-motion="still"] *,
html[data-motion="still"] *::before,
html[data-motion="still"] *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}
.swatch { display:block; height:28px; border-radius:8px; margin-bottom:8px; }
.swatch-forest { background:#1b4d3e; }
.swatch-cocoa { background:#5c3317; }
.swatch-volta { background:#0f4c5c; }
.swatch-night { background:#121614; box-shadow: inset 0 0 0 1px #2c3531; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
