/* ============ SIDETRACKED — styles ============ */
/* ADHD-first: big targets, one consistent layout, calm motion, high contrast */

:root {
  --bg: #FDF6EC;
  --panel: #FFFFFF;
  --ink: #2D2A32;
  --ink-soft: #6B6572;
  --accent: #FF8A5C;
  --accent-deep: #E9642E;
  --gold: #FFC24B;
  --teal: #2FA098;
  --purple: #7C6BC4;
  --shadow: 0 4px 14px rgba(45,42,50,.12);
  --radius: 18px;
  --font: -apple-system, "SF Pro Rounded", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

body.big-text { font-size: 112%; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  animation-duration: .01s !important;
  transition-duration: .01s !important;
}

/* ============ TITLE SCREEN ============ */
#title-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(180deg, #FFE8CF 0%, #FDF6EC 55%, #FFF3E0 100%);
}
.title-art { width: min(88vw, 380px); }
.title-art svg { width: 100%; height: auto; display: block; border-radius: 22px; box-shadow: var(--shadow); }
.game-title {
  font-size: clamp(38px, 11vw, 56px);
  letter-spacing: 3px;
  color: var(--accent-deep);
  text-shadow: 0 3px 0 #FFD9A8;
}
.game-sub { color: var(--ink-soft); font-size: 16px; max-width: 300px; }
.title-buttons { display: flex; flex-direction: column; gap: 12px; width: min(80vw, 300px); margin-top: 8px; }
.big-btn {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  padding: 16px 22px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 5px 0 var(--accent-deep);
  cursor: pointer;
  transition: transform .08s;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-deep); }
.big-btn.secondary { background: var(--teal); box-shadow: 0 5px 0 #1E7770; }
.title-note { color: var(--ink-soft); font-size: 13px; margin-top: 6px; }

/* ============ GAME LAYOUT ============ */
#game-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* --- top bar --- */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
#chapter-dots { display: flex; gap: 5px; }
.ch-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #E4D9C8;
}
.ch-dot.done { background: var(--gold); }
.ch-dot.now { background: var(--accent); transform: scale(1.35); }
#spark-counter {
  margin-left: auto;
  font-weight: 800;
  font-size: 17px;
  color: var(--accent-deep);
  background: #FFF1DC;
  border-radius: 999px;
  padding: 5px 12px;
}
#spark-counter.pop { animation: pop .35s; }
@keyframes pop { 40% { transform: scale(1.25); } }
.topbar-btns { display: flex; gap: 6px; }
.icon-btn {
  width: 42px; height: 42px;
  border-radius: 14px;
  border: none;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 20px;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.92); }

/* --- objective bar: ALWAYS visible --- */
#objective-bar {
  margin: 0 12px 8px;
  background: #FFEFD9;
  border: 2px dashed var(--gold);
  border-radius: 14px;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 15px;
  color: #8A5A16;
  display: flex;
  align-items: center;
  gap: 8px;
}
#objective-bar::before { content: "🎯"; }
#objective-bar.flash { animation: objflash .8s; }
@keyframes objflash { 0%,100% { background:#FFEFD9; } 40% { background:#FFD98F; } }

/* --- scene --- */
#scene-wrap {
  position: relative;
  margin: 0 12px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 8 / 5;
  flex-shrink: 0;
  background: #ddd;
}
#scene-art, #scene-art svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hotspot-layer { position: absolute; inset: 0; }
.hotspot {
  position: absolute;
  cursor: pointer;
  border-radius: 12px;
}
.hs-dot {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,.95);
  box-shadow: 0 0 0 4px rgba(255,194,75,.55), 0 1px 6px rgba(0,0,0,.3);
  pointer-events: none;
  animation: dotpulse 1.8s ease-in-out infinite;
}
@keyframes dotpulse {
  0%,100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(255,194,75,.55), 0 1px 6px rgba(0,0,0,.3); }
  50%     { transform: scale(1.25); box-shadow: 0 0 0 8px rgba(255,194,75,.25), 0 1px 6px rgba(0,0,0,.3); }
}
.hs-dot.nudge { animation: dotnudge .5s ease-in-out infinite; }
@keyframes dotnudge {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.7); }
}
#scene-name {
  position: absolute;
  top: 8px; left: 10px;
  background: rgba(45,42,50,.65);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
}
#scene-wrap.shake { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

