/* ==========================================================
   Level-specific challenge styles
   ========================================================== */

/* ---------- Shared level layout ---------- */

.level-header {
  margin-bottom: 2.5vmin;
}

.challenge-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5vmin;
  width: 100%;
}

.success-line {
  font-size: clamp(9px, 2vmin, 15px);
  line-height: 2;
  color: var(--gold-bright);
  text-shadow: 0 0 10px rgba(240, 184, 96, 0.6), 2px 2px 0 var(--night-deep);
  max-width: 60ch;
  animation: success-pop 0.45s ease;
}

@keyframes success-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Level 1: riddle ---------- */

/* Bookshelf walls receding into the room on both sides */
.shelf-wall {
  position: absolute;
  top: 6%;
  width: 26%;
  height: 66%;
  background:
    repeating-linear-gradient(180deg,
      #241634 0 16%,
      #1c1028 16% 19%),
    repeating-linear-gradient(90deg,
      rgba(240, 184, 96, 0.12) 0 6px, transparent 6px 22px);
  border: 3px solid #1c1028;
  pointer-events: none;
  z-index: 0;
}

.shelf-wall.left {
  left: -6%;
  transform: perspective(600px) rotateY(52deg);
  transform-origin: left center;
}

.shelf-wall.right {
  right: -6%;
  transform: perspective(600px) rotateY(-52deg);
  transform-origin: right center;
}

/* The riddle tome floats and bobs in mid-air */
.floating-tome {
  animation: tome-float 2.6s ease-in-out infinite;
  transform-style: preserve-3d;
  box-shadow:
    0 0 18px rgba(240, 184, 96, 0.25),
    0 24px 26px -14px rgba(0, 0, 0, 0.65);
}

@keyframes tome-float {
  0%, 100% { transform: perspective(700px) rotateX(6deg) translateY(0); }
  50% { transform: perspective(700px) rotateX(6deg) translateY(-9px); }
}

.riddle-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2vmin;
}

.riddle-options .pixel-btn {
  font-size: clamp(9px, 1.9vmin, 14px);
}

.riddle-options .pixel-btn.wrong {
  animation: shake 0.4s ease;
  filter: saturate(0.4) brightness(0.75);
}

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

.hint-line {
  font-size: clamp(8px, 1.7vmin, 13px);
  color: var(--pink);
  text-shadow: 2px 2px 0 var(--night-deep);
  animation: success-pop 0.4s ease;
}

/* ---------- Level 2: memory match ---------- */

/* The cards lie on a tilted tearoom table */
/* Tilted table look, but a FLAT rendering context: cards flip inside
   their own perspective, never intersecting (and clipping through)
   the table plane — and hit areas stay exactly where cards appear. */
.table3d {
  transform: perspective(950px) rotateX(24deg);
  background:
    radial-gradient(60% 60% at 50% 30%, rgba(255, 217, 138, 0.12), transparent 70%),
    repeating-linear-gradient(90deg, #5e4226 0 34px, #543a20 34px 68px);
  border: var(--px) solid #3c2a14;
  outline: 2px solid var(--night-deep);
  box-shadow:
    0 26px 34px rgba(0, 0, 0, 0.55),
    inset 0 0 34px rgba(0, 0, 0, 0.35);
  padding: 2.4vmin 3vmin;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.6vmin;
}

.memory-card {
  width: clamp(48px, 11vmin, 92px);
  height: clamp(56px, 13vmin, 108px);
  perspective: 600px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: transform 0.2s ease;
}

/* Cards lift off the table toward you */
.memory-card:hover:not(.matched) {
  transform: translateY(-5px) scale(1.05);
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--px) solid var(--gold-dim);
  outline: 2px solid var(--night-deep);
}

.memory-card-back {
  background:
    radial-gradient(circle at 50% 40%, rgba(240, 184, 96, 0.25) 0%, transparent 55%),
    linear-gradient(180deg, var(--night-soft) 0%, var(--night) 100%);
  font-size: clamp(14px, 3vmin, 24px);
  color: var(--gold-dim);
}

