/* Save the Candy: shared look for every page of the Halloween digital escape room */
:root {
  color-scheme: dark;
  --night: #0a0910;
  --night-2: #120e19;
  --panel: rgba(18, 14, 25, 0.86);
  --panel-solid: #17121f;
  --line: rgba(239, 230, 210, 0.14);
  --bone: #efe6d2;
  --bone-dim: #b9ad97;
  --candle: #f3a32f;
  --candle-soft: rgba(243, 163, 47, 0.18);
  --moon: #9dbfe0;
  --uv: #c9a8ff;
  --rust: #e0674a;
  --paper: #e8dcc2;
  --paper-ink: #2b2118;
  --paper-line: rgba(43, 33, 24, 0.18);
  --good: #7fd49a;
  --font-display: "IM Fell English SC", "IM Fell English", Georgia, "Times New Roman", serif;
  --font-body: "Atkinson Hyperlegible", Verdana, "Segoe UI", system-ui, sans-serif;
  --radius: 6px;
  --bar-h: 58px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--candle); }
:focus-visible { outline: 3px solid var(--candle); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; text-wrap: balance; line-height: 1.1; margin: 0; }
p { margin: 0; }

/* ---------- painted backdrop ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: -2;
  background-size: cover; background-position: center;
}
.backdrop::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 0%, rgba(10, 9, 16, 0.55) 70%, rgba(10, 9, 16, 0.9) 100%),
    linear-gradient(to bottom, rgba(10, 9, 16, 0.55), rgba(10, 9, 16, 0.25) 30%, rgba(10, 9, 16, 0.75));
}
.fog {
  position: fixed; inset: auto 0 0 0; height: 45vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 20% 100%, rgba(190, 200, 220, 0.12), transparent 70%),
    radial-gradient(ellipse 50% 35% at 75% 100%, rgba(190, 200, 220, 0.10), transparent 70%);
  animation: fogdrift 22s ease-in-out infinite alternate;
}
@keyframes fogdrift { from { transform: translateX(-4%); } to { transform: translateX(4%); } }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--bar-h);
  padding: 8px 16px;
  background: linear-gradient(to bottom, rgba(10, 9, 16, 0.96), rgba(10, 9, 16, 0.82));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.bar .mark { font-family: var(--font-display); font-size: 22px; color: var(--bone); text-decoration: none; white-space: nowrap; }
.bar .mark small { display: block; font-family: var(--font-body); font-size: 12px; color: var(--bone-dim); letter-spacing: 0.08em; text-transform: uppercase; }
.bar .spacer { flex: 1; }
.clock {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 24px; letter-spacing: 0.04em;
  padding: 2px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35); min-width: 96px; text-align: center;
}
.clock.low { color: var(--rust); border-color: rgba(224, 103, 74, 0.6); animation: pulse 1s ease-in-out infinite; }
.clock.off { font-size: 14px; font-weight: 400; color: var(--bone-dim); letter-spacing: 0; }
@keyframes pulse { 50% { box-shadow: 0 0 18px rgba(224, 103, 74, 0.45); } }
.stat { font-size: 14px; color: var(--bone-dim); white-space: nowrap; }
.stat b { color: var(--bone); }
.iconbtn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 7px 12px; cursor: pointer; font-size: 14px; text-decoration: none; color: var(--bone);
}
.iconbtn:hover { border-color: rgba(243, 163, 47, 0.5); background: var(--candle-soft); }
.iconbtn svg { width: 18px; height: 18px; }
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 8px; }
  .bar .mark small, .stat .long { display: none; }
  .clock { font-size: 20px; min-width: 80px; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--radius); cursor: pointer;
  padding: 13px 26px; font-weight: 700; font-size: 18px; text-decoration: none;
  background: var(--candle); color: #fff;
  text-shadow: 0 1px 1px rgba(80, 40, 0, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 210, 140, 0.35) inset, 0 8px 30px rgba(243, 163, 47, 0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255, 210, 140, 0.5) inset, 0 10px 40px rgba(243, 163, 47, 0.4); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; color: var(--bone); text-shadow: none; box-shadow: 0 0 0 1px var(--line) inset; }
.btn.ghost:hover { box-shadow: 0 0 0 1px rgba(243, 163, 47, 0.6) inset; }

/* ---------- lock (a padlock, its wheels, and the try button in one row) ---------- */
.lock {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 16px; align-items: center;
  padding: 10px 16px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent 40%),
    linear-gradient(to bottom, #2a2530, #16131b);
  border: 1px solid rgba(239, 230, 210, 0.18);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
}
.padlock { position: relative; width: 58px; height: 72px; }
.padlock .shackle {
  position: absolute; left: 9px; top: 2px; width: 40px; height: 40px;
  border: 7px solid #9a94a3; border-bottom: 0; border-radius: 20px 20px 0 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.45s cubic-bezier(.3, 1.6, .5, 1);
  transform-origin: 100% 100%;
}
.padlock .body {
  position: absolute; left: 0; bottom: 0; width: 58px; height: 46px; border-radius: 8px;
  background: linear-gradient(135deg, #c79a4a, #8a6224 55%, #5a3e14);
  box-shadow: inset 0 1px 0 rgba(255, 235, 190, 0.5), inset 0 -4px 8px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.5);
}
.padlock .body::after {
  content: ""; position: absolute; left: 50%; top: 13px; width: 9px; height: 17px; transform: translateX(-50%);
  background: radial-gradient(circle at 50% 30%, #1b1208 4px, transparent 5px), linear-gradient(#1b1208, #1b1208) 50% 100% / 3px 9px no-repeat;
}
.lock.open .padlock .shackle { transform: translate(0, -10px) rotate(-30deg); }
.lock .label { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bone-dim); }
.lock .side-col { display: grid; gap: 6px; justify-items: start; }
.wheels { display: flex; gap: 6px; }
.wheel {
  display: grid; grid-template-rows: 22px 46px 22px; width: 46px;
  background: linear-gradient(to right, #0d0b10, #1f1b25 30%, #2c2733 50%, #1f1b25 70%, #0d0b10);
  border: 1px solid rgba(0, 0, 0, 0.7); border-radius: 8px;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}
.wheel button {
  background: none; border: 0; cursor: pointer; color: var(--bone-dim); padding: 0;
  display: grid; place-items: center;
}
.wheel button:hover { color: var(--candle); }
.wheel button svg { width: 18px; height: 18px; }
.wheel .face {
  display: grid; place-items: center;
  font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--bone);
  border-block: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.05) 50%, rgba(0, 0, 0, 0.5));
  outline: none; cursor: ns-resize; user-select: none; touch-action: none;
}
.wheel .face:focus-visible { box-shadow: inset 0 0 0 3px var(--candle); }
.wheel .face.tick { animation: tick 0.12s ease-out; }
@keyframes tick { from { transform: translateY(-6px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.lock.shake { animation: shake 0.45s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px) rotate(-0.4deg); }
  20%, 80% { transform: translateX(4px) rotate(0.5deg); }
  30%, 50%, 70% { transform: translateX(-7px) rotate(-0.6deg); }
  40%, 60% { transform: translateX(7px) rotate(0.6deg); }
}
.lock .msg { min-height: 1.4em; font-size: 14px; line-height: 1.35; color: var(--bone-dim); }
.lock .msg.bad { color: var(--rust); }
.lock .msg.good { color: var(--good); }
.lock .btn { padding: 10px 20px; font-size: 17px; }
.wheels.word { min-width: 0; }
.word-input {
  width: min(300px, 100%); font: inherit; font-size: 24px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--bone); background: linear-gradient(to bottom, #0d0b10, #1f1b25 50%, #0d0b10);
  border: 1px solid rgba(0, 0, 0, 0.7); border-radius: 8px; padding: 14px 14px; box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.8);
}
.word-input::placeholder { color: rgba(185, 173, 151, 0.55); letter-spacing: 0.02em; text-transform: none; font-weight: 400; font-size: 17px; }
.word-input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--candle), inset 0 0 12px rgba(0, 0, 0, 0.8); }
.door-tag { font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--candle); }
.lock.jammed .wheels { opacity: 0.35; filter: grayscale(1); }
.lock.jammed::after {
  content: ""; position: absolute; inset: 0; border-radius: 12px; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(224, 103, 74, 0.6), inset 0 0 40px rgba(224, 103, 74, 0.2);
}
.lock.open { border-color: rgba(127, 212, 154, 0.5); box-shadow: 0 0 50px rgba(243, 163, 47, 0.22), 0 16px 40px rgba(0, 0, 0, 0.55); }
@media (max-width: 560px) {
  .lock { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .lock .padlock { display: none; }
  .lock .wheels { width: 100%; justify-content: center; gap: 4px; }
  .lock .wheel { width: auto; flex: 1 1 0; max-width: 46px; min-width: 0; }
  .lock .wheel .face { font-size: 26px; }
  .lock .side-col { justify-items: stretch; text-align: center; width: 100%; }
}

/* ---------- hint drawer ---------- */
.hints { display: grid; gap: 10px; }
.hint-card {
  border: 1px solid var(--line); border-radius: 10px; background: rgba(0, 0, 0, 0.3);
  padding: 14px 16px;
}
.hint-card h3 { font-family: var(--font-body); font-size: 15px; font-weight: 700; letter-spacing: 0.02em; margin-bottom: 6px; color: var(--candle); }
.hint-card p + p, .hint-card p + ul, .hint-card ul + p { margin-top: 8px; }
.hint-card ul { margin: 0; padding-left: 20px; }
.hint-cost { font-size: 14px; color: var(--bone-dim); }

/* ---------- puzzle page layout: notes + hints on the left, the scene and a tool tray on the right ---------- */
.side { display: grid; gap: 16px; }
.layout {
  width: min(1380px, 100%); margin: 0 auto; padding: 20px 16px 48px;
  display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 22px; align-items: start;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: contents; }
  .scene-wrap { order: 2; position: static; }
  .hints-panel { order: 3; }
}
.side h1 { font-size: 46px; margin-top: 2px; text-shadow: 0 2px 20px rgba(0, 0, 0, 0.9); }