/* --- dialogue panel: fixed place, never jumps around --- */
#dialogue-panel {
  flex: 1;
  min-height: 110px;
  margin: 10px 12px 8px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  position: relative;
  overflow-y: auto;
  cursor: pointer;
}
#dlg-idle p { color: var(--ink-soft); font-size: 15px; text-align: center; margin-top: 14px; }
#dlg-speaker {
  display: inline-block;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .5px;
  color: #fff;
  background: var(--teal);
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}
#dlg-speaker.you { background: var(--accent); }
#dlg-speaker.narrator { background: var(--purple); }
#dlg-text { font-size: 19px; line-height: 1.45; font-weight: 500; }
#dlg-more {
  position: absolute;
  right: 14px; bottom: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  animation: bob 1.2s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

#dlg-choices { display: flex; flex-direction: column; gap: 9px; padding-top: 4px; }
.choice-btn {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  text-align: left;
  padding: 13px 16px;
  border: 2px solid #EFE6D8;
  border-radius: 14px;
  background: #FFFBF4;
  color: var(--ink);
  cursor: pointer;
}
.choice-btn:active { background: #FFE9CC; border-color: var(--gold); }

/* --- inventory --- */
#inventory-bar {
  display: flex;
  gap: 8px;
  padding: 4px 12px 12px;
  min-height: 52px;
  overflow-x: auto;
}
.inv-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 2px solid transparent;
}
.inv-chip .inv-emoji { font-size: 18px; }
.inv-chip.new { animation: chipland .6s; border-color: var(--gold); }
@keyframes chipland { 0% { transform: scale(.3) rotate(-15deg); } 65% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ============ MODALS ============ */
#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(45,42,50,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
#modal-card {
  background: var(--panel);
  border-radius: 22px;
  padding: 20px;
  width: min(94vw, 420px);
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  animation: rise .25s ease-out;
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.modal-title { font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.modal-sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 14px; }
.modal-close {
  width: 100%;
  margin-top: 14px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  padding: 13px;
  border: none;
  border-radius: 14px;
  background: #F1EADF;
  color: var(--ink);
  cursor: pointer;
}

/* journal */
.clue-grid { display: flex; flex-direction: column; gap: 10px; }
.clue-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #FFFBF2;
  border: 2px solid #F3E6CE;
  border-radius: 14px;
  padding: 11px 13px;
}
.clue-card .clue-icon { font-size: 26px; }
.clue-card b { display: block; font-size: 15px; }
.clue-card span { font-size: 14px; color: var(--ink-soft); line-height: 1.4; }
.journal-empty { text-align: center; color: var(--ink-soft); padding: 24px 8px; font-size: 15px; }

/* hint */
.hint-box {
  background: #F0FAF7;
  border: 2px solid #BEE7DC;
  border-radius: 14px;
  padding: 14px;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 600;
}
.hint-more {
  width: 100%;
  margin-top: 10px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
}

/* settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px;
  border-bottom: 1px solid #F0EAE0;
  font-size: 16px;
  font-weight: 600;
}
.toggle {
  width: 54px; height: 30px;
  border-radius: 999px;
  border: none;
  background: #E4DCCE;
  position: relative;
  cursor: pointer;
  transition: background .2s;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: left .2s;
}
.toggle.on { background: var(--teal); }
.toggle.on::after { left: 27px; }
.danger-btn {
  width: 100%;
  margin-top: 14px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: #FCE8E4;
  color: #C0442C;
  cursor: pointer;
}

/* ============ PUZZLE PIECES ============ */
.pz-clue-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pz-clue-chip {
  background: #FFF4DC;
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  color: #8A5A16;
}
.pz-grid { display: flex; flex-direction: column; gap: 12px; }
.pz-row-label { font-size: 13px; font-weight: 800; color: var(--ink-soft); letter-spacing: .5px; margin-bottom: 5px; }
.pz-opts { display: flex; gap: 8px; }
.pz-opt {
  flex: 1;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  padding: 12px 6px;
  border: 2px solid #EFE6D8;
  border-radius: 12px;
  background: #FFFBF4;
  cursor: pointer;
}
.pz-opt.sel { border-color: var(--accent); background: #FFE9DC; }
.pz-go {
  width: 100%;
  margin-top: 14px;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 800;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--accent-deep);
  cursor: pointer;
}
.pz-go:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-deep); }
.pz-feedback { min-height: 24px; margin-top: 10px; text-align: center; font-weight: 700; font-size: 15px; color: var(--accent-deep); }