.memory-card-front {
  background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border-color: var(--gold);
  font-size: clamp(20px, 4.5vmin, 40px);
  transform: rotateY(180deg);
}

.memory-card.matched .memory-card-face {
  border-color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(240, 184, 96, 0.7);
}

.memory-card.matched {
  cursor: default;
  animation: match-bounce 0.4s ease;
}

@keyframes match-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ---------- Level 3: the long road ---------- */

.road-scene {
  position: relative;
  width: min(88cqw, 1100px);
  height: min(56cqh, 420px);
  border: var(--px) solid var(--purple-mid);
  outline: 2px solid var(--night-deep);
  overflow: hidden;
  background: linear-gradient(180deg, #0e0a24 0%, #241540 52%, #2e2444 60%, #3a3050 100%);
}

/* Moon */
.road-scene::before {
  content: "";
  position: absolute;
  top: 8%;
  right: 10%;
  width: clamp(28px, 6vmin, 52px);
  height: clamp(28px, 6vmin, 52px);
  background: radial-gradient(circle at 40% 40%, #fff7dd 0%, var(--gold-bright) 60%, var(--gold) 100%);
  border-radius: 50%;
  box-shadow: 0 0 26px rgba(255, 217, 138, 0.7);
}

/* A real 3D road plane, tilted back, with dashes rolling toward you */
.road-strip {
  position: absolute;
  bottom: -8%;
  left: 50%;
  width: 64%;
  height: 78%;
  background:
    repeating-linear-gradient(180deg, #2a2438 0 40px, #262034 40px 80px);
  border-left: 6px solid #3a3050;
  border-right: 6px solid #3a3050;
  transform: translateX(-50%) perspective(300px) rotateX(52deg);
  transform-origin: 50% 100%;
  animation: road-roll 1.6s linear infinite;
}

.road-strip::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 7%;
  height: 100%;
  background: repeating-linear-gradient(
    180deg,
    var(--gold-dim) 0 34px,
    transparent 34px 80px
  );
  animation: road-roll 1.6s linear infinite;
}

@keyframes road-roll {
  from { background-position-y: 0; }
  to   { background-position-y: 80px; }
}

.charm {
  position: absolute;
  font-size: clamp(18px, 4vmin, 34px);
  background: none;
  border: none;
  cursor: pointer;
  padding: 1vmin;
  filter: drop-shadow(0 0 4px rgba(255, 217, 138, 0.5));
  transition: transform 0.15s ease;
  z-index: 2;
}

.charm:hover { transform: scale(1.2); }

.charm.hinting {
  animation: charm-hint 1.1s ease-in-out infinite;
}

@keyframes charm-hint {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 217, 138, 0.5)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 217, 138, 1)); transform: scale(1.22); }
}

.charm.found {
  animation: charm-found 0.5s ease forwards;
  pointer-events: none;
}

@keyframes charm-found {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.5) rotate(10deg); }
  100% { transform: scale(0.2) translateY(-60px); opacity: 0; }
}

.charm-tray {
  display: flex;
  gap: 2vmin;
  align-items: center;
  font-size: clamp(16px, 3.4vmin, 28px);
}

.charm-tray .tray-slot {
  width: clamp(34px, 7vmin, 56px);
  height: clamp(34px, 7vmin, 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--night);
  border: 2px solid var(--gold-dim);
  opacity: 0.6;
}

.charm-tray .tray-slot.collected {
  opacity: 1;
  border-color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(240, 184, 96, 0.6);
  animation: match-bounce 0.4s ease;
}

.found-toast {
  position: absolute;
  top: 4%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(8px, 1.8vmin, 14px);
  color: var(--gold-bright);
  text-shadow: 2px 2px 0 var(--night-deep);
  animation: toast-in 0.4s ease;
  z-index: 3;
  pointer-events: none;
  text-align: center;
  width: max-content;
  max-width: 94%;
}

