/* Chanukah Escape — "Bright and playful" (same family as the landing page).
   Warm cream page, bold blue and orange, sunny yellow, thick ink outlines with hard sticker shadows.
   The old navy and gold look is saved in backup-navy-look/. One-column phone app; the camera screen is full-bleed with a bottom sheet. */
:root {
  --night: #fff7e6;      /* page: warm cream (matches theme-color in build.sh) */
  --night-2: #ffffff;    /* cards */
  --night-3: #ffffff;    /* buttons / inputs */
  --edge: #1b2145;       /* hard sticker shadow */
  --ink: #1b2145;
  --muted: #555a78;
  --gold: #ffc93c;       /* sunny yellow fill */
  --gold-hi: #1a2f96;    /* strong accent text */
  --gold-deep: #1b2145;
  --gold-line: #1b2145;  /* outlines */
  --accent: #2a4bd7;     /* headings, selected states */
  --sky: #dfe8ff;
  --sun-soft: #fff0bf;
  --pink: #e8457c;
  --flame: #ff7a1a;
  --blue: #2a4bd7;
  --olive: #1f9d62;
  --good: #14804e;
  --bad: #c92a1e;
  --line: rgba(27, 33, 69, .22);
  --display: "Baloo 2", "Rubik", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Nunito", "Rubik", -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background-color: var(--night);
  background-image: radial-gradient(rgba(42, 75, 215, .07) 1.5px, transparent 1.6px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.1; text-wrap: balance; margin: 0; font-weight: 700; }
p { margin: 0; }
b, strong { color: var(--gold-hi); font-weight: 800; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--flame); outline-offset: 3px; }
::selection { background: var(--gold); color: var(--ink); }

.wrap {
  max-width: 560px; margin: 0 auto;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  padding-block: 22px 44px;
  display: flex; flex-direction: column; gap: 20px;
}
.eyebrow { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: #c2410c; font-weight: 800; }
.muted { color: var(--muted); }
.he { font-family: var(--display); direction: rtl; unicode-bidi: isolate; font-weight: 700; }

/* ---------- Buttons: chunky, tactile, with a solid bottom edge that presses down ---------- */
.btn {
  --edge-h: 5px;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 22px; border-radius: 16px;
  border: 2.5px solid var(--ink);
  background: var(--night-3); color: var(--ink);
  font-weight: 800; font-size: 18px; letter-spacing: .01em; text-decoration: none; text-align: center; line-height: 1.2;
  box-shadow: 0 var(--edge-h) 0 var(--edge);
  transform: translateY(0);
  transition: transform .09s ease, box-shadow .09s ease, background-color .2s;
  margin-bottom: var(--edge-h);
}
.btn:active:not([disabled]) { transform: translateY(var(--edge-h)); box-shadow: 0 0 0 var(--edge); }
.btn.primary {
  background: var(--blue); color: #fff; border-color: var(--ink);
  box-shadow: 0 var(--edge-h) 0 var(--edge);
}
.btn.primary:active:not([disabled]) { box-shadow: 0 0 0 var(--edge); }
.btn.primary b, .btn.primary strong { color: inherit; }
.btn.ghost { background: var(--gold); color: var(--ink); border-color: var(--ink); box-shadow: 0 var(--edge-h) 0 var(--edge); }
.btn.ghost:active:not([disabled]) { box-shadow: 0 0 0 var(--edge); }
.btn.small { --edge-h: 4px; min-height: 48px; padding: 0 16px; font-size: 16px; border-radius: 14px; }
.btn[disabled] { opacity: .45; cursor: default; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }

.linkish {
  background: none; border: none; color: var(--muted); text-decoration: underline; text-decoration-color: var(--flame);
  text-underline-offset: 4px; padding: 12px 10px; font-size: 16px; min-height: 44px;
}
.linkish:active { color: var(--gold-hi); }

/* ---------- Gold-edged tiles ---------- */
.clue, .confirm, .reward, .spot, .level, .game-card, .lock-frame {
  background: var(--night-2);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  box-shadow: 5px 5px 0 var(--edge);
}
.clue { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.clue .riddle { font-family: var(--display); font-size: 23px; line-height: 1.32; font-weight: 500; color: var(--ink); }
.confirm { padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--sun-soft); }

/* ---------- Home ---------- */
.title-block { display: flex; flex-direction: column; gap: 8px; text-align: center; align-items: center; padding-top: 10px; }
.title-block .eyebrow { display: inline-flex; align-items: center; gap: 10px; }
.title-block .eyebrow::before, .title-block .eyebrow::after { content: ""; width: 22px; height: 3px; border-radius: 2px; background: var(--flame); }
.title-block h1, .win h1 {
  font-size: clamp(44px, 13vw, 62px); font-weight: 800; color: var(--blue); letter-spacing: -.01em;
  /* chunky sticker lettering */
  text-shadow: 3px 3px 0 var(--gold);
}
.title-block .he { font-size: 22px; color: var(--ink); opacity: .9; }
.ornament { display: block; width: 120px; height: 14px; margin: 2px auto 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14'%3E%3Cpath d='M0 7H48M72 7H120' stroke='%231b2145' stroke-opacity='.45' stroke-width='1.6'/%3E%3Cpath d='M60 1 66 11H54Z M60 13 54 3H66Z' fill='%23ffc93c' stroke='%231b2145' stroke-width='1.2'/%3E%3C/svg%3E") center / contain no-repeat; }
.menorah-box { position: relative; width: 100%; max-width: 420px; margin: 0 auto; }
.menorah-box::before { /* warm pool of candlelight behind the menorah */
  content: ""; position: absolute; left: 10%; right: 10%; top: 0; bottom: 18%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 201, 60, .55), rgba(255, 201, 60, 0)); pointer-events: none;
}
.menorah-box svg { position: relative; width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 8px rgba(27, 33, 69, .22)); }
.story { color: var(--muted); text-align: center; max-width: 34em; margin: 0 auto; font-size: 17px; }
.digits { display: flex; gap: 12px; justify-content: center; }
.digit {
  width: 56px; height: 68px; border-radius: 14px; border: 2.5px solid var(--ink); background: var(--night-3);
  display: grid; place-items: center; font-family: var(--display); font-size: 36px; font-weight: 800; color: var(--gold-hi);
  font-variant-numeric: tabular-nums; box-shadow: 0 5px 0 var(--edge);
}
.digit.empty { color: rgba(27, 33, 69, .35); border-style: dashed; border-color: var(--line); background: var(--night-2); }
.statline { display: flex; justify-content: center; gap: 18px; color: var(--muted); font-size: 16px; font-variant-numeric: tabular-nums; font-weight: 600; }
.statline > * + *::before { content: "✦"; color: var(--accent); margin-right: 18px; font-size: 11px; vertical-align: 2px; }
.foot { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* Level picker (one-game build) */
.levels { display: grid; gap: 16px; }
.level {
  text-align: left; padding: 18px 20px 16px; color: var(--ink);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  transition: transform .09s ease, box-shadow .09s ease, border-color .2s;
}
.level:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--edge); }
.level:hover, .level:focus-visible { border-color: var(--accent); }
.level h3 { font-size: 27px; color: var(--accent); font-weight: 800; }
.level .meta { font-size: 14px; color: var(--olive); grid-column: 1 / -1; font-weight: 700; letter-spacing: .03em; }
.level p { grid-column: 1 / -1; font-size: 16px; color: var(--muted); }
.level .go { grid-row: 1; grid-column: 2; font-weight: 800; color: var(--ink); background: var(--gold); border-radius: 999px; padding: 6px 14px; font-size: 15px; box-shadow: 0 3px 0 var(--gold-deep); }

