/* Family Guessing Games: mobile-first styles. No external resources. */
:root {
  --bg: #fff7ec;
  --surface: #ffffff;
  --ink: #1b2430;
  --muted: #566274;
  --line: #e4dccd;
  --primary: #4f3df0;
  --primary-ink: #ffffff;
  --accent: #ff7a1a;
  --good: #0f7a55;
  --good-bg: #e3f7ee;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --stage: #eef2f6;
  --radius: 16px;
  --shadow: 0 2px 0 rgba(27, 36, 48, .08), 0 8px 20px rgba(27, 36, 48, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.45;
  /* Safe-area insets so nothing hides under notches or the home bar. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px 48px;
  min-height: 100vh;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--primary); }

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

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

.notice {
  padding: 24px 8px;
  text-align: center;
  color: var(--muted);
}

.error-box {
  background: var(--bad-bg);
  border: 2px solid var(--bad);
  border-radius: var(--radius);
  padding: 18px;
  margin: 20px 0;
  text-align: center;
}
.error-box p + p { margin-top: 10px; }

/* ---------- Generic buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .2);
  transition: transform .08s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.btn.secondary { background: var(--surface); color: var(--primary); border: 2px solid var(--primary); box-shadow: none; }
.btn.big { width: 100%; min-height: 52px; font-size: 19px; }
.btn[disabled] { opacity: .5; cursor: default; }

.link-btn {
  background: none;
  border: 0;
  padding: 0 4px;
  min-height: 44px;
  color: var(--muted);
  text-decoration: underline;
  font-size: 16px;
}

/* ---------- Home ---------- */
.home-head { text-align: center; padding: 18px 0 14px; }
.home-head h1 { font-size: clamp(24px, 7.6vw, 34px); line-height: 1.1; letter-spacing: -.5px; white-space: nowrap; }
.home-head p { color: var(--muted); margin-top: 8px; font-size: 18px; }

.deck-list { display: grid; gap: 14px; margin: 12px 0 18px; }

.deck-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 4px 14px;
  align-items: center;
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  min-height: 88px;
}
.deck-card:active { transform: translateY(1px); }
.deck-card .emoji { grid-row: span 3; font-size: 44px; text-align: center; line-height: 1; }
.deck-card h2 { font-size: 20px; line-height: 1.2; }
.deck-card .blurb { color: var(--muted); font-size: 17px; }
.deck-card .progress { font-weight: 700; color: var(--primary); font-size: 16px; }
.deck-card.done .progress { color: var(--good); }
.deck-card.unavailable { opacity: .6; pointer-events: none; }

.home-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  padding-top: 6px;
}
.home-foot a, .home-foot .link-btn { color: var(--muted); font-size: 16px; min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Play header ---------- */
.play-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.back-btn {
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.play-head .title {
  font-weight: 800;
  font-size: 17px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.pill-stat {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid var(--line);
  font-weight: 800;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.pill-stat.hot { border-color: var(--accent); background: #fff1e4; }

/* ---------- Image stage: fixed 16:10 box, never shifts layout ---------- */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--stage);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--line);
}
.stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.stage .img-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 12px;
}

/* ---------- Clues ---------- */
.section-label {
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--muted);
}
.clues { list-style: none; margin: 0; padding: 0; counter-reset: clue; display: grid; gap: 8px; }
.clues li {
  counter-increment: clue;
  position: relative;
  padding: 10px 12px 10px 46px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 14px;
  font-size: 18px;
}
.clues li::before {
  content: counter(clue);
  position: absolute;
  left: 10px;
  top: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: grid;
  place-items: center;
}
.clues li.extra::before { background: var(--accent); }
.clues li b { display: block; }
.clues li.fade-in { animation: fadeUp .5s ease both; }

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

/* ---------- Already tried ---------- */
.tried { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.tried[hidden] { display: none; }
.tried .label { font-size: 14px; font-weight: 800; letter-spacing: .06em; color: var(--muted); margin-right: 2px; }
.tried .chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bad-bg);
  color: var(--bad);
  border: 1px solid #f0b9b4;
  font-size: 16px;
  font-weight: 600;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* ---------- Typeahead + input ---------- */
.play-area { margin-top: 14px; }
.play-area[hidden], .lifelines[hidden], .reveal-wrap[hidden], .result[hidden] { display: none; }