/* Pop-in that keeps the centering translate intact */
@keyframes toast-in {
  0%   { transform: translateX(-50%) scale(0.6); opacity: 0; }
  70%  { transform: translateX(-50%) scale(1.08); }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ---------- Level 4: the sea ---------- */

.beach-scene {
  position: relative;
  width: min(88cqw, 1100px);
  height: min(56cqh, 420px);
  border: var(--px) solid #22315c;
  outline: 2px solid var(--night-deep);
  overflow: hidden;
  background: linear-gradient(180deg, #101a34 0%, #22315c 42%, #2e4a74 58%, #d8c290 78%, #c9ab6e 100%);
}

/* Moon over water */
.beach-scene::before {
  content: "";
  position: absolute;
  top: 7%;
  left: 12%;
  width: clamp(26px, 5.5vmin, 48px);
  height: clamp(26px, 5.5vmin, 48px);
  background: radial-gradient(circle at 40% 40%, #ffffff 0%, #e8eeff 60%, #b8c8e8 100%);
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(232, 238, 255, 0.8);
}

/* ----- The sea: gradient depth, scalloped swells, moon glitter ----- */

.sea {
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  height: 44%;
  overflow: hidden;
  background: linear-gradient(180deg, #16294a 0%, #1f3a60 30%, #2a4a74 62%, #3a628c 100%);
  pointer-events: none;
}

/* Pale light band where sea meets sky */
.sea::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10%;
  background: linear-gradient(180deg, rgba(200, 220, 255, 0.35), transparent);
}

/* Rows of scalloped wave crests drifting sideways */
.sea-swell {
  position: absolute;
  left: -40%;
  width: 180%;
  height: 16%;
  background:
    radial-gradient(16px 11px at 15px 3px, rgba(160, 200, 240, 0.4) 52%, transparent 56%)
      repeat-x 0 0 / 30px 100%,
    linear-gradient(180deg, rgba(160, 200, 240, 0.14), transparent 70%);
  animation: swell-drift linear infinite;
}

.sea-swell.s1 { top: 22%; animation-duration: 11s; opacity: 0.45; transform: scaleY(0.7); }
.sea-swell.s2 { top: 48%; animation-duration: 8s; animation-direction: reverse; opacity: 0.7; }
.sea-swell.s3 { top: 74%; animation-duration: 6s; opacity: 0.95; transform: scaleY(1.3); }

@keyframes swell-drift {
  from { background-position-x: 0, 0; }
  to   { background-position-x: 60px, 0; }
}

/* Moonlight glitter path on the water, under the moon */
.sea-glitter {
  position: absolute;
  top: 4%;
  bottom: 4%;
  left: 7%;
  width: 12%;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(230, 240, 255, 0.35) 0 2px,
      transparent 2px 9px
    );
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.9), rgba(0,0,0,0.25)),
    radial-gradient(60% 100% at 50% 50%, #000 40%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: radial-gradient(55% 100% at 50% 50%, #000 30%, transparent 90%);
  animation: glitter-shimmer 2.4s ease-in-out infinite;
}

@keyframes glitter-shimmer {
  0%, 100% { opacity: 0.55; background-position-y: 0; }
  50% { opacity: 0.9; background-position-y: 3px; }
}

/* Foam where the tide meets the sand — breathes in and out */
.shore-foam {
  position: absolute;
  top: 71%;
  left: -6%;
  right: -6%;
  height: 5%;
  background:
    radial-gradient(18px 12px at 16px 2px, rgba(245, 250, 255, 0.75) 50%, transparent 56%)
      repeat-x 0 0 / 34px 100%;
  animation: foam-tide 4.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes foam-tide {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50% { transform: translateY(9px); opacity: 0.45; }
}

/* The sand is a tilted plane running toward the viewer */
.beach-scene .sand-plane {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -10%;
  height: 34%;
  background:
    radial-gradient(circle at 30% 40%, rgba(138, 106, 56, 0.35) 2px, transparent 3px) 0 0 / 46px 26px,
    radial-gradient(circle at 70% 70%, rgba(255, 244, 214, 0.3) 2px, transparent 3px) 12px 8px / 52px 30px,
    linear-gradient(180deg, #d8c290 0%, #c9ab6e 100%);
  transform: perspective(320px) rotateX(48deg);
  transform-origin: 50% 100%;
  pointer-events: none;
}

.driftwood-sign {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%) perspective(500px) rotateY(-7deg) rotateX(3deg);
  background: linear-gradient(180deg, #8a6a38 0%, #6e5228 100%);
  border: var(--px) solid #4a3620;
  outline: 2px solid var(--night-deep);
  padding: 2vmin 3vmin;
  cursor: pointer;
  text-align: center;
  z-index: 2;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  transition: left 0.5s ease, bottom 0.5s ease, transform 0.5s ease, padding 0.5s ease;
}

/* After the message resolves, the sign shrinks aside for the records */
.driftwood-sign.sign-retreat {
  left: 85%;
  bottom: 32%;
  transform: translateX(-50%) scale(0.55) rotate(-4deg);
  z-index: 1;
  pointer-events: none;
}

.driftwood-sign .sign-text {
  font-size: clamp(10px, 2.4vmin, 18px);
  color: #f5e6c0;
  text-shadow: 2px 2px 0 #4a3620;
  display: inline-block;
}

.sign-letter {
  display: inline-block;
  transition: transform 0.5s cubic-bezier(0.3, 1.4, 0.5, 1), color 0.5s ease;
}

.sign-letter.settling {
  color: var(--gold-bright);
  text-shadow: 0 0 8px rgba(255, 217, 138, 0.8);
}

.sign-tap-prompt {
  display: block;
  font-size: clamp(7px, 1.4vmin, 11px);
  color: #d8c290;
  margin-top: 1vmin;
}

/* ----- Records washed ashore, bobbing on the waves ----- */

.records-row {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  gap: 3.5cqw;
  z-index: 3;
}

.vinyl-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8vmin;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-pixel);
  padding: 0;
  animation: record-bob 3.2s ease-in-out infinite;
}

@keyframes record-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-7px) rotate(2deg); }
}