/* Game picker: one gold-edged tile per game, three chunky level keys inside */
.games { display: grid; gap: 22px; }
.game-card { padding: 20px 18px 16px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.game-card::before { /* small brass corner flourish */
  content: ""; position: absolute; top: 10px; right: 12px; width: 22px; height: 22px; opacity: .8;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 20.7 17H3.3Z M12 22 3.3 7H20.7Z' fill='%23ffc93c' stroke='%231b2145' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.game-card h3 { font-size: 28px; color: var(--accent); font-weight: 800; padding-right: 30px; }
.game-card p { font-size: 16px; color: var(--muted); line-height: 1.45; }
.level-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.level-btn {
  min-height: 64px; border-radius: 14px; border: 2px solid var(--ink); border-bottom-color: var(--ink); background: var(--night-3); color: var(--ink);
  padding: 9px 6px; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center;
  box-shadow: 0 5px 0 var(--edge); margin-bottom: 5px;
  transition: transform .09s ease, box-shadow .09s ease, border-color .2s;
}
.level-btn:active { transform: translateY(5px); box-shadow: 0 0 0 var(--edge); }
.level-btn:hover, .level-btn:focus-visible { border-color: var(--accent); }
.level-btn b { font-size: 17px; font-weight: 800; color: var(--ink); }
.level-btn span { font-size: 13px; color: var(--muted); font-weight: 600; }
.level-row .level-btn:nth-child(1) b { color: var(--good); }
.level-row .level-btn:nth-child(2) b { color: var(--blue); }
.level-row .level-btn:nth-child(3) b { color: #c2410c; }
.level-btn.on { border-color: var(--ink); background: var(--sky); }
.level-badge {
  display: inline-block; border: 2.5px solid var(--ink); color: var(--ink); background: var(--gold);
  border-radius: 999px; padding: 6px 16px; font-size: 15px; font-weight: 800; line-height: 1.35; box-shadow: 0 3px 0 var(--edge);
}

/* Code digits with tags (dreidel letters) */
.chips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: baseline; gap: 8px; border: 2.5px solid var(--ink); background: var(--night-3);
  border-radius: 14px; padding: 6px 14px; min-height: 52px; font-family: var(--display); font-size: 28px; font-weight: 800; color: var(--gold-hi);
  font-variant-numeric: tabular-nums; box-shadow: 0 5px 0 var(--edge);
}
.chip .tag { font-size: 24px; color: var(--ink); }
.chip.empty { color: rgba(27, 33, 69, .4); border-style: dashed; border-color: var(--line); background: var(--night-2); }

/* Pieces: letters, recipe steps */
.steps-found { display: flex; flex-direction: column; gap: 8px; }
.step-chip {
  border: 2.5px solid var(--ink); background: var(--night-2); border-radius: 12px; padding: 10px 14px; font-weight: 700; font-size: 17px;
  display: flex; gap: 10px; align-items: baseline; box-shadow: 0 4px 0 var(--edge);
}
.step-chip .tag { color: var(--accent); font-family: var(--display); font-weight: 800; font-size: 20px; }
.step-chip.empty { color: rgba(27, 33, 69, .4); border-style: dashed; border-color: var(--line); box-shadow: none; }
.piece-row { display: flex; gap: 16px; align-items: center; }
.seq-list { display: flex; flex-direction: column; gap: 10px; }
.seq-list button {
  text-align: left; border: 2px solid var(--ink); background: var(--night-3); border-radius: 14px; padding: 12px 14px; font-weight: 700; font-size: 17px; color: var(--ink);
  display: flex; gap: 12px; align-items: center; min-height: 56px; box-shadow: 0 5px 0 var(--edge); margin-bottom: 4px;
  transition: transform .09s ease, box-shadow .09s ease, border-color .2s;
}
.seq-list button:active { transform: translateY(5px); box-shadow: 0 0 0 var(--edge); }
.seq-list button .n { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-size: 15px; font-weight: 800; }
.seq-list button.on { background: var(--sky); border-color: var(--ink); transform: translateY(3px); box-shadow: 0 2px 0 var(--edge); }
.seq-list button.on .n { background: var(--gold); color: var(--ink); border-color: var(--ink); }
.seq-list .tag { color: var(--accent); font-family: var(--display); font-weight: 800; font-size: 20px; }

/* Hint coins */
.coin-dot {
  position: relative; overflow: hidden; display: inline-block; width: 18px; height: 18px; border-radius: 50%; flex: none;
  vertical-align: -3px; margin-right: 6px;
  background: radial-gradient(circle at 36% 32%, #fff2b8 0 12%, #f0c052 45%, #a86f1c 100%);
  box-shadow: 0 2px 0 #7a4d12, inset 0 0 0 1.5px rgba(122, 77, 18, .6);
}
.coin-dot::after { content: ""; position: absolute; top: -40%; bottom: -40%; left: -60%; width: 40%; background: rgba(255, 255, 255, .65); transform: rotate(25deg); animation: coinshine 3.2s ease-in-out infinite; }
@keyframes coinshine { 0%, 55% { left: -60%; } 85%, 100% { left: 130%; } }
.coin-pill { font-weight: 800; color: var(--gold-hi); gap: 2px; font-variant-numeric: tabular-nums; }
.coin-pill .coin-dot { width: 20px; height: 20px; }
.hint-btn { align-self: flex-start; border-style: dashed; }
#hintBox { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Scan screen ---------- */
#scan { position: fixed; inset: 0; background: #000; z-index: 20; }
#stage { position: absolute; inset: 0; overflow: hidden; transition: bottom .3s; background: #05071a; }
#scan.sheet-open #stage { bottom: 50%; }
#scan.sheet-open .reticle { top: 50%; }
#stage video, #stage canvas.photo { position: absolute; inset: 0; width: 100%; height: 100%; }
#stage video { object-fit: cover; }
#stage canvas.photo { object-fit: contain; }
#overlay { position: absolute; left: 0; top: 0; width: 300px; height: 520px; transform-origin: 0 0; pointer-events: none; will-change: transform; transition: opacity .25s; }
#overlay svg { width: 300px; height: 520px; display: block; overflow: visible; }
.scan-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: nowrap;
}
.pill {
  background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; padding: 9px 16px; font-size: 16px; font-weight: 700;
  min-height: 44px; display: inline-flex; align-items: center; color: var(--ink); box-shadow: 0 3px 0 var(--edge);
}
button.pill:active { transform: translateY(3px); box-shadow: none; }
#scanStatus { color: var(--gold-hi); flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 24px; }
.scan-top .pill { font-size: 15px; padding: 9px 13px; flex: none; }
.scan-top #scanStatus { flex: 0 1 auto; }
.scan-top .coin-pill { flex: none; }
.reticle {
  position: absolute; left: 50%; top: 38%; width: min(56vw, 260px); aspect-ratio: 1; max-width: 100%;
  transform: translate(-50%, -50%); border-radius: 18px; pointer-events: none;
  box-shadow: 0 0 0 3px #ffc93c, 0 0 0 9999px rgba(0, 0, 0, .25);
}
.snap-panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 20px max(18px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 22px) max(18px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  background: var(--night); border-top: 3px solid var(--ink); border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .3);
}
.snap-panel .btn { width: 100%; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.manual { display: flex; gap: 8px; }
.manual input { flex: 1; min-width: 0; min-height: 48px; border-radius: 14px; border: 2px solid var(--line); background: var(--night-3); padding: 0 16px; text-transform: uppercase; letter-spacing: .08em; }
.snap-panel .manual .btn { width: auto; flex: none; }
/* toast */
.toast {
  position: absolute; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 74px); transform: translateX(-50%);
  z-index: 5; width: min(90vw, 420px); background: var(--gold); border: 3px solid var(--ink);
  border-radius: 16px; padding: 14px 18px; text-align: center; font-weight: 800; box-shadow: 0 6px 0 var(--edge);
  animation: toastIn .35s ease-out both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); }
}
.search-clue { font-family: var(--display); font-size: 22px; line-height: 1.32; font-weight: 500; }
#searchPanel .eyebrow { color: #c2410c; }
.debug-list { display: flex; flex-wrap: wrap; gap: 8px; }
.debug-list span { border: 1.5px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 15px; background: var(--night-2); }
.debug-list span.hit { border-color: var(--accent); color: var(--gold-hi); font-weight: 700; }
#scan.sheet-open .snap-panel { display: none; }