/* Height reserved so the layout never jumps when pills appear. */
.typeahead {
  display: flex;
  gap: 8px;
  height: 48px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  margin-bottom: 4px;
}
.typeahead::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}
.pill:active { background: var(--primary); color: #fff; }

.guess-form { display: flex; gap: 8px; }
.guess-form input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 52px;
  padding: 0 14px;
  font-size: 18px; /* 18px prevents iOS focus zoom */
  background: #fff;
  border: 2px solid #9aa5b5;
  border-radius: 14px;
}
.guess-form input:focus { border-color: var(--primary); outline: 3px solid rgba(79, 61, 240, .25); }
.guess-form .btn { flex: 0 0 auto; min-height: 52px; background: var(--good); }
.shake { animation: shake .3s ease; border-color: var(--bad) !important; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ---------- Multiple choice ---------- */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  min-height: 64px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: 18px;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 0 rgba(79, 61, 240, .25);
}
.choice:active:not([disabled]) { transform: translateY(2px); box-shadow: none; }
.choice.wrong { background: var(--bad-bg); border-color: #e3a29d; color: var(--bad); text-decoration: line-through; box-shadow: none; opacity: .9; }
.choice.dim { opacity: .35; box-shadow: none; border-color: var(--line); }
.choice[disabled] { cursor: default; }
.choice-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.choice-tools .btn { min-height: 44px; font-size: 16px; padding: 6px 16px; background: var(--accent); color: #1b2430; }

/* ---------- Lifelines ---------- */
.lifelines { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.lifeline {
  min-height: 52px;
  padding: 6px 8px;
  border-radius: 14px;
  border: 2px solid var(--accent);
  background: #fff1e4;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.2;
}
.lifeline[disabled] { opacity: .55; border-color: var(--line); background: #f4f0e8; cursor: default; }

.reveal-wrap { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); text-align: center; }
.reveal-wrap .link-btn { color: var(--muted); font-size: 16px; }
.reveal-wrap .link-btn.armed { color: var(--bad); font-weight: 700; }

/* ---------- Result (compact: answer, then the facts, right under the picture) ---------- */
.result { margin-top: 8px; display: grid; gap: 8px; }
.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 2px solid var(--good);
  background: var(--good-bg);
}
.answer-head.revealed { border-color: var(--line); background: #f1ece0; }
.answer-head .answer-text { min-width: 0; }
.answer-head .praise { font-size: 14px; font-weight: 800; color: var(--good); line-height: 1.2; }
.answer-head.revealed .praise { color: var(--muted); }
.answer-head h2 { font-size: 22px; line-height: 1.15; overflow-wrap: anywhere; margin: 0; }
.answer-head .stars { font-size: 16px; letter-spacing: 1px; color: #e69500; white-space: nowrap; flex: none; }
.answer-head .stars .off { color: #c9c2b2; }
.fact-card { background: #fff; border: 2px solid var(--primary); border-radius: 14px; padding: 10px 12px; font-size: 17px; line-height: 1.4; }
.fact-card h3 { font-size: 13px; letter-spacing: .08em; color: var(--primary); margin: 0 0 2px; text-transform: uppercase; }
.fact-card p { margin: 0; }
.fact-card p + p { margin-top: 6px; }
.img-credit { text-align: center; font-size: 12px; margin: 14px 0 0; color: var(--muted); }
.img-credit a { color: var(--muted); }

/* ---------- Summary ---------- */
.summary { text-align: center; padding-top: 18px; display: grid; gap: 14px; }
.summary h1 { font-size: 30px; }
.summary .big-emoji { font-size: 64px; line-height: 1; }
.summary .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 8px; }
.stat-box .num { font-size: 30px; font-weight: 800; color: var(--primary); }
.stat-box .lbl { color: var(--muted); font-size: 16px; }
.summary .actions { display: grid; gap: 10px; }

/* ---------- Credits ---------- */
.credits h1 { font-size: 28px; margin: 8px 0; }
.credits .intro { color: var(--muted); margin-bottom: 8px; }
.credits h2 { font-size: 20px; margin: 20px 0 8px; }
.credit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.credit-list li { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 16px; overflow-wrap: anywhere; }
.credit-list li b { display: block; }
.credit-list .meta { color: var(--muted); }

@media (min-width: 560px) {
  .app { padding-top: 28px; }
}

/* Motion off for anyone who asks. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .shake { border-color: var(--bad) !important; }
}

/* Confetti layer sits above everything and never takes taps. */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- Phone space savers ---------- */
@media (max-width: 559px) { .app { padding-top: 8px; } }
.section-label { margin: 10px 0 4px; font-size: 12px; }
.clues { gap: 6px; }
.clues li { padding: 8px 10px 8px 40px; font-size: 17px; line-height: 1.35; border-radius: 12px; }
.clues li::before { left: 8px; top: 8px; width: 24px; height: 24px; font-size: 14px; }
.clues li b { display: inline; }
.clues li b::after { content: ": "; }
/* Keep the guess box in reach: while typing, it sticks to the bottom of the screen. */
.play-area:has(> div:first-child:not([hidden])) {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: var(--bg);
  margin: 0 -16px;
  padding: 6px 16px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 12px -8px rgba(27, 36, 48, .18);
}
@media (max-width: 559px) {
  .section-label { display: none; }
  .clues { margin-top: 8px; }
  .play-head { margin-bottom: 6px; }
  .pill-stat, .play-head .back { min-height: 32px; font-size: 15px; }
}
/* The suggestion row only takes space when it has pills (the sticky bar floats, so nothing jumps). */
.typeahead:empty { height: 0; margin: 0; }
.play-area + .lifelines { margin-top: 6px; }

/* ---------- Group chooser + grouped summary ---------- */
.chooser h1 { font-size: 28px; line-height: 1.15; margin: 12px 0 4px; }
.chooser .deck-card { min-height: 72px; }
.chooser .deck-card .emoji { grid-row: span 2; }
.chooser .deck-card h2 { overflow-wrap: anywhere; }
.summary .actions .link-btn { justify-self: center; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Home sections + compact tiles ---------- */
.deck-section .deck-list { gap: 10px; margin: 8px 0 6px; }
.section-head {
  margin: 18px 0 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.deck-section:first-child .section-head { margin-top: 6px; }
.home-sections + .home-foot { margin-top: 14px; }
.deck-section .deck-card {
  grid-template-columns: 44px 1fr;
  gap: 1px 12px;
  padding: 10px 14px;
  min-height: 64px;
}
.deck-section .deck-card .emoji { font-size: 34px; }
.deck-section .deck-card h3 { font-size: 18px; line-height: 1.2; }
.deck-section .deck-card .blurb { font-size: 15px; line-height: 1.3; }
.deck-section .deck-card .progress { font-size: 15px; }

/* ---------- Question banner ---------- */
.prompt { margin: 0 0 8px; line-height: 1.15; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.prompt-lead { font-size: 15px; font-weight: 600; color: var(--muted); }
.prompt-name { font-size: 28px; font-weight: 800; letter-spacing: -.3px; overflow-wrap: anywhere; }
.prompt-name.size-long { font-size: 22px; }
.prompt-name.size-xlong { font-size: 19px; }
.prompt-tail { font-size: .85em; font-weight: 800; white-space: nowrap; }
.prompt-name { text-wrap: balance; }

/* ---------- Map and text stages (same 16:10 box as the picture stage) ---------- */
.stage-map svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-region { fill: #c7d4e4; stroke: #fff; stroke-width: 2.2; stroke-linejoin: round; }
.map-region.is-highlight { fill: var(--primary); }
.map-region.is-reveal { fill: var(--good); }
.map-ring circle { fill: none; }
.map-ring .ring-halo { stroke: #fff; stroke-width: 10; }
.map-ring .ring-line { stroke: var(--primary); stroke-width: 5; }
.map-ring.is-reveal .ring-line { stroke: var(--good); }
.map-star-shape {
  fill: #ffc400;
  stroke: #1b2430;
  stroke-width: 3.5;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  animation: starPulse 1.6s ease-in-out infinite;
}
.map-star.is-done .map-star-shape { animation: none; }
@keyframes starPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.map-label text { font-family: inherit; font-weight: 800; }
.map-label-halo { fill: #fff; stroke: #fff; stroke-width: 9; stroke-linejoin: round; }
.map-label-text { fill: var(--ink); }

.stage-text { display: grid; place-items: center; padding: 10px 14px; text-align: center; }
.stage-name { font-size: 46px; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; color: var(--ink); overflow-wrap: anywhere; }
.stage-name.size-long { font-size: 32px; }
.stage-name.size-xlong { font-size: 26px; }

/* Text-only cards: the stage shows the name, so the banner keeps just its lead-in. */
.prompt.prompt-leadonly { margin-bottom: 4px; }
.prompt.prompt-leadonly .prompt-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.prompt.prompt-leadonly .prompt-lead { font-size: 16px; }

/* Home: one plain how-to line under the tagline. */
.home-head .home-how { font-size: 15px; color: var(--muted); margin-top: 6px; }