.vinyl-disc {
  line-height: 0;
  transition: transform 0.2s ease, filter 0.2s ease;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
}

.vinyl-disc svg {
  width: clamp(30px, 7.5cqh, 54px);
  height: auto;
}

.vinyl-record:hover .vinyl-disc {
  transform: translateY(-4px);
}

.vinyl-record.selected .vinyl-disc {
  transform: translateY(-10px) scale(1.18);
  filter: drop-shadow(0 0 14px rgba(255, 217, 138, 0.95));
}

.vinyl-name {
  font-size: clamp(6px, 1.4vmin, 10px);
  color: var(--pink-soft);
  text-shadow: 1px 1px 0 var(--night-deep);
  background: rgba(21, 12, 40, 0.7);
  border: 1px solid var(--gold-dim);
  padding: 0.5vmin 1vmin;
  max-width: 13ch;
  line-height: 1.6;
}

/* ----- Artist crates on the sand ----- */

.crate-row {
  position: absolute;
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 3cqw;
  z-index: 3;
}

.artist-crate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6vmin;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-pixel);
  padding: 0;
  transition: transform 0.2s ease;
}

.artist-crate:hover:not(.filled) {
  transform: translateY(-4px);
}

.artist-crate.rattle {
  animation: shake 0.4s ease;
}

.crate-slot {
  height: clamp(20px, 4.6cqh, 34px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  line-height: 0;
}

.crate-slot svg {
  width: clamp(26px, 6.2cqh, 46px);
  height: auto;
}

.vinyl-spinning {
  animation: vinyl-spin 2.6s linear infinite;
  filter: drop-shadow(0 0 8px rgba(255, 217, 138, 0.7));
}

@keyframes vinyl-spin {
  to { transform: rotate(360deg); }
}

.crate-art {
  line-height: 0;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.45));
}

.crate-art svg {
  width: clamp(42px, 10cqh, 76px);
  height: auto;
}

.crate-label {
  font-size: clamp(6px, 1.5vmin, 10px);
  color: var(--gold-bright);
  text-shadow: 1px 1px 0 var(--night-deep);
  background: var(--night);
  border: 2px solid var(--gold-dim);
  padding: 0.6vmin 1.2vmin;
  line-height: 1.6;
}

