:root {
  --panel: #22183f;
  --panel-2: #33265e;
  --line: #4a3a7a;
  --gold: #f5d76e;
  --text: #fbf4e4;
  --muted: #b9acd9;
  --pink: #ff8fb8;
  --parch: #f6e7c8;
  --ink: #3b2716;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }

body {
  background: radial-gradient(ellipse at top, #2d1d52, #0b0717 70%);
  color: var(--text);
  font-family: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; cursor: pointer; }

#game {
  width: min(calc(100vw - 16px), calc((100vh - 160px) * 16 / 9));
  width: min(calc(100vw - 16px), calc((100dvh - 160px) * 16 / 9));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- top bar ---------- */
#topbar { display: flex; align-items: center; gap: 8px; height: 52px; }
#topbar h1 {
  margin: 0 auto 0 4px;
  font-size: clamp(16px, 2.2vw, 26px);
  color: var(--gold);
  text-shadow: 0 2px 0 #0006;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  height: 46px;
  min-width: 46px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 500;
  transition: transform .1s, background .2s;
}
button.hud-btn:hover { background: var(--panel-2); }
button.hud-btn:active { transform: scale(.94); }
.counter { font-weight: 600; color: var(--gold); }
#cat-icon svg { width: 30px; height: 30px; display: block; }
@media (max-width: 760px) { .label { display: none; } #topbar h1 { font-size: 16px; } }

.wiggle { animation: wiggle .6s; }
@keyframes wiggle {
  20% { transform: rotate(-8deg) scale(1.08); }
  40% { transform: rotate(7deg) scale(1.08); }
  60% { transform: rotate(-4deg); }
  80% { transform: rotate(3deg); }
}

/* ---------- stage ---------- */
#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 10px 40px #0009, 0 0 0 3px #3b2d66;
}
#scene, #scene svg { width: 100%; height: 100%; display: block; }
#scene.fade-in { animation: fadein .45s ease; }
@keyframes fadein { from { opacity: 0; } }

#scene [data-hs] { cursor: pointer; }
#scene [data-hs]:not(.nohl):hover { filter: brightness(1.22); }
/* Glows, bubbles and twinkles are decoration: clicks go through them to whatever is underneath (like hidden cats). */
#scene .pulse, #scene .bubble, #scene .twinkle, #scene .float { pointer-events: none; }
.hcat.found { filter: drop-shadow(0 0 6px #ffe066) drop-shadow(0 0 2px #fff); pointer-events: none; }

.twinkle { animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .2; } }
.pulse { animation: pulse 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { opacity: .6; transform: scale(.92); } }
.bubble { animation: bubble 2.6s ease-in infinite; }
@keyframes bubble { from { transform: translateY(0); opacity: .9; } to { transform: translateY(-70px); opacity: 0; } }
.float { animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px); opacity: .6; } }

#scene-name {
  position: absolute;
  top: 10px;
  left: 12px;
  background: #0009;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: clamp(12px, 1.4vw, 16px);
  color: var(--muted);
  pointer-events: none;
}

.exit {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1b1233dd;
  border: 2px solid var(--gold);
  color: var(--gold);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: clamp(13px, 1.6vw, 18px);
  font-weight: 600;
  box-shadow: 0 4px 12px #0007;
}
.exit:hover { background: #3b2566ee; }
.exit-right { right: 10px; top: 50%; animation: nudge-r 1.6s ease-in-out infinite; }
.exit-left { left: 10px; top: 50%; animation: nudge-l 1.6s ease-in-out infinite; }
.exit-down { left: 12px; bottom: 12px; animation: nudge-d 1.6s ease-in-out infinite; }
@keyframes nudge-r { 0%, 100% { transform: translate(0, -50%); } 50% { transform: translate(5px, -50%); } }
@keyframes nudge-l { 0%, 100% { transform: translate(0, -50%); } 50% { transform: translate(-5px, -50%); } }
@keyframes nudge-d { 50% { transform: translateY(5px); } }

#tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: #000c;
  color: #fff;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 15px;
  white-space: nowrap;
  transform: translate(16px, 16px);
}
#held {
  position: absolute;
  z-index: 6;
  width: 56px;
  height: 56px;
  pointer-events: none;
  transform: translate(-30%, -30%);
  filter: drop-shadow(0 0 8px var(--gold));
}
#held svg { width: 100%; height: 100%; }