/* padlock dials */
.dials { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.dial { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dial button {
  width: 56px; height: 40px;
  font-size: 20px;
  border: none;
  border-radius: 10px;
  background: #F1EADF;
  cursor: pointer;
}
.dial button:active { background: var(--gold); }
.dial .dial-num {
  width: 56px; height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  background: var(--ink);
  color: var(--gold);
  border-radius: 10px;
}

/* flyer match */
.flyer-stage { display: flex; gap: 6px; align-items: center; justify-content: center; margin-bottom: 12px; }
.flyer-half svg { display: block; width: 100%; height: auto; }
.flyer-left { width: 44%; }
.flyer-slot { width: 44%; border: 3px dashed #D8CDBB; border-radius: 8px; aspect-ratio: 15/22; display:flex; align-items:center; justify-content:center; color:#B9AD98; font-size:13px; font-weight:700; }
.flyer-opts { display: flex; gap: 8px; }
.flyer-opt { flex: 1; border: 3px solid #EFE6D8; border-radius: 10px; padding: 3px; cursor: pointer; background: #FFFBF4; }
.flyer-opt svg { display: block; width: 100%; height: auto; }
.flyer-opt.wrong { animation: wob .4s; }
@keyframes wob { 25% { transform: rotate(-4deg);} 75% { transform: rotate(4deg);} }

/* heave */
.heave-meter {
  height: 26px;
  background: #F1EADF;
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0;
}
.heave-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  border-radius: 999px;
  transition: width .25s ease-out;
}
.heave-btn {
  width: 100%;
  font-family: var(--font);
  font-size: 26px;
  font-weight: 900;
  padding: 22px;
  border: none;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 0 var(--accent-deep);
  cursor: pointer;
}
.heave-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-deep); }

/* loyalty card in coffee puzzle */
.loyalty-card {
  background: linear-gradient(135deg, #FFF7E8, #FFE9D2);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
}

/* ============ CHAPTER SPLASH ============ */
#chapter-splash {
  position: fixed; inset: 0;
  z-index: 60;
  background: linear-gradient(160deg, #FF9E6D, #FFC24B);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
  color: #fff;
  animation: fadein .3s;
}
@keyframes fadein { from { opacity: 0; } }
#chapter-splash .splash-star { font-size: 64px; animation: spinstar .9s ease-out; }
@keyframes spinstar { from { transform: scale(0) rotate(-180deg); } 70% { transform: scale(1.2) rotate(10deg);} }
#chapter-splash h2 { font-size: 30px; text-shadow: 0 2px 0 rgba(0,0,0,.15); }
#chapter-splash .splash-detail { font-size: 17px; font-weight: 600; opacity: .95; }
#chapter-splash .splash-break {
  background: rgba(255,255,255,.22);
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
}
#chapter-splash .big-btn { margin-top: 10px; background: #fff; color: var(--accent-deep); box-shadow: 0 5px 0 rgba(0,0,0,.18); }

/* ============ TOASTS + FX ============ */
#toast-layer {
  position: fixed;
  top: calc(60px + env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 70;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: toastin 2.2s forwards;
}
.toast.gold { background: var(--gold); color: #6B4A08; }
@keyframes toastin {
  0% { transform: translateY(-16px) scale(.8); opacity: 0; }
  12% { transform: translateY(0) scale(1); opacity: 1; }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}

#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 65; overflow: hidden; }
.confetti {
  position: absolute;
  width: 10px; height: 14px;
  top: -20px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}
.spark-fly {
  position: absolute;
  font-size: 18px;
  animation: sparkfly .9s ease-out forwards;
  pointer-events: none;
}
@keyframes sparkfly {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  25% { opacity: 1; transform: translateY(-14px) scale(1.15); }
  100% { transform: translateY(-52px) scale(.9); opacity: 0; }
}

/* ============ WIDE SCREENS (desktop preview) ============ */
@media (min-width: 700px) {
  #game-screen { max-width: 520px; margin: 0 auto; }
}