.artist-crate.filled .crate-label {
  border-color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(240, 184, 96, 0.6);
}

.vinyl-flyer {
  position: fixed;
  z-index: 95;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(255, 217, 138, 0.8));
}

/* ---------- Level 5: nickname trap ---------- */

.villain-arena {
  position: relative;
  width: min(88cqw, 1100px);
  height: min(56cqh, 420px);
  border: var(--px) solid #5e2a4a;
  outline: 2px solid var(--night-deep);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(94, 42, 74, 0.6) 0%, transparent 60%),
    linear-gradient(180deg, #1e1030 0%, #3c1e4e 100%);
}

/* Tilted stone floor under the goblin */
.villain-arena::after {
  content: "";
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -12%;
  height: 46%;
  background: repeating-conic-gradient(#3c2a44 0 25%, #33233a 0 50%) 0 0 / 44px 44px;
  transform: perspective(300px) rotateX(50deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 40%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 40%);
  pointer-events: none;
}

.goblin.nyeh {
  animation: goblin-nyeh 0.4s ease;
}

@keyframes goblin-nyeh {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  30% { transform: translateX(-54%) rotate(-10deg); }
  70% { transform: translateX(-46%) rotate(10deg); }
}

.goblin {
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(34px, 8vmin, 72px);
  filter: drop-shadow(0 0 10px rgba(94, 42, 74, 0.9));
  animation: goblin-bounce 1.4s ease-in-out infinite;
  z-index: 1;
}

@keyframes goblin-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-8px); }
}

.goblin.defeated {
  animation: goblin-shrink 0.8s ease forwards;
}

@keyframes goblin-shrink {
  to { transform: translateX(-50%) scale(0.4) translateY(20px); filter: grayscale(0.6); }
}

.taunt-bubble {
  position: absolute;
  font-family: var(--font-pixel);
  font-size: clamp(9px, 2vmin, 15px);
  color: #3c1e4e;
  background: linear-gradient(180deg, #f2d8e8 0%, #d8a8c8 100%);
  border: 3px solid #5e2a4a;
  outline: 2px solid var(--night-deep);
  border-radius: 14px;
  padding: 1.4vmin 2vmin;
  cursor: pointer;
  z-index: 2;
  animation: bubble-drift 3.2s ease-in-out infinite;
  transition: transform 0.15s ease;
}

.taunt-bubble:hover { transform: scale(1.08); }

@keyframes bubble-drift {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -14px; }
}

.taunt-bubble.popped {
  animation: bubble-pop 0.35s ease forwards;
  pointer-events: none;
}

@keyframes bubble-pop {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.35); opacity: 0.9; }
  100% { transform: scale(0); opacity: 0; }
}

.cupcake-reveal {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(18px, 4.5vmin, 40px);
  color: var(--gold-bright);
  text-shadow:
    0 0 18px rgba(255, 217, 138, 0.9),
    0 0 40px rgba(242, 160, 192, 0.6),
    3px 3px 0 var(--night-deep);
  animation: reveal-glow 1.2s ease;
  white-space: nowrap;
  z-index: 3;
}

@keyframes reveal-glow {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.4); }
  60%  { opacity: 1; transform: translateX(-50%) scale(1.15); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ==========================================================
   Sprite sizing (SVGs scale via viewBox)
   ========================================================== */

.memory-card-front svg {
  width: 62%;
  height: auto;
}

.tray-slot svg {
  width: 68%;
  height: auto;
}

.shell svg,
.egg-bottle svg {
  width: clamp(22px, 4.6cqh, 36px);
  height: auto;
}

/* ---------- Level 1: floating answer tomes ---------- */

.tome-space {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 2vmin 4cqw;
}

.tome-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2vmin;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-pixel);
  transition: transform 0.2s ease, filter 0.3s ease;
}

/* Staggered depths: scale + offset only (real translateZ made the
   back tome's hit area sit under its neighbours — unclickable) */