.notes {
  background: var(--paper); color: var(--paper-ink); border-radius: 4px; padding: 18px 20px 20px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, var(--paper-line) 27px 28px);
  background-position: 0 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), inset 0 0 50px rgba(120, 85, 30, 0.22);
  font-size: 16px; line-height: 28px;
}
.notes h2 { font-family: "IM Fell English", Georgia, serif; font-style: italic; font-size: 22px; margin-bottom: 4px; line-height: 28px; }
.notes p + p { margin-top: 10px; }
.notes .nudge { font-style: italic; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; }
.panel > h2 { font-family: var(--font-body); font-size: 15px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bone-dim); }
.hint-btn { justify-self: start; font-size: 15px; padding: 9px 16px; }
.scene-wrap { position: sticky; top: calc(var(--bar-h) + 12px); display: grid; gap: 10px; }
.tray { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.tool { display: grid; gap: 8px; align-content: center; padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.tool p { font-size: 13px; line-height: 1.35; color: var(--bone-dim); }
@media (max-width: 760px) { .tray { grid-template-columns: 1fr; } }
.tray.single { grid-template-columns: 1fr; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px 16px;
  background: rgba(6, 5, 10, 0.82); backdrop-filter: blur(4px);
  animation: fadein 0.35s ease;
}
.overlay .card {
  width: min(520px, 100%); text-align: center; display: grid; gap: 14px; justify-items: center;
  padding: 30px 26px; border-radius: 14px; background: var(--panel-solid); border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}
.overlay h2 { font-size: 40px; }
@keyframes fadein { from { opacity: 0; } }

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

/* ---------- the painted cast (Naomi, Sofia, Arjun, Henry, Simone) ---------- */
.door-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.door-head .guide {
  height: 124px; width: auto; flex: none; margin-bottom: -22px; position: relative; z-index: 1;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.6));
}
.door-head + .notes, .door-head + .notes.key { position: relative; z-index: 2; }
.notes h2 .says { font-style: normal; font-weight: 700; font-family: var(--font-body); font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.says.naomi { color: #b07a10; } .says.sofia { color: #1f7f79; } .says.arjun { color: #8a2432; }
.says.henry { color: #2c4fa6; } .says.simone { color: #7a55b8; }
@media (max-width: 960px) { .door-head .guide { height: 104px; } }