/* AR beacon + cue */
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#stage video, #stage canvas#freeze { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#beacon { position: absolute; left: 0; top: 0; pointer-events: none; transform-origin: 50% 100%; will-change: transform; }
#beacon .bob { animation: bob 3.2s ease-in-out infinite; }
#beacon .bob svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .55)) drop-shadow(0 0 14px rgba(255, 170, 60, .35)); }
#beacon.appear .bob { animation: appear .95s cubic-bezier(.2, 1.35, .4, 1) both, bob 3.2s ease-in-out .95s infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes appear { from { opacity: 0; transform: scale(.35) translateY(40px); filter: brightness(2.4); } to { opacity: 1; transform: none; filter: none; } }
#cue {
  position: absolute; z-index: 2; left: 50%; transform: translateX(-50%); bottom: 14px; width: min(88%, 420px);
  background: #fff; border: 2.5px solid var(--ink); border-radius: 16px; padding: 12px 16px;
  box-shadow: 0 5px 0 var(--edge); animation: cueIn .8s ease-out both;
}
#cue .riddle { font-family: var(--display); font-size: 20px; line-height: 1.3; }
@keyframes cueIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Station sheet (puzzle) ---------- */
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; height: 50%; overflow-y: auto; overscroll-behavior: contain;
  background-color: var(--night); border-top: 3px solid var(--ink); border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
  animation: sheetUp .38s cubic-bezier(.2, .9, .3, 1) both;
}
#sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: rgba(27, 33, 69, .3); margin: 10px auto 0; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
#sheet .wrap { padding-block: 10px calc(env(safe-area-inset-bottom, 0px) + 28px); gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.sheet-head h2 { font-size: 30px; color: var(--accent); font-weight: 800; margin-top: 4px; }
.close-x {
  background: var(--night-3); border: 2px solid var(--ink); border-radius: 14px; width: 48px; height: 48px; flex: none; font-size: 24px; line-height: 1;
  color: var(--ink); box-shadow: 0 4px 0 var(--edge); transition: transform .09s, box-shadow .09s;
}
.close-x:active { transform: translateY(4px); box-shadow: none; }
.q { font-weight: 700; font-size: 20px; line-height: 1.35; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choices button {
  min-height: 60px; border-radius: 16px; border: 2px solid var(--ink); background: var(--night-3); padding: 8px 12px;
  font-weight: 700; font-size: 18px; color: var(--ink); box-shadow: 0 5px 0 var(--edge); margin-bottom: 5px;
  transition: transform .09s, box-shadow .09s, border-color .2s;
}
.choices button:active:not([disabled]) { transform: translateY(5px); box-shadow: 0 0 0 var(--edge); }
.choices button[disabled] { box-shadow: 0 2px 0 var(--edge); transform: translateY(3px); text-decoration: line-through; text-decoration-color: var(--bad); color: var(--muted); background: #f1ede2; }
.choices button.hinted, .order-menorah button.hinted { background: var(--sun-soft); border-color: var(--ink); box-shadow: 0 5px 0 var(--edge), 0 0 0 3px rgba(255, 201, 60, .9); }
.answer-row { display: flex; gap: 10px; align-items: flex-start; }
.answer-row input {
  flex: 1; min-width: 0; min-height: 56px; border-radius: 16px; border: 2.5px solid var(--ink); background: var(--night-3);
  padding: 0 16px; font-size: 22px; font-weight: 700; letter-spacing: .06em; box-shadow: inset 0 3px 0 rgba(27, 33, 69, .1);
}
.answer-row input:focus { outline: none; border-color: var(--accent); }
.code-boxes { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.code-boxes input {
  width: 58px; height: 72px; text-align: center; font-family: var(--display); font-size: 36px; font-weight: 800; color: var(--gold-hi);
  border-radius: 14px; border: 2.5px solid var(--ink); background: var(--night-3); box-shadow: inset 0 3px 0 rgba(27, 33, 69, .1), 0 4px 0 var(--edge);
}
.code-boxes input:focus { outline: none; border-color: var(--accent); background: var(--sun-soft); }
.code-boxes.many { gap: 6px; }
.code-boxes.many input { width: 40px; height: 56px; font-size: 27px; border-radius: 12px; }
.code-boxes input.given { color: var(--good); border-color: var(--olive); border-style: dashed; }
.lock-frame { padding: 16px; display: flex; flex-direction: column; gap: 12px; animation: lockin .5s ease-out; }
@keyframes lockin { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.feedback { min-height: 1.5em; font-weight: 700; font-size: 17px; }
.feedback.bad { color: var(--bad); }
.feedback.good { color: var(--good); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.lock-hint { border-left: 4px solid var(--flame); padding: 4px 0 4px 14px; color: var(--ink); }

/* Order-the-candles puzzle: three little brass candlesticks */
.order-menorah { display: flex; justify-content: center; gap: 18px; padding: 6px 0 0; }
.order-menorah button {
  width: 70px; height: 128px; border-radius: 16px; border: 2px solid var(--ink); background: var(--night-3);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 10px; gap: 4px; position: relative;
  box-shadow: 0 5px 0 var(--edge); transition: transform .09s, box-shadow .09s, border-color .2s;
}
.order-menorah button:active { transform: translateY(5px); box-shadow: none; }
.order-menorah button.lit { border-color: var(--ink); background: var(--sun-soft); }
.order-menorah .stick {
  width: 18px; height: 60px; border-radius: 4px 4px 2px 2px; position: relative;
  background: linear-gradient(90deg, #22389a, #6f8cf2 38%, #2b45b8);
}
.order-menorah .stick::after { content: ""; position: absolute; left: -10px; right: -10px; bottom: -8px; height: 8px; border-radius: 0 0 8px 8px; background: linear-gradient(90deg, #8d5c17, #ffe08a 40%, #b47d22); }
.order-menorah .fl {
  width: 14px; height: 24px; border-radius: 50% 50% 45% 45% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 72%, #fffbe9 0 22%, #ffc34a 45%, #ff8c1f 75%, #e2531a);
  box-shadow: 0 0 14px 4px rgba(255, 150, 40, .45); visibility: hidden; transform-origin: 50% 100%;
}
.order-menorah button.lit .fl { visibility: visible; animation: flickerB 1.5s ease-in-out infinite; }
.order-menorah .n { position: absolute; top: 8px; font-weight: 800; font-size: 18px; color: var(--gold-hi); font-family: var(--display); }

.reward {
  background: var(--sun-soft); padding: 18px; display: flex; flex-direction: column; gap: 12px;
  animation: rise .45s ease-out both;
}
.reward .big-digit {
  font-family: var(--display); font-size: 56px; font-weight: 800; color: var(--accent); line-height: 1; flex: none;
  text-shadow: 3px 3px 0 var(--gold);
}
.big-digit.long { font-size: 24px; font-family: var(--body); font-weight: 800; line-height: 1.2; color: var(--gold-hi); text-shadow: none; flex: 1 1 auto; }

/* Hologram preview inside the station sheet */
.holo-preview { background: var(--night-2); border: 2.5px solid var(--ink); border-radius: 16px; display: flex; justify-content: center; padding: 48px 8px 8px; }
.holo-preview svg { width: 160px; height: auto; display: block; overflow: visible; }

/* ---------- Setup ---------- */
.setup-title { font-size: 34px; color: var(--accent); font-weight: 800; }
.spot { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.spot label { font-size: 14px; color: var(--muted); font-weight: 700; letter-spacing: .03em; }
.spot input, .spot textarea, .spot select {
  width: 100%; border-radius: 12px; border: 2px solid var(--line); background: var(--night);
  padding: 12px; font-size: 16px; color: var(--ink); min-height: 48px;
}
.spot input:focus, .spot textarea:focus, .spot select:focus { outline: none; border-color: var(--accent); }
.spot textarea { min-height: 80px; resize: vertical; line-height: 1.4; }
.spot h3 { font-size: 21px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; color: var(--gold-hi); }
.spot h3 code { font-family: var(--body); font-size: 13px; color: var(--accent); letter-spacing: .1em; }
.steps { display: flex; flex-direction: column; gap: 12px; padding: 0; margin: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.steps li::before {
  content: counter(s); width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: var(--ink);
  display: grid; place-items: center; font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 var(--gold-deep); font-family: var(--display);
}
.preview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.preview-grid figure { margin: 0; background: #fff; color: #111; border-radius: 10px; padding: 8px; text-align: center; font-size: 12px; font-weight: 700; }
.preview-grid svg { width: 100%; height: auto; display: block; }

/* ---------- Win ---------- */
.win h1 { text-align: center; }
.win .he { text-align: center; font-size: 32px; color: var(--ink); }
.win .eyebrow { display: block; }
.win .story { color: var(--ink); }

/* ---------- Art animation (SVG classes from art.js) ---------- */
.flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker 1.7s infinite ease-in-out; }
.flame.b { animation-name: flickerB; animation-duration: 2.1s; animation-delay: -.5s; }
.flame.c { animation-duration: 1.35s; animation-delay: -.9s; }
@keyframes flicker {
  0%, 100% { transform: scale(1, 1) skewX(0); opacity: 1; }
  18% { transform: scale(.95, 1.06) skewX(2.5deg); }
  37% { transform: scale(1.03, .96) skewX(-1.5deg); opacity: .94; }
  56% { transform: scale(.97, 1.08) skewX(1.5deg); }
  74% { transform: scale(1.02, .97) skewX(-2.5deg); opacity: .97; }
}
@keyframes flickerB {
  0%, 100% { transform: scale(1, 1) skewX(0); }
  30% { transform: scale(.96, 1.07) skewX(-2deg); }
  60% { transform: scale(1.03, .95) skewX(2deg); }
  80% { transform: scale(.98, 1.04) skewX(-1deg); }
}
.halo { animation: pulse 2.6s infinite ease-in-out; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { opacity: .7; transform: scale(1.06); } }
.smoke { animation: smoke 3s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes smoke { 50% { opacity: .35; transform: translateY(-4px) skewX(6deg); } }
.dreidel-spin { transform-box: fill-box; transform-origin: 50% 85%; animation: wobble 1s infinite ease-in-out; }
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.letter-cycle text { opacity: 0; animation: cyc 2.4s infinite steps(1); }
.letter-cycle text:nth-child(2) { animation-delay: .6s; } .letter-cycle text:nth-child(3) { animation-delay: 1.2s; } .letter-cycle text:nth-child(4) { animation-delay: 1.8s; }
@keyframes cyc { 0% { opacity: 1; } 25%, 100% { opacity: 0; } }

/* Gentle entrance when a screen opens */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
section > .wrap > * { animation: rise .55s cubic-bezier(.2, .8, .3, 1) both; }
section > .wrap > *:nth-child(2) { animation-delay: .06s; }
section > .wrap > *:nth-child(3) { animation-delay: .12s; }
section > .wrap > *:nth-child(4) { animation-delay: .18s; }
section > .wrap > *:nth-child(n+5) { animation-delay: .24s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition: none !important; }
  .flame, .halo, .smoke, .dreidel-spin, .letter-cycle text, .shake, #beacon .bob, .coin-dot::after { animation: none !important; }
  .letter-cycle text:first-child { opacity: 1; }
  .order-menorah button.lit .fl { animation: none !important; }
}

/* =====================================================================
   Escape-room screens (game picker by level, lock board, locks, notebook, tasks).
   Same "Midnight & gold" tokens as above.
   ===================================================================== */
#home.playing .menorah-box { max-width: 230px; }
#home.playing .title-block h1 { font-size: clamp(34px, 10vw, 46px); }
.level-group { display: flex; flex-direction: column; gap: 16px; }
.level-group + .level-group { margin-top: 10px; }
.level-head { text-align: center; }
.game-card .row { margin-top: 2px; }
.play-confirm .confirm { margin-top: 4px; }
.riddle-item { display: block; padding-left: 22px; position: relative; }
.riddle-item + .riddle-item { margin-top: 12px; }
.riddle-item::before { content: "✦"; position: absolute; left: 0; top: .1em; color: var(--accent); font-size: .7em; }
.search-clue .riddle-item { font-size: 18px; }
.say-btn { align-self: flex-start; }

/* Lock board on the home screen */
.lock-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.lock-card {
  display: flex; align-items: center; gap: 12px; text-align: left; min-height: 74px; padding: 12px 14px;
  border-radius: 16px; border: 2px solid var(--ink); background: var(--night-3); color: var(--ink);
  box-shadow: 0 5px 0 var(--edge); margin-bottom: 5px; transition: transform .09s, box-shadow .09s, border-color .2s;
}
.lock-card:active { transform: translateY(5px); box-shadow: 0 0 0 var(--edge); }
.lock-card.open { border-color: var(--ink); background: #d9f4e3; }
.lock-icon { font-size: 30px; line-height: 1; flex: none; }
.lock-name { display: flex; flex-direction: column; gap: 2px; }
.lock-name b { font-family: var(--display); font-size: 19px; line-height: 1.15; }
.lock-name small { font-size: 14px; color: var(--muted); font-weight: 600; }
.lock-card.open .lock-name small { color: var(--good); }
.lock-title { font-size: 30px; color: var(--accent); font-weight: 800; }
.hint-area { display: flex; flex-direction: column; gap: 10px; }

/* Tap-in-order locks (colors, arrows, recipe steps) */
.tap-slots { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tap-slot {
  min-width: 54px; min-height: 54px; padding: 4px 8px; border-radius: 14px; border: 2px dashed var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: rgba(27, 33, 69, .45); font-weight: 800; font-size: 15px;
}
.tap-slot.on { border-style: solid; border-color: var(--ink); color: var(--ink); background: var(--sun-soft); }
.tap-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tap-opts.list { grid-template-columns: 1fr; }
.tap-opts button {
  min-height: 60px; border-radius: 16px; border: 2px solid var(--ink); background: var(--night-3); padding: 8px 12px;
  font-weight: 700; font-size: 18px; color: var(--ink); box-shadow: 0 5px 0 var(--edge); margin-bottom: 5px;
  display: flex; align-items: center; justify-content: center; gap: 10px; transition: transform .09s, box-shadow .09s;
}
.tap-opts.list button { justify-content: flex-start; text-align: left; }
.tap-opts.big button { font-size: 40px; min-height: 76px; }
.tap-opts button:active { transform: translateY(5px); box-shadow: 0 0 0 var(--edge); }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); flex: none; box-shadow: inset -3px -4px 0 rgba(0, 0, 0, .2); }
.tap-slot .swatch { width: 22px; height: 22px; }

/* Number fields */
.fields-form { display: flex; flex-direction: column; gap: 12px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; }
.field-row input {
  width: 96px; height: 60px; text-align: center; font-family: var(--display); font-size: 30px; font-weight: 800; color: var(--gold-hi);
  border-radius: 14px; border: 2.5px solid var(--ink); background: var(--night-3); box-shadow: inset 0 3px 0 rgba(27, 33, 69, .1);
}
.field-row input:focus { outline: none; border-color: var(--accent); background: var(--sun-soft); }

/* Accusation */
.choose-group { display: flex; flex-direction: column; gap: 10px; }
.choices button.on { border-color: var(--accent); background: var(--sky); color: var(--gold-hi); }

/* Oil jugs */
.jugs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; }
.jug {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 16px;
  border: 2px solid var(--ink); background: var(--night-3); color: var(--ink); box-shadow: 0 5px 0 var(--edge); margin-bottom: 5px;
}
.jug.on { background: var(--sky); border-color: var(--ink); box-shadow: 0 5px 0 var(--edge), 0 0 0 3px rgba(255, 201, 60, .9); }
.jug-body { width: 54px; height: 110px; border: 2.5px solid var(--gold-line); border-radius: 8px 8px 14px 14px; position: relative; overflow: hidden; background: var(--sky); }
.jug:nth-child(2) .jug-body { height: 80px; }
.jug:nth-child(3) .jug-body { height: 56px; }
.jug-oil { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(#ffd36e, #c88f2c); transition: height .35s ease; }
.jug b { font-family: var(--display); font-size: 22px; color: var(--gold-hi); }
.jug small { font-size: 13px; color: var(--muted); }

/* Found-it sheet and real-room tasks */
.task-box { border: 2.5px solid var(--ink); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--night-2); }
.task-wait { font-size: 15px; }
.found-note { border-left: 4px solid var(--flame); padding: 4px 0 4px 14px; display: flex; flex-direction: column; gap: 4px; }
.found-note .riddle { font-family: var(--display); font-size: 20px; line-height: 1.3; }
.win-line { color: var(--good); }

/* Notebook */
.note-list { display: flex; flex-direction: column; gap: 16px; }
.note-card {
  display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 14px; background: var(--night-2);
  border: 2.5px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--edge);
}
.note-art { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.note-art svg { width: 110px; height: auto; display: block; }
.note-art img { width: 100%; border-radius: 10px; border: 1.5px solid var(--line); }
.note-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.note-text h3 { font-size: 21px; color: var(--gold-hi); }
.note-text p { font-size: 16px; }
@media (max-width: 360px) { .note-card { grid-template-columns: 1fr; } .note-art svg { width: 150px; } }
#clueText .riddle-item { font-size: 18px; line-height: 1.35; }
.games > *, .level-group > *, .game-card > * { min-width: 0; }
.code-form input { width: 100%; min-width: 0; font-size: 18px; }
.unlock-btn { white-space: normal; }
.game-card .opens-note { color: var(--accent); font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.howto { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 6px; }
.howto ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; font-size: 16px; color: var(--ink); }
.gm-game { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.gm-game h3 { font-size: 20px; color: var(--gold-hi); }
.gm-game small { font-family: var(--body); font-size: 13px; color: var(--muted); }
#stuckArea .row { flex-wrap: wrap; }
.riddle-item[data-n]::before { content: attr(data-n) "."; font-family: var(--display); font-weight: 800; font-size: 1em; top: 0; color: var(--accent); }

/* bright look: bold words inside yellow or blue boxes stay readable */
.toast b, .toast strong, .level-badge b { color: inherit; }
.game-card { border-width: 3px; }
.level-group:nth-child(3n+1) .game-card { background: #fff; }
.unlock-btn { background: var(--gold); }
.code-form, .mail-form { flex-wrap: wrap; }
.code-form input, .mail-form input { flex: 1 1 170px; }
.code-form .btn, .mail-form .btn { flex: 1 1 auto; }

/* ---------- Countdown clock: sits in the corner of every screen ---------- */
.clock {
  position: fixed; z-index: 40; right: max(12px, env(safe-area-inset-right, 0px)); top: calc(env(safe-area-inset-top, 0px) + 10px);
  background: #fff; color: var(--ink); border: 2.5px solid var(--ink); border-radius: 999px; padding: 6px 14px;
  font-family: var(--display); font-weight: 800; font-size: 20px; line-height: 1.2; font-variant-numeric: tabular-nums;
  box-shadow: 3px 3px 0 var(--edge); pointer-events: none;
}
.clock.low { background: var(--gold); }
.clock.last { background: var(--bad); color: #fff; animation: clockPulse 1s ease-in-out infinite; }
.clock.hit { animation: clockHit .6s ease-out; }
@keyframes clockPulse { 50% { transform: scale(1.08); } }
@keyframes clockHit { 0% { transform: scale(1.35); background: var(--bad); color: #fff; } 100% { transform: none; } }
body.clock-on section:not(#scan) > .wrap { padding-top: 64px; }
/* on the camera screen the top row is full, so the clock drops just below it and the toast moves down */
body.clock-on:has(#scan:not([hidden])) .clock { top: calc(env(safe-area-inset-top, 0px) + 66px); }
body.clock-on #scan .toast { top: calc(env(safe-area-inset-top, 0px) + 122px); }

/* ---------- Win and time's-up screens ---------- */
.win-stars { text-align: center; font-size: 46px; line-height: 1; letter-spacing: 6px; animation: starPop .7s cubic-bezier(.2, 1.6, .4, 1) .25s both; }
.win-rank { text-align: center; font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.15; color: #c2410c; text-wrap: balance; }
.win-clock { text-align: center; font-size: 18px; font-weight: 700; background: var(--gold); border: 2.5px solid var(--ink); border-radius: 16px; padding: 10px 14px; box-shadow: 4px 4px 0 var(--edge); align-self: center; }
.win-clock b { color: inherit; font-variant-numeric: tabular-nums; }
@keyframes starPop { from { opacity: 0; transform: scale(.2) rotate(-20deg); } to { opacity: 1; transform: none; } }
#confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
#confetti i { position: absolute; top: -24px; display: block; opacity: .95; animation: confettiFall linear both; }
@keyframes confettiFall { to { transform: translate(var(--drift), 108vh) rotate(var(--spin)); opacity: .9; } }
/* keep the top of the camera screen clear for the back button, status and clock, however long the clue panel gets */
#scan .snap-panel { max-height: calc(100% - env(safe-area-inset-top, 0px) - 118px); overflow-y: auto; overscroll-behavior: contain; }