.tome-option.depth-0 { transform: scale(1.04); animation: tome-bob 2.4s ease-in-out infinite; }
.tome-option.depth-1 { transform: scale(0.88) translateY(-8px); animation: tome-bob 2.9s ease-in-out 0.4s infinite; }
.tome-option.depth-2 { transform: scale(0.96); animation: tome-bob 2.6s ease-in-out 0.8s infinite; }

@keyframes tome-bob {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -10px; }
}

.tome-art {
  filter: drop-shadow(0 0 10px rgba(240, 184, 96, 0.45)) drop-shadow(0 14px 10px rgba(0, 0, 0, 0.5));
  line-height: 0;
}

.tome-art svg {
  width: clamp(40px, 10cqh, 70px);
  height: auto;
}

.tome-label {
  font-size: clamp(8px, 1.8vmin, 13px);
  color: var(--pink-soft);
  text-shadow: 2px 2px 0 var(--night-deep);
  background: rgba(21, 12, 40, 0.7);
  border: 2px solid var(--gold-dim);
  padding: 1vmin 1.6vmin;
}

.tome-option:hover .tome-art {
  filter: drop-shadow(0 0 18px rgba(255, 217, 138, 0.9)) drop-shadow(0 14px 10px rgba(0, 0, 0, 0.5));
}

.tome-option.wrong {
  animation: shake 0.4s ease;
  filter: saturate(0.3) brightness(0.6);
}

.tome-option.faded {
  opacity: 0.25;
  pointer-events: none;
}

.tome-option.chosen .tome-art {
  filter: drop-shadow(0 0 26px rgba(255, 217, 138, 1));
}

.tome-option.chosen {
  animation: match-bounce 0.5s ease;
}

/* ---------- Level 3: driving ---------- */

/* Steer hint pinned to the bottom edge of the road scene */
.steer-hint {
  position: absolute;
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(7px, 1.6vmin, 12px);
  color: var(--pink);
  text-shadow: 1px 1px 0 var(--night-deep);
  background: rgba(21, 12, 40, 0.65);
  padding: 0.8vmin 1.6vmin;
  z-index: 4;
  pointer-events: none;
  white-space: nowrap;
  max-width: 94%;
}

/* Success messages shown INSIDE a scene box (they'd fall below the
   fold on phone screens if stacked after the scene) */
.road-scene .success-line,
.beach-scene .success-line,
.villain-arena .success-line,
.sky-scene .success-line,
.valley-scene .success-line {
  position: absolute;
  top: 32%;
  left: 50%;
  transform: translateX(-50%);
  animation: toast-in 0.45s ease;
  background: rgba(21, 12, 40, 0.88);
  border: 2px solid var(--gold-dim);
  padding: 1.6vmin 2.6vmin;
  width: max-content;
  max-width: 86%;
  text-align: center;
  z-index: 6;
}

.drive-car {
  position: absolute;
  top: 78%;
  transform: translateX(-50%);
  z-index: 3;
  transition: left 0.22s cubic-bezier(0.3, 1.2, 0.5, 1);
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.6));
  pointer-events: none;
  line-height: 0;
}

.drive-car svg {
  width: clamp(52px, 13cqh, 90px);
  height: auto;
}

.drive-car.lean-left  { animation: car-lean-l 0.25s ease; }
.drive-car.lean-right { animation: car-lean-r 0.25s ease; }

@keyframes car-lean-l {
  50% { transform: translateX(-50%) rotate(-6deg); }
}
@keyframes car-lean-r {
  50% { transform: translateX(-50%) rotate(6deg); }
}

.road-charm {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  line-height: 0;
  filter: drop-shadow(0 0 8px rgba(255, 217, 138, 0.8));
}

.road-charm svg {
  width: clamp(26px, 6cqh, 44px);
  height: auto;
}

.road-charm.caught {
  animation: charm-found 0.5s ease forwards;
}

.road-charm.missed {
  animation: charm-miss 0.5s ease forwards;
}

@keyframes charm-miss {
  to { opacity: 0; transform: translateX(-50%) translateY(30px) scale(1.4); }
}

/* ---------- Level 4: the star bridge ---------- */