/* ---------- dialog ---------- */
#dialog {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  padding: 2%;
  background: linear-gradient(transparent 50%, #0007);
  cursor: pointer;
  animation: fadein .2s;
}
.dlg-box { display: flex; align-items: flex-end; gap: 14px; width: 100%; }
#dlg-portrait {
  flex: 0 0 auto;
  width: clamp(70px, 14%, 150px);
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 40%, #5a4a9a, #221845);
  border: 3px solid var(--gold);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 6px 16px #0008;
}
#dlg-portrait svg { width: 100%; height: 100%; display: block; }
.dlg-bubble {
  flex: 1;
  position: relative;
  min-height: 92px;
  background: var(--parch);
  color: var(--ink);
  border: 3px solid #c9a86a;
  border-radius: 18px;
  padding: 10px 44px 14px 18px;
  box-shadow: 0 6px 20px #0009;
}
#dlg-name { font-weight: 700; color: #7a3fa0; font-size: clamp(14px, 1.6vw, 19px); margin-bottom: 2px; }
#dlg-text { font-size: clamp(15px, 2vw, 24px); line-height: 1.35; }
#dlg-text .ch { opacity: 0; animation: chIn .01s forwards; }
#dlg-text.instant .ch { animation: none; opacity: 1; }
@keyframes chIn { to { opacity: 1; } }
.clue { color: #b03a7a; font-weight: 700; background: #ffd6ea; border-radius: 6px; padding: 0 3px; margin: 0 -1px; }
#dlg-next { position: absolute; right: 14px; bottom: 8px; color: #a0703a; font-size: 20px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- toasts ---------- */
#toasts {
  position: absolute;
  z-index: 20;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1b1233ee;
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: clamp(13px, 1.5vw, 18px);
  white-space: nowrap;
  box-shadow: 0 6px 18px #0008;
  animation: toastIn .35s cubic-bezier(.2, 1.6, .4, 1);
  transition: opacity .4s, transform .4s;
}
.toast svg { width: 34px; height: 34px; }
.toast.cat { border-color: #ffb3d9; }
.toast.clue { border-color: var(--pink); }
.toast.tip { border-color: var(--muted); }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.8); } }

.spark {
  position: fixed;
  z-index: 100;
  width: 14px;
  height: 14px;
  pointer-events: none;
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
  animation: spark .9s ease-out forwards;
}
@keyframes spark {
  from { transform: translate(-50%, -50%) scale(1.2) rotate(0); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3) rotate(180deg); opacity: 0; }
}