.sky-scene {
  position: relative;
  width: min(88cqw, 1100px);
  height: min(58cqh, 430px);
  border: var(--px) solid var(--purple-mid);
  outline: 2px solid var(--night-deep);
  overflow: hidden;
  background:
    radial-gradient(70% 60% at 50% 110%, rgba(78, 47, 116, 0.5) 0%, transparent 65%),
    linear-gradient(180deg, #0a0618 0%, #180f30 60%, #241540 100%);
}

.sky-dust {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #cfd8e8;
  animation: dust-twinkle 2.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes dust-twinkle {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.9; }
}

.const-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.const-lines line {
  stroke: var(--gold-bright);
  stroke-width: 0.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 2px rgba(255, 217, 138, 0.9));
  animation: line-in 0.5s ease;
}

@keyframes line-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.const-lines.complete line {
  animation: line-flare 1.1s ease;
}

@keyframes line-flare {
  0%, 100% { stroke-width: 0.5; }
  40% { stroke-width: 1.4; stroke: #fff7dd; }
}

.const-star {
  position: absolute;
  transform: translate(-50%, -50%) scale(0.8);
  background: none;
  border: none;
  cursor: pointer;
  padding: 1vmin;
  line-height: 0;
  filter: grayscale(0.6) brightness(0.55);
  transition: filter 0.3s ease, transform 0.3s ease;
  z-index: 2;
}

.const-star svg {
  width: clamp(20px, 4.6cqh, 34px);
  height: auto;
}

.const-star.beckon {
  filter: grayscale(0) brightness(1.1) drop-shadow(0 0 10px rgba(255, 217, 138, 0.9));
  animation: star-beckon 1s ease-in-out infinite;
}

@keyframes star-beckon {
  0%, 100% { transform: translate(-50%, -50%) scale(0.9); }
  50% { transform: translate(-50%, -50%) scale(1.15); }
}

.const-star.lit {
  filter: grayscale(0) brightness(1.2) drop-shadow(0 0 14px rgba(255, 217, 138, 1));
  transform: translate(-50%, -50%) scale(1);
  cursor: default;
}

.const-star.nope {
  animation: shake 0.35s ease;
}

/* ---------- Level 7: the lantern lift ---------- */

.valley-scene {
  position: relative;
  width: min(88cqw, 1100px);
  height: min(58cqh, 430px);
  border: var(--px) solid var(--purple-mid);
  outline: 2px solid var(--night-deep);
  overflow: hidden;
  background:
    radial-gradient(80% 50% at 50% 115%, rgba(60, 30, 78, 0.8) 0%, transparent 70%),
    linear-gradient(180deg, #0a0618 0%, #1c1236 55%, #2c1a4a 100%);
}

.valley-warmth {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 60% at 50% 80%, rgba(240, 184, 96, 0.28) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}

.valley-lantern {
  position: absolute;
  background: none;
  border: none;
  cursor: pointer;
  padding: 1vmin;
  line-height: 0;
  filter: grayscale(0.75) brightness(0.5);
  transition: filter 0.5s ease;
  z-index: 2;
}

.valley-lantern svg {
  width: clamp(26px, 6.5cqh, 46px);
  height: auto;
}

.valley-lantern.lit {
  filter: grayscale(0) brightness(1.15) drop-shadow(0 0 16px rgba(255, 217, 138, 0.95));
  cursor: default;
}

/* ---------- Keepsake reward ---------- */

.keepsake-charm {
  line-height: 0;
  filter: drop-shadow(0 0 22px rgba(255, 217, 138, 0.8));
  animation: tome-bob 2.6s ease-in-out infinite;
}

.keepsake-charm svg {
  width: clamp(60px, 16cqh, 110px);
  height: auto;
}

/* ---------- Misc sprite fixes ---------- */

.nyeh-text {
  font-family: var(--font-pixel);
  font-size: clamp(9px, 2vmin, 14px);
  color: var(--pink);
  text-shadow: 2px 2px 0 var(--night-deep);
}

.goblin svg {
  width: clamp(56px, 14cqh, 100px);
  height: auto;
}