/* ---------- inventory ---------- */
#inventory {
  display: flex;
  justify-content: center;
  gap: 10px;
  height: 88px;
  padding: 7px;
  background: #1a1233;
  border: 2px solid #3b2d66;
  border-radius: 16px;
}
.slot {
  position: relative;
  width: 72px;
  height: 72px;
  padding: 6px;
  background: #2a1f4d;
  border: 2px solid var(--line);
  border-radius: 14px;
  transition: transform .15s, box-shadow .15s;
}
.slot svg { width: 100%; height: 100%; display: block; }
.slot.empty { opacity: .4; }
button.slot:hover { transform: translateY(-2px); }
.slot.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px #f5d76e55, 0 0 18px #f5d76e99;
  transform: translateY(-4px);
}
.slot-name {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #000d;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
button.slot:hover .slot-name, .slot.selected .slot-name { opacity: 1; }
.slot.pop { animation: pop .6s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes pop { from { transform: scale(.3); } }

/* ---------- buttons ---------- */
.btn {
  background: linear-gradient(#8a5ad0, #5a2d9a);
  border: 2px solid var(--gold);
  color: #fff;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 18px;
  font-weight: 600;
  box-shadow: 0 4px 0 #3a1d66;
  transition: transform .1s;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #3a1d66; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { font-size: 22px; padding: 12px 30px; }
.btn.alt { background: linear-gradient(#3fa98a, #20705a); box-shadow: 0 4px 0 #134a3a; }
.btn.danger { background: linear-gradient(#d0607a, #9a2d4a); box-shadow: 0 4px 0 #5a1a2a; }
.row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; align-items: center; }

/* ---------- modals ---------- */
#modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #0009;
  backdrop-filter: blur(3px);
}
.modal-box { width: 100%; max-width: 720px; max-height: 100%; overflow: auto; animation: modalIn .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes modalIn { from { transform: scale(.85); opacity: 0; } }
.modal-box h2 { margin: 6px 0 12px; }

.book {
  background: var(--parch);
  color: var(--ink);
  border: 4px solid #8a5a2b;
  border-radius: 18px;
  padding: 16px 26px 16px;
  box-shadow: inset 0 0 50px #c9a86a88, 0 20px 60px #000a;
}
.book-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: #8a5a2b; }
.x { background: none; border: none; font-size: 22px; color: #8a5a2b; }
.book h2 { text-align: center; font-size: clamp(20px, 3vw, 28px); color: #5a2d7a; }
.sentence { font-size: clamp(18px, 2.6vw, 26px); line-height: 2.2; text-align: center; margin: 8px 0; }
.blank {
  min-width: 110px;
  margin: 0 2px;
  padding: 2px 12px;
  background: #fff6e0;
  color: #a07a50;
  border: none;
  border-bottom: 3px dashed #8a5a2b;
  border-radius: 8px;
  font-weight: 600;
}
.blank.filled { color: #5a2d7a; background: #f0e0ff; border-bottom-style: solid; }
.blank.active { outline: 3px solid var(--pink); box-shadow: 0 0 0 6px #ff8fb844; }
.blank:disabled { cursor: default; }
.pool-label { text-align: center; margin-top: 10px; color: #8a5a2b; }
.pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 10px 0; min-height: 48px; align-items: center; }
.pool em { color: #8a6a4a; }
.chip {
  background: #ffd6ea;
  border: 2px solid #d06a9a;
  color: #7a2a55;
  border-radius: 999px;
  padding: 6px 18px;
  font-size: 20px;
  font-weight: 600;
  transition: transform .1s;
}
.chip:hover { transform: scale(1.06); }
.chip.used { background: #b03a7a; color: #fff; }
.book-msg { text-align: center; min-height: 1.4em; margin: 6px 0; color: #b03a3a; font-weight: 600; }
.book .btn.big { display: block; margin: 4px auto 0; }
.book-foot { text-align: center; font-size: 14px; color: #8a6a4a; margin-top: 12px; }
.stamp { text-align: center; font-size: 28px; font-weight: 700; color: #2e8a4a; transform: rotate(-4deg); }

.puzzle, .end, .menu {
  background: linear-gradient(#3b2566, #1f1438);
  border: 4px solid var(--gold);
  border-radius: 20px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 20px 60px #000a;
}
.puzzle h2, .end h2, .menu h2 { color: var(--gold); font-size: 30px; }
.dials { display: flex; justify-content: center; gap: 18px; margin: 20px 0; }
.dial {
  width: clamp(80px, 18vw, 120px);
  aspect-ratio: 1;
  padding: 14px;
  background: radial-gradient(#4b3a8a, #221845);
  border: 3px solid #8a6ad0;
  border-radius: 20px;
  transition: border-color .3s, box-shadow .3s;
}
.dial svg { width: 100%; height: 100%; display: block; }
.dial.spin svg { animation: spin .3s ease-out; }
@keyframes spin { from { transform: rotateY(90deg) scale(.7); } }
.dials.solved .dial { border-color: #b6ff8a; box-shadow: 0 0 24px #b6ff8a; }
.hint { color: var(--muted); font-style: italic; }
.menu { max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.menu h2 { margin-bottom: 4px; }
.end-art { width: 140px; height: 140px; margin: 0 auto; border-radius: 50%; overflow: hidden; border: 4px solid var(--gold); background: radial-gradient(circle at 50% 40%, #5a4a9a, #221845); }
.end-art svg { width: 100%; height: 100%; }
.end p { font-size: 19px; }
.end-cats { color: var(--gold); }

/* ---------- title screen ---------- */
#title {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 30%, #3a2670, #0b0717 75%);
}
#title-art { width: min(90vw, 520px); }
#title-art svg { width: 100%; display: block; }
#title h1 { margin: 0; font-size: clamp(34px, 6vw, 66px); color: var(--gold); text-shadow: 0 4px 0 #5a2d9a, 0 0 30px #f5d76e66; }
#title h2 { margin: 4px 0 24px; font-weight: 500; font-size: clamp(18px, 3vw, 30px); color: var(--pink); }
#title .small { color: var(--muted); margin-top: 22px; }

/* ---------- chapter select ---------- */
#chapters {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 16px;
  overflow-y: auto;
  background: radial-gradient(ellipse at 50% 20%, #3a2670, #0b0717 75%);
}
#chapters h1 { margin: 0; color: var(--gold); font-size: clamp(28px, 5vw, 48px); text-shadow: 0 4px 0 #5a2d9a; }
#chapter-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; max-width: 1200px; }
.card {
  width: 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px;
  text-align: center;
  background: linear-gradient(#33265e, #1f1438);
  border: 3px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 10px 30px #0008;
}
.card.done { border-color: #7fdc9a; }
.card.locked, .card.soon { opacity: .55; }
.card-num { font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--pink); }
.card-art { width: 120px; height: 100px; display: flex; align-items: center; justify-content: center; }
.card-art svg { width: 100%; height: 100%; }
.card-art.q { font-size: 60px; color: var(--muted); }
.card h3 { margin: 0; font-size: 19px; color: var(--gold); }
.card-blurb { margin: 0; font-size: 14px; color: var(--muted); }
.card-status, .card-cats { margin: 0; font-size: 15px; }
.card-btns { display: flex; flex-direction: column; gap: 8px; margin-top: auto; width: 100%; }
.card .btn { font-size: 16px; padding: 8px 14px; }
.btn.ghost { background: transparent; border-color: var(--line); box-shadow: none; font-size: 14px; }
.unlocked { color: #b6ff8a; }

/* ---------- magnifying glass ---------- */
#stage.lens-mode #scene { cursor: crosshair; touch-action: none; }

/* ---------- more puzzles ---------- */
.sort-row { display: flex; justify-content: center; gap: 10px; margin: 20px 0; flex-wrap: wrap; }
.sort-item {
  width: clamp(64px, 14vw, 100px);
  aspect-ratio: 1;
  padding: 4px;
  background: #2a1f4d;
  border: 3px solid var(--line);
  border-radius: 16px;
  transition: transform .15s;
}
.sort-item svg, .choice svg, .bottle svg { width: 100%; height: 100%; display: block; }
.sort-item.picked { border-color: var(--gold); transform: translateY(-8px); box-shadow: 0 0 18px #f5d76e99; }
.sort-row.solved .sort-item { border-color: #b6ff8a; box-shadow: 0 0 18px #b6ff8a; }

.jig-board { display: grid; gap: 3px; width: min(100%, 400px); margin: 14px auto; padding: 3px; background: #1a1233; border-radius: 10px; }
.jig-cell { display: block; padding: 0; border: 2px dashed #6a5aa0; border-radius: 6px; background: #2a1f4d; overflow: hidden; }
.jig-cell.placed { border: none; border-radius: 0; }
.jig-cell svg, .jig-piece svg { width: 100%; height: 100%; display: block; }
.jig-tray { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; min-height: 20px; }
.jig-piece { width: clamp(90px, 22vw, 140px); padding: 0; border: 3px solid transparent; border-radius: 6px; background: none; transform: rotate(var(--r)); transition: transform .15s; box-shadow: 0 6px 14px #0008; overflow: hidden; }
.jig-piece.picked { border-color: var(--gold); transform: rotate(0) scale(1.08); }

.cauldron-big { width: 200px; margin: 6px auto 0; }
.cauldron-big svg { width: 100%; display: block; }
.drops { color: var(--muted); min-height: 1.4em; }
.bottles { display: flex; justify-content: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.bottle { width: 88px; padding: 8px 6px 6px; background: #2a1f4d; border: 3px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 15px; }
.bottle svg { width: 56px; height: 56px; }
.bottle.missing { opacity: .45; }
.bottle:active { transform: scale(.94); }

.choice-pic { display: flex; justify-content: center; }
.bite-pic { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.bite-pic svg { width: 130px; height: 130px; }
.choices { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.choice { width: 120px; padding: 8px; background: #2a1f4d; border: 3px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 15px; }
.choice svg { width: 96px; height: 96px; }
.choice.wrong { border-color: #d0607a; animation: wiggle .5s; }
.choice.right { border-color: #b6ff8a; box-shadow: 0 0 20px #b6ff8a; }
.puzzle .book-msg { color: #ffb3c8; }

.page-nav { display: flex; align-items: center; justify-content: center; gap: 14px; color: #8a5a2b; font-weight: 600; }
.pg { width: 38px; height: 38px; border-radius: 50%; border: 2px solid #8a5a2b; background: #fff6e0; color: #8a5a2b; font-size: 16px; }
.pg:disabled { opacity: .3; cursor: default; }

.exit-up { right: 12px; top: 12px; animation: nudge-u 1.6s ease-in-out infinite; }
@keyframes nudge-u { 50% { transform: translateY(-4px); } }

/* ---------- effects ---------- */
#scene.grow-in { animation: growin .9s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes growin { from { transform: scale(.25); opacity: 0; filter: hue-rotate(90deg); } }
.shooting-star {
  position: absolute;
  z-index: 9;
  top: 8%;
  left: 20%;
  width: 160px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent, #fff8d0);
  box-shadow: 0 0 12px #fff8d0;
  transform: rotate(18deg);
  pointer-events: none;
  animation: shoot 1.6s ease-in forwards;
}
@keyframes shoot {
  from { opacity: 0; translate: 0 0; }
  15% { opacity: 1; }
  to { opacity: 0; translate: 55vw 22vw; }
}

/* ---------- Chapter 3 ---------- */
.echo-ring { animation: echoring 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes echoring { from { transform: scale(.4); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }
#dialog.echo .dlg-bubble { background: #dcecff; border-color: #8ec9f5; font-style: italic; }
#dialog.echo #dlg-name { color: #2e6aa8; }
#dialog.echo #dlg-portrait { opacity: .75; border-color: #9fd8ff; box-shadow: 0 0 20px #9fd8ff; }

.progress { color: var(--pink); font-weight: 600; margin-bottom: 6px; }
.riddle { font-size: clamp(18px, 2.4vw, 24px); }
.choice .emoji { font-size: 54px; line-height: 1.1; }

.pads { display: flex; justify-content: center; gap: 14px; margin: 18px 0 8px; flex-wrap: wrap; }
.pad { width: clamp(76px, 16vw, 110px); aspect-ratio: 1; padding: 6px; border-radius: 50%; background: radial-gradient(#2a2244, #140f28); border: 3px solid var(--line); transition: transform .1s, box-shadow .1s; }
.pad svg { width: 100%; height: 100%; display: block; }
.pad.lit { transform: scale(1.12); border-color: var(--glow); box-shadow: 0 0 30px var(--glow), inset 0 0 30px var(--glow); }
.melody-secret { height: 44px; display: flex; justify-content: flex-end; opacity: 0; pointer-events: none; transition: opacity .3s; }
.melody.playing .melody-secret { opacity: 1; pointer-events: auto; }
.melody-secret svg { height: 44px; width: 44px; }

.stones { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 10px; background: #15345a; border-radius: 16px; }
.stone-row { display: flex; gap: 10px; }
.stone { width: clamp(56px, 11vw, 74px); aspect-ratio: 1.2; padding: 8px; border-radius: 50%; background: #6f6a80; border: 3px solid #4a4658; }
.stone svg { width: 100%; height: 100%; display: block; }
.stone.on { background: #b6ff8a; border-color: #fff; box-shadow: 0 0 16px #b6ff8a; }
.stones-goal { color: var(--muted); font-size: 15px; margin: 4px 0; }

.fishing { width: min(100%, 400px); margin: 10px auto; border-radius: 14px; overflow: hidden; }
.fishing svg { width: 100%; display: block; }
#bobber { transition: transform .15s; animation: bobbing 1.4s ease-in-out infinite; }
#bobber.dip { transform: translateY(16px); animation: none; }
#bobber .ripple { opacity: 0; }
#bobber.dip .ripple { opacity: 1; }
@keyframes bobbing { 50% { transform: translateY(4px); } }
.caught { display: flex; justify-content: center; gap: 12px; min-height: 10px; }
.catch { display: flex; flex-direction: column; align-items: center; font-size: 14px; color: var(--muted); }
.catch svg { width: 64px; height: 64px; }

.faces-title { text-align: center; font-size: 20px; margin: 6px 0; }
.faces { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.face { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.face-art { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 40%, #5a4a9a, #221845); border: 3px solid #8a5a2b; }
.face-art svg { width: 100%; height: 100%; display: block; }
.face .blank { min-width: 100px; font-size: 17px; }

/* ---------- Chapter 4 ---------- */
.flash { position: absolute; inset: 0; z-index: 9; background: #e6f6ff; pointer-events: none; animation: flash 1.1s ease-out forwards; }
@keyframes flash { from { opacity: .95; } to { opacity: 0; } }

.inspect { background: linear-gradient(#e8f6ff, #cfe6fb); color: #1f2f4e; border: 4px solid #9fd8ff; border-radius: 20px; padding: 18px 22px; box-shadow: 0 0 40px #9fd8ff88, 0 20px 60px #000a; }
.inspect-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.inspect-head h2 { margin: 0; color: #2e4a8a; font-size: 26px; }
.inspect-art { width: 96px; height: 96px; flex: 0 0 auto; border-radius: 50%; overflow: hidden; border: 4px solid #9fd8ff; background: radial-gradient(circle at 50% 40%, #5a4a9a, #221845); }
.inspect-art svg { width: 100%; height: 100%; display: block; }
.frozen-tag { margin: 2px 0 0; color: #4a8ac8; font-weight: 600; }
.inspect-row { display: flex; gap: 12px; align-items: flex-start; background: #fff9; border-radius: 14px; padding: 8px 12px; margin: 8px 0; }
.inspect-row p { margin: 2px 0 0; font-size: clamp(16px, 2vw, 20px); line-height: 1.5; }
.ir-icon { font-size: 30px; line-height: 1; }
.inspect .hint { color: #4a6a9a; text-align: center; }
.inspect .btn { display: block; margin: 6px auto 0; }
.clue-chip { background: #ffd6ea; color: #b03a7a; border: 2px dashed #d06a9a; border-radius: 8px; padding: 0 6px; font-weight: 700; font-size: inherit; animation: chipGlow 1.6s ease-in-out infinite; }
.clue-chip.got { background: #b03a7a; color: #fff; border-style: solid; animation: none; }
@keyframes chipGlow { 50% { box-shadow: 0 0 10px #ff8fb8; } }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 8px auto; max-width: 440px; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.steps li::before { content: counter(step); width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; background: #5a2d7a; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.steps .blank { flex: 1; text-align: left; }
.wart { margin-right: 6px; }

.scale-art { width: min(100%, 400px); margin: 0 auto; }
.scale-art svg { width: 100%; display: block; }
.weights { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.weight { width: 96px; padding: 6px; background: #2a1f4d; border: 3px solid var(--line); border-radius: 14px; transition: transform .15s; }
.weight svg { width: 100%; display: block; }
.weight.on { border-color: var(--gold); transform: translateY(-6px); box-shadow: 0 0 14px #f5d76e99; }

.modal-box.wide { max-width: 980px; }
.diff-pair { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.diff-pair figure { margin: 0; flex: 1 1 300px; max-width: 440px; }
.diff-pair svg { width: 100%; display: block; border-radius: 10px; border: 4px solid #fff; }
#diffB { cursor: crosshair; }
.diff-pair figcaption { color: var(--muted); margin-top: 4px; }

.connect { width: min(100%, 460px); margin: 10px auto; }
.connect svg { width: 100%; display: block; border-radius: 12px; }
.connect .dot { cursor: pointer; }

/* ---------- Chapter 5 ---------- */
.rings { width: min(100%, 380px); margin: 10px auto; }
.rings svg { width: 100%; display: block; }
.rings [data-ring] { cursor: pointer; }
.series { background: #ffffff14; border-radius: 14px; padding: 6px 12px; margin: 8px 0; }
.series p { margin: 6px 0; }
.rank { font-size: 22px; color: var(--gold); }
