* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: linear-gradient(180deg, #cfe8ff 0%, #ffe6c4 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Avenir Next", "Avenir", sans-serif;
  color: #2d2438;
}
canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ============ HUD ============ */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
.hud.hidden { display: none; }
.hud-score {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 12px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(45, 36, 56, 0.18);
  font-weight: 800;
  font-size: 26px;
  color: #2d2438;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}
.hud-stage {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: rgba(45, 36, 56, 0.85);
  color: white;
  border-radius: 999px;
  font-weight: 800;
  font-size: 18px;
  margin-top: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.hud-meter {
  position: absolute;
  top: calc(env(safe-area-inset-top, 12px) + 76px);
  right: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(45, 36, 56, 0.18);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}
.hud-meter-label { font-weight: 700; font-size: 14px; color: #5a4a6e; }
.hud-meter-bar {
  width: 140px;
  height: 14px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}
.hud-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #6ab0e8 0%, #a78bfa 100%);
  width: 0%;
  transition: width 0.18s ease;
}
.mute-btn {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  right: 12px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  border: none;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(45, 36, 56, 0.18);
  cursor: pointer;
  pointer-events: auto;
  margin-top: 12px;
  z-index: 60;
  font-family: inherit;
}
.mute-btn:active { transform: scale(0.95); }

/* ============ POP BANNERS ============ */
.wave-banner, .grew-banner, .district-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  padding: 14px 30px;
  border-radius: 24px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  z-index: 11;
  transform: translate(-50%, -50%) scale(0.5);
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.wave-banner {
  background: linear-gradient(135deg, #ffd76b, #f29849);
  color: white;
  font-size: 30px;
  text-shadow: 2px 2px 0 rgba(45, 36, 56, 0.3);
}
.district-banner {
  background: linear-gradient(135deg, #a78bfa, #6d5fd6);
  color: white;
  font-size: 28px;
  text-shadow: 2px 2px 0 rgba(45, 36, 56, 0.3);
  top: 30%;
}
.grew-banner {
  background: white;
  color: #2d2438;
  font-size: 30px;
  top: 38%;
}
.wave-banner.show, .grew-banner.show, .district-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ============ OVERLAY SCREENS ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 70px 20px 24px;
  text-align: center;
  background: linear-gradient(180deg, #cfe8ff 0%, #ffe6c4 100%);
  overflow-y: auto;
}
.overlay.hidden { display: none; }
.overlay h1 {
  font-size: clamp(32px, 5.5vw, 48px);
  font-weight: 900;
  margin: 4px 0 12px;
  color: #2d2438;
  text-shadow: 3px 3px 0 white, 6px 6px 0 rgba(45, 36, 56, 0.12);
}
.overlay .sub {
  font-size: clamp(15px, 2.2vw, 20px);
  font-weight: 600;
  color: #5a4a6e;
  margin: 0 0 22px;
  max-width: 540px;
  line-height: 1.4;
}

.player-banner {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 50%;
  transform: translateX(-50%);
  margin-top: 12px;
  background: white;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 16px;
  color: #5a4a6e;
  box-shadow: 0 4px 12px rgba(45, 36, 56, 0.1);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ DRAGON PICKER (now with 5 dragons) ============ */
.dragon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  max-width: 620px;
  margin-bottom: 18px;
  justify-content: center;
}
.dragon-card {
  flex: 0 1 calc(50% - 6px);
  background: white;
  border: 4px solid transparent;
  border-radius: 22px;
  padding: 12px 8px 14px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(45, 36, 56, 0.12);
  transition: transform 0.12s ease, border-color 0.12s ease;
  position: relative;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: inherit;
  color: #2d2438;
}
@media (min-width: 560px) {
  .dragon-card {
    flex: 0 1 calc(33.333% - 8px);
    min-height: 200px;
  }
}
.dragon-card:active:not(.locked) { transform: scale(0.96); }
.dragon-card.favorite { border-color: #ffd76b; }
.dragon-card .name { font-weight: 800; font-size: 20px; margin-top: 4px; }
.dragon-card .tag  { font-size: 13px; color: #5a4a6e; font-weight: 600; line-height: 1.3; padding: 0 4px; }
.dragon-card svg { width: 96px; height: 80px; }
.dragon-card.locked {
  background: #efeaf2;
  cursor: not-allowed;
}
.dragon-card.locked .name { color: #9da0a8; }
.dragon-card.locked .tag  { color: #b0b3bc; }
.dragon-card.locked svg { opacity: 0.35; filter: grayscale(1); }
.lock-overlay {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 26px;
}
.new-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #ef6b6b;
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  box-shadow: 0 4px 10px rgba(239, 107, 107, 0.5);
  animation: sparkle 1.4s ease-in-out infinite;
}
@keyframes sparkle {
  0%, 100% { transform: scale(1) rotate(-4deg); }
  50%      { transform: scale(1.15) rotate(4deg); }
}

/* ============ CONTROL PICKER ============ */
.mode-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  width: 100%;
  max-width: 520px;
}
@media (min-width: 600px) {
  .mode-buttons { grid-template-columns: 1fr 1fr; }
}
.mode-btn {
  font-family: inherit;
  font-size: 24px;
  font-weight: 800;
  padding: 28px 16px;
  border: 4px solid transparent;
  border-radius: 24px;
  cursor: pointer;
  background: white;
  color: #2d2438;
  box-shadow: 0 6px 16px rgba(45, 36, 56, 0.12);
  transition: transform 0.12s ease, border-color 0.12s ease;
  min-height: 160px;
}
.mode-btn:active { transform: scale(0.96); }
.mode-btn.favorite { border-color: #ffd76b; }
.mode-btn .emoji { display: block; font-size: 44px; margin-bottom: 6px; }
.mode-btn .tag   { display: block; font-weight: 600; color: #5a4a6e; font-size: 16px; margin-top: 6px; }

/* ============ BUTTONS ============ */
.big-btn {
  font-family: inherit;
  background: linear-gradient(135deg, #ffd76b, #f29849);
  color: white;
  border: none;
  font-size: 22px;
  font-weight: 800;
  padding: 18px 30px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(242, 152, 73, 0.4);
  transition: transform 0.12s ease;
  min-height: 64px;
}
.big-btn:active { transform: scale(0.96); }
.secondary-btn {
  font-family: inherit;
  background: white;
  color: #2d2438;
  border: 3px solid #2d2438;
  font-size: 18px;
  font-weight: 800;
  padding: 14px 22px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  min-height: 56px;
}
.secondary-btn:active { transform: scale(0.96); }
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 6px;
}

/* ============ NAP SCREEN ============ */
.nap-card {
  background: white;
  border-radius: 28px;
  padding: 28px 24px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop-in {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.nap-card h2 {
  font-size: 36px;
  margin: 8px 0 12px;
  color: #2d2438;
}
.nap-card .score {
  font-size: 24px;
  font-weight: 700;
  color: #2d2438;
  margin: 8px 0;
}
.nap-card .new-high {
  display: inline-block;
  background: linear-gradient(135deg, #ffd76b, #f29849);
  color: white;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 18px;
  margin: 8px 0;
  animation: sparkle 1.4s ease-in-out infinite;
}
.nap-card .best {
  font-size: 18px;
  color: #5a4a6e;
  font-weight: 700;
  margin: 8px 0;
}
.nap-card .stage-row {
  font-size: 20px;
  color: #2d2438;
  font-weight: 700;
  margin: 14px 0 22px;
}

/* ============================================================
   CASTLE BUTTON (on dragon picker)
   The doorway-to-somewhere-special button. Made prominent with a
   warm cream-to-gold gradient and a chunky soft shadow so it reads
   as an inviting destination, distinct from the dragon cards above.
   ============================================================ */
.castle-btn {
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  max-width: 620px;
  min-height: 96px;
  margin: 8px 0 20px;
  padding: 22px 30px;
  border: 4px solid #f0c468;
  border-radius: 26px;
  background: linear-gradient(180deg, #fff8e8 0%, #fde2b6 100%);
  color: #2d2438;
  font-size: 28px;
  font-weight: 800;
  cursor: pointer;
  box-shadow:
    0 12px 28px rgba(200, 140, 40, 0.30),
    inset 0 2px 0 rgba(255, 255, 255, 0.85),
    inset 0 -3px 0 rgba(180, 120, 40, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.castle-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #fffbf0 0%, #fde8c4 100%);
  box-shadow:
    0 16px 34px rgba(200, 140, 40, 0.36),
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    inset 0 -3px 0 rgba(180, 120, 40, 0.15);
}
.castle-btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow:
    0 5px 12px rgba(200, 140, 40, 0.26),
    inset 0 2px 0 rgba(255, 255, 255, 0.85);
}
.castle-btn-icon {
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(160, 100, 30, 0.35));
}
.castle-btn-label {
  font-size: 28px;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* ============================================================
   CASTLE BEDROOM — peaceful scene with the player's dragon
   No HUD, no game UI. Pure CSS + inline SVG.
   ============================================================ */
.castle-overlay {
  /* override the gradient sky background of normal overlays */
  background: #f7f4ec;
  padding: 0;
  display: block;
  overflow: hidden;
}
.castle-room {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #fbf8f1; /* warm cream — the room "ambient light" */
}

/* ----- Back wall ----- */
.castle-wall {
  position: absolute;
  inset: 0 0 38% 0;
  background:
    linear-gradient(180deg, #f4ece0 0%, #ffffff 30%, #fbf8f1 100%);
  overflow: hidden;
}
.castle-stones {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  background-image:
    /* horizontal seams */
    linear-gradient(180deg, transparent 0, transparent 47px, #e3dcd1 47px, #e3dcd1 49px, transparent 49px),
    /* vertical seams, offset every other row by 40px via two layers */
    linear-gradient(90deg, transparent 0, transparent 80px, #e3dcd1 80px, #e3dcd1 82px, transparent 82px);
  background-size: 80px 96px, 80px 96px;
  background-position: 0 0, 0 0;
}
.castle-stones::after {
  /* second pattern offset to break the grid into proper stone bond */
  content: '';
  position: absolute;
  inset: 49px 0 0 0;
  background-image:
    linear-gradient(90deg, transparent 0, transparent 40px, #e3dcd1 40px, #e3dcd1 42px, transparent 42px);
  background-size: 80px 96px;
  background-position: 0 0;
  opacity: 0.85;
}

/* ----- Window ----- */
.castle-window {
  position: absolute;
  top: 8%;
  left: 22%;
  width: 24%;
  min-width: 200px;
  height: 55%;
  max-height: 280px;
}
.window-frame {
  position: absolute;
  inset: 0 0 14px 0;
  border: 12px solid #cdbfa9;
  border-radius: 14px 14px 8px 8px;
  background: linear-gradient(180deg, #b9dcf0 0%, #d8ecf6 70%, #e8f1d9 100%);
  overflow: hidden;
  box-shadow: inset 0 0 0 3px #f4ece0,
              0 4px 12px rgba(0, 0, 0, 0.08);
}
.window-sky {
  position: absolute;
  inset: 0 0 25% 0;
  overflow: hidden;
}
.cloud {
  position: absolute;
  width: 70px;
  height: 24px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  box-shadow:
    18px -8px 0 -4px rgba(255, 255, 255, 0.9),
    -16px -6px 0 -6px rgba(255, 255, 255, 0.9);
  animation: cloudDrift 30s linear infinite;
}
.cloud-1 { top: 24%;  left: -25%; animation-delay:   0s; }
.cloud-2 { top: 52%;  left: -25%; animation-delay: -10s; }
.cloud-3 { top: 12%;  left: -25%; animation-delay: -20s; }
@keyframes cloudDrift {
  from { transform: translateX(0);     }
  to   { transform: translateX(420px); }
}
.window-rooftops {
  position: absolute;
  inset: auto 0 0 0;
  height: 28%;
  background: linear-gradient(180deg, #a8c878 0%, #88a858 100%);
}
.rooftop {
  position: absolute;
  bottom: 50%;
  width: 0; height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
}
.rooftop.r1 { left: 6%;  border-bottom: 18px solid #c46b5a; }
.rooftop.r2 { left: 22%; border-bottom: 22px solid #c49a4a; }
.rooftop.r3 { left: 40%; border-bottom: 16px solid #5d83b0; }
.rooftop.r4 { left: 60%; border-bottom: 20px solid #a07090; }
.rooftop.r5 { left: 80%; border-bottom: 18px solid #c46b5a; }
.window-mullion-v {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 6px;
  margin-left: -3px;
  background: #cdbfa9;
}
.window-mullion-h {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 6px;
  margin-top: -3px;
  background: #cdbfa9;
}
.window-sill {
  position: absolute;
  left: -8px;
  right: -8px;
  bottom: 0;
  height: 14px;
  background: linear-gradient(180deg, #c6b394 0%, #ac9876 100%);
  border-radius: 4px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
}

/* ----- Framed picture ----- */
.castle-picture {
  position: absolute;
  top: 12%;
  right: 14%;
  width: 110px;
  height: 90px;
  background: #8b6f4a;
  padding: 6px;
  border-radius: 4px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18),
              inset 0 0 0 2px #6a5232;
}
.picture-mat {
  position: relative;
  width: 100%;
  height: 100%;
  background: #fff8e8;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.picture-sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #cfe8ff 0%, #ffe6c4 100%);
}
.picture-dragon {
  position: relative;
  width: 80%;
  height: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.picture-dragon svg { width: 100%; height: 100%; }

/* ----- Wood floor ----- */
.castle-floor {
  position: absolute;
  inset: 62% 0 0 0;
  background:
    /* gentle ambient light from candle side */
    radial-gradient(ellipse 60% 80% at 80% 0%, rgba(255, 220, 130, 0.18), transparent 65%),
    /* plank seams */
    repeating-linear-gradient(180deg,
      #cc9966 0,
      #cc9966 44px,
      #a87a4f 44px,
      #a87a4f 46px,
      #cc9966 46px,
      #cc9966 90px,
      #a87a4f 90px,
      #a87a4f 92px),
    /* base color */
    #cc9966;
  /* gentle wood grain via overlay */
  box-shadow: inset 0 4px 12px rgba(80, 50, 20, 0.18);
}
.castle-floor::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(90deg,
      transparent 0,
      transparent 160px,
      rgba(80, 50, 20, 0.25) 160px,
      rgba(80, 50, 20, 0.25) 162px,
      transparent 162px,
      transparent 320px,
      rgba(80, 50, 20, 0.25) 320px,
      rgba(80, 50, 20, 0.25) 322px);
  /* shift the cross-seams on every other plank for a real plank look */
  background-position: 0 22px;
  background-size: 320px 90px;
}

/* ----- Door (back to picker) ----- */
.castle-door {
  position: absolute;
  left: 3%;
  bottom: 6%;
  width: 130px;
  height: 220px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  z-index: 4;
}
.castle-door:active { transform: scale(0.97); }
.door-arch {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #c1b39b 0%, #b09f85 100%);
  border-radius: 65px 65px 0 0;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18),
              inset 0 4px 0 rgba(255, 255, 255, 0.35);
  padding: 10px;
}
.door-wood {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #7a4a2a 0%, #5a3a22 100%);
  border-radius: 55px 55px 0 0;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px #3a2412;
}
.door-plank {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(0, 0, 0, 0.3);
}
.door-plank:nth-child(1) { left: 25%; }
.door-plank:nth-child(2) { left: 50%; }
.door-plank:nth-child(3) { left: 75%; }
.door-hinge {
  position: absolute;
  left: 6px;
  width: 14px;
  height: 18px;
  background: #4a4a4a;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px #2a2a2a;
}
.door-hinge.top { top: 18px; }
.door-hinge.bot { bottom: 18px; }
.door-handle {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -4px;
  background: #f4d250;
  border-radius: 50%;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.door-sign {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff8e8;
  border: 2px solid #8b6f4a;
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 18px;
  font-weight: 800;
  color: #2d2438;
  white-space: nowrap;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

/* ----- Rug ----- */
.castle-rug {
  position: absolute;
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  max-width: 540px;
  height: 60px;
  background: var(--rug-color, #ef6b6b);
  border: 6px solid var(--rug-trim, #c0392b);
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  z-index: 2;
}
.castle-rug::before, .castle-rug::after {
  content: '';
  position: absolute;
  top: -10px;
  bottom: -10px;
  width: 8px;
  background: repeating-linear-gradient(90deg,
    var(--rug-trim, #c0392b) 0,
    var(--rug-trim, #c0392b) 2px,
    transparent 2px,
    transparent 5px);
}
.castle-rug::before { left: -18px; }
.castle-rug::after  { right: -18px; }

/* ----- Bed ----- */
.castle-bed {
  position: absolute;
  bottom: 9%;
  left: 50%;
  transform: translateX(-50%);
  width: 460px;
  max-width: 70%;
  height: 130px;
  z-index: 3;
}
.bed-frame-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60%;
  background: linear-gradient(180deg, #a06a3a 0%, #7a4a2a 100%);
  border-radius: 14px 14px 6px 6px;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.15);
}
.bed-frame-front {
  position: absolute;
  bottom: 0;
  left: -4px;
  right: -4px;
  height: 32%;
  background: linear-gradient(180deg, #8a5a2a 0%, #5a3a22 100%);
  border-radius: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
}
.bed-mattress {
  position: absolute;
  top: 14%;
  left: 4%;
  right: 4%;
  height: 50%;
  background: linear-gradient(180deg, #fdfbf5 0%, #f0e9d8 100%);
  border-radius: 10px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
}
.bed-pillow {
  position: absolute;
  top: 18%;
  left: 8%;
  width: 22%;
  height: 36%;
  background: linear-gradient(180deg, #ffffff 0%, #f0e9d8 100%);
  border-radius: 16px 14px 12px 14px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}
.bed-blanket {
  position: absolute;
  bottom: 18%;
  right: 6%;
  width: 38%;
  height: 38%;
  background: var(--blanket-color, #ef6b6b);
  border-radius: 6px 10px 4px 4px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18),
              inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.bed-blanket::before {
  /* folded edge */
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  height: 12px;
  background: var(--blanket-color, #ef6b6b);
  border-radius: 4px;
  filter: brightness(1.18);
}

/* ----- Bedside table + candle ----- */
.bedside-table {
  position: absolute;
  bottom: 8%;
  right: 12%;
  width: 90px;
  height: 130px;
  z-index: 3;
}
.table-top {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  height: 14px;
  background: linear-gradient(180deg, #8a5a2a 0%, #6a4220 100%);
  border-radius: 4px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}
.table-leg {
  position: absolute;
  top: 74px;
  bottom: 0;
  width: 8px;
  background: linear-gradient(180deg, #7a4a22 0%, #5a3214 100%);
  border-radius: 0 0 3px 3px;
}
.table-leg.left  { left: 8px;  }
.table-leg.right { right: 8px; }
.candle {
  position: absolute;
  top: 14px;
  left: 50%;
  width: 24px;
  height: 48px;
  margin-left: -12px;
}
.candle-base {
  position: absolute;
  bottom: 0;
  left: 4px;
  right: 4px;
  height: 30px;
  background: linear-gradient(180deg, #fff8e8 0%, #e8d8b8 100%);
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
}
.candle-base::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 50%;
  width: 2px;
  height: 6px;
  margin-left: -1px;
  background: #2d2438;
}
.candle-flame {
  position: absolute;
  bottom: 32px;
  left: 50%;
  width: 12px;
  height: 18px;
  margin-left: -6px;
  background: radial-gradient(ellipse at 50% 70%, #fff5d0 0%, #ffd76b 40%, #f29849 80%);
  border-radius: 50% 50% 50% 50% / 70% 70% 50% 50%;
  transform-origin: 50% 100%;
  animation: candleFlicker 0.35s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(255, 200, 100, 0.5);
}
.candle-glow {
  position: absolute;
  bottom: 24px;
  left: 50%;
  width: 90px;
  height: 90px;
  margin-left: -45px;
  background: radial-gradient(circle, rgba(255, 200, 100, 0.35) 0%, transparent 65%);
  pointer-events: none;
  animation: glowPulse 1.8s ease-in-out infinite;
}
@keyframes candleFlicker {
  0%, 100% { transform: scale(1, 1)     translateX(0);   }
  25%      { transform: scale(1.08, 0.96) translateX(0.4px); }
  50%      { transform: scale(0.96, 1.04) translateX(-0.4px); }
  75%      { transform: scale(1.04, 0.98) translateX(0.2px); }
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}
.sparkle {
  position: absolute;
  bottom: 56px;
  left: 50%;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  background: #ffd76b;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 215, 107, 0.9);
  opacity: 0;
  animation: sparkleDrift 4s ease-out infinite;
}
.sparkle-1 { animation-delay: 0s;    }
.sparkle-2 { animation-delay: 1.3s;  }
.sparkle-3 { animation-delay: 2.6s;  }
@keyframes sparkleDrift {
  0%   { opacity: 0; transform: translate(0, 0)     scale(0.6); }
  15%  { opacity: 0.9; }
  100% { opacity: 0; transform: translate(8px, -90px) scale(0.4); }
}

/* ----- Chest at foot of bed ----- */
.castle-chest {
  position: absolute;
  bottom: 6%;
  left: 32%;
  width: 110px;
  height: 70px;
  z-index: 3;
}
.chest-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(180deg, #8a5a2a 0%, #5a3a22 100%);
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2),
              inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.chest-lid {
  position: absolute;
  bottom: 60%;
  left: -4px;
  right: -4px;
  height: 36%;
  background: linear-gradient(180deg, #a06a3a 0%, #7a4a2a 100%);
  border-radius: 14px 14px 3px 3px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.18);
}
.chest-clasp {
  position: absolute;
  bottom: 45%;
  left: 50%;
  width: 16px;
  height: 18px;
  margin-left: -8px;
  background: linear-gradient(180deg, #f4d250 0%, #c69a26 100%);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.chest-clasp::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  background: #2d2438;
  border-radius: 50%;
}
.chest-band {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: #4a3018;
}
.chest-band.band-1 { bottom: 12%; }
.chest-band.band-2 { bottom: 38%; }

/* ----- The dragon, sitting on the bed ----- */
.castle-dragon {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  max-width: 56%;
  height: 220px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.castle-dragon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Subtle breathing — applied to the body group inside the resting SVG */
.dragon-breathe {
  transform-origin: 50% 70%;
  animation: dragonBreathe 3.2s ease-in-out infinite;
}
@keyframes dragonBreathe {
  0%, 100% { transform: scale(1);      }
  50%      { transform: scale(1.015);  }
}

/* Tail swish — very gentle */
.dragon-tail {
  transform-origin: 75% 50%;
  animation: dragonTailSwish 5.5s ease-in-out infinite;
}
@keyframes dragonTailSwish {
  0%, 100% { transform: rotate(-1.5deg); }
  50%      { transform: rotate(2deg);    }
}

/* Blink — toggled via .blink class for ~150 ms */
.dragon-eye-lid {
  transform-origin: center;
  transform: scaleY(0);
  transition: transform 90ms ease-in-out;
}
.dragon-eye.blink .dragon-eye-lid {
  transform: scaleY(1);
}

/* Yawn — toggled via .yawn class on the mouth group */
.dragon-mouth-closed { opacity: 1; }
.dragon-mouth-open   { opacity: 0; }
.dragon-mouth.yawn .dragon-mouth-closed { opacity: 0; }
.dragon-mouth.yawn .dragon-mouth-open   { opacity: 1; }

/* Tiny "z" that puffs when yawning */
.dragon-zzz {
  opacity: 0;
  transform: translate(0, 0) scale(0.4);
  transition: opacity 0.4s ease, transform 1.4s ease-out;
}
.dragon-zzz.show {
  opacity: 0.85;
  transform: translate(20px, -28px) scale(1);
}

/* ----- Entry/exit fade (shared across all castle rooms) ----- */
.castle-fade {
  position: fixed;
  inset: 0;
  background: #ffffff;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.30s ease;
  z-index: 90;
}
.castle-fade.show { opacity: 1; }

/* ============================================================
   CASTLE — MULTIPLE ROOMS (Round 3a)
   The bedroom now connects to a hallway, which leads to the
   weight room. Each room is its own overlay with a shared dragon
   container styled via .castle-dragon and an inner .dragon-facing
   wrapper that flips the dragon when walking left.
   ============================================================ */

/* Each .castle-dragon has an inner facing wrapper so we can flip
   horizontally without disturbing position. */
.castle-dragon .dragon-facing {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
}
.castle-dragon .dragon-facing.face-left {
  transform: scaleX(-1);
}

/* Smooth left/right slide for room walking. */
.castle-dragon.sliding {
  transition: left 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}
/* Gentle vertical bob while walking. */
.castle-dragon.walking .dragon-facing {
  animation: dragonWalkBob 0.36s ease-in-out infinite;
}
.castle-dragon.walking.face-left .dragon-facing,
.castle-dragon.walking .dragon-facing.face-left {
  animation: dragonWalkBobLeft 0.36s ease-in-out infinite;
}
@keyframes dragonWalkBob {
  0%, 100% { transform: translateY(0)    scaleX(1); }
  50%      { transform: translateY(-6px) scaleX(1); }
}
@keyframes dragonWalkBobLeft {
  0%, 100% { transform: translateY(0)    scaleX(-1); }
  50%      { transform: translateY(-6px) scaleX(-1); }
}

/* ----- Right-wall door variant (for bedroom + hallway) ----- */
.castle-door.door-right {
  left: auto;
  right: 3%;
}
/* Hinges flipped to the right side for right-wall doors */
.door-hinge.right { left: auto; right: 6px; }
.door-handle.left { right: auto; left: 14px; }

/* Center-wall (placeholder) door for the hallway */
.castle-door.door-center {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  cursor: default;
  opacity: 0.78;
}
.castle-door.door-center .door-wood {
  background: linear-gradient(180deg, #6a4a2e 0%, #4a2e1a 100%);
}
.door-locked .door-sign.sign-locked {
  background: #efeaf2;
  border-color: #6a5a78;
  color: #6a5a78;
}
.door-lock {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -12px;
  margin-top: -12px;
  font-size: 24px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* ============================================================
   HALLWAY
   ============================================================ */
.castle-room-hall {
  background: #f7f2e7;
}
.castle-wall-hall {
  inset: 0 0 38% 0;
  background: linear-gradient(180deg, #f4ece0 0%, #ffffff 28%, #faf4e8 100%);
}
.hall-window {
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: 22%;
  min-width: 180px;
}
.hall-rug {
  position: absolute;
  bottom: 0;
  left: 14%;
  right: 14%;
  height: 38%;
  background:
    repeating-linear-gradient(90deg,
      #b94d4d 0,
      #b94d4d 24px,
      #d65b5b 24px,
      #d65b5b 48px),
    #c25555;
  border-top: 6px solid #7c1d16;
  border-bottom: 6px solid #7c1d16;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.18);
  z-index: 1;
}

/* Wall torches */
.wall-torch {
  position: absolute;
  width: 36px;
  height: 80px;
}
.torch-left  { top: 28%; left: 12%; }
.torch-right { top: 28%; right: 12%; }
.torch-gym   { top: 22%; right: 22%; }
.torch-bracket {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 22px;
  height: 8px;
  margin-left: -11px;
  background: #4a3a22;
  border-radius: 2px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}
.torch-stick {
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 8px;
  height: 36px;
  margin-left: -4px;
  background: linear-gradient(180deg, #6a4a30 0%, #4a3018 100%);
  border-radius: 3px;
}
.torch-flame {
  position: absolute;
  bottom: 36px;
  left: 50%;
  width: 18px;
  height: 28px;
  margin-left: -9px;
  background: radial-gradient(ellipse at 50% 70%, #fff5d0 0%, #ffd76b 40%, #f29849 80%, transparent 95%);
  border-radius: 50% 50% 50% 50% / 70% 70% 50% 50%;
  transform-origin: 50% 100%;
  animation: torchFlicker 0.32s ease-in-out infinite;
  box-shadow: 0 0 16px rgba(255, 180, 80, 0.55);
}
.torch-glow {
  position: absolute;
  bottom: 24px;
  left: 50%;
  width: 110px;
  height: 110px;
  margin-left: -55px;
  background: radial-gradient(circle, rgba(255, 200, 100, 0.32) 0%, transparent 65%);
  pointer-events: none;
  animation: torchGlow 1.6s ease-in-out infinite;
}
@keyframes torchFlicker {
  0%, 100% { transform: scale(1, 1)       translateX(0); }
  25%      { transform: scale(1.1, 0.95)  translateX(0.6px); }
  50%      { transform: scale(0.92, 1.06) translateX(-0.6px); }
  75%      { transform: scale(1.06, 0.96) translateX(0.4px); }
}
@keyframes torchGlow {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

.hall-dragon {
  bottom: 8%;
}

/* ============================================================
   WEIGHT ROOM
   ============================================================ */
.castle-room-gym {
  background: #f0eadf;
}
.castle-wall-gym {
  inset: 0 0 38% 0;
  background: linear-gradient(180deg, #ece4d4 0%, #f8f1e2 30%, #f0e8d4 100%);
}
.castle-wall-gym .castle-stones {
  opacity: 0.75; /* slightly more visible stones */
}
.castle-floor-stone {
  background:
    radial-gradient(ellipse 80% 100% at 50% 0%, rgba(255, 220, 130, 0.16), transparent 70%),
    repeating-linear-gradient(180deg,
      #b8a890 0,
      #b8a890 60px,
      #9a8a72 60px,
      #9a8a72 62px,
      #b8a890 62px,
      #b8a890 120px,
      #9a8a72 120px,
      #9a8a72 122px),
    #b8a890;
  box-shadow: inset 0 4px 12px rgba(60, 40, 20, 0.18);
}
.castle-floor-stone::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(90deg,
      transparent 0,
      transparent 120px,
      rgba(60, 40, 20, 0.18) 120px,
      rgba(60, 40, 20, 0.18) 122px,
      transparent 122px,
      transparent 240px,
      rgba(60, 40, 20, 0.18) 240px,
      rgba(60, 40, 20, 0.18) 242px);
  background-position: 0 30px;
  background-size: 240px 120px;
}

/* Motivational sign on the wall */
.gym-sign {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  background: #fff8e8;
  border: 4px solid #8b6f4a;
  border-radius: 12px;
  padding: 10px 22px;
  font-size: 22px;
  font-weight: 900;
  color: #6a4a2a;
  letter-spacing: 1px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.18);
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

/* Weight rack against the back wall */
.weight-rack {
  position: absolute;
  top: 22%;
  left: 6%;
  width: 220px;
  height: 130px;
}
.rack-post {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  background: linear-gradient(180deg, #4a4a4a 0%, #2a2a2a 100%);
  border-radius: 3px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.25);
}
.rack-post.left  { left: 0; }
.rack-post.right { right: 0; }
.rack-rail {
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  background: #3a3a3a;
}
.rack-rail.top { top: 30%; }
.rack-rail.bot { top: 70%; }
.rack-barbell {
  position: absolute;
  left: 14px;
  right: 14px;
  height: 8px;
  background: linear-gradient(180deg, #aaaaaa 0%, #6a6a6a 100%);
  border-radius: 4px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}
.rack-barbell::before, .rack-barbell::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 18px;
  height: 22px;
  margin-top: -11px;
  background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 100%);
  border-radius: 4px;
}
.rack-barbell::before { left: -4px; }
.rack-barbell::after  { right: -4px; }
.rack-barbell.b1 { top: 18%; }
.rack-barbell.b2 { top: 50%; }
.rack-barbell.b3 { top: 82%; transform: scaleX(0.7); transform-origin: 50% 50%; }

/* Wall mirror */
.gym-mirror {
  position: absolute;
  bottom: 8%;
  right: 4%;
  width: 110px;
  height: 240px;
  z-index: 2;
}
.mirror-frame {
  width: 100%;
  height: 100%;
  padding: 8px;
  background: linear-gradient(180deg, #a06a3a 0%, #5a3a22 100%);
  border-radius: 50% / 14%;
  box-shadow: 0 8px 18px rgba(0,0,0,0.22),
              inset 0 2px 0 rgba(255,255,255,0.25);
}
.mirror-glass {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(180deg, #d8e6f0 0%, #b8d0e0 70%, #c8d8e8 100%);
  border-radius: 50% / 14%;
  overflow: hidden;
}
.mirror-shimmer {
  position: absolute;
  top: 0; bottom: 0;
  left: -20%;
  width: 30%;
  background: linear-gradient(110deg, transparent 0%, rgba(255,255,255,0.55) 50%, transparent 100%);
  animation: mirrorShimmer 4.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes mirrorShimmer {
  0%   { left: -30%; }
  60%  { left: 100%; }
  100% { left: 100%; }
}
.mirror-dragon {
  position: absolute;
  inset: 4%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scaleX(-1);
  opacity: 0.92;
}
.mirror-dragon svg { width: 100%; height: 100%; overflow: visible; }

/* Strength plaque */
.strength-plaque {
  position: absolute;
  bottom: 9%;
  right: 17%;
  background: #fff8e8;
  border: 3px solid #8b6f4a;
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 130px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.18);
  z-index: 2;
}
.plaque-name { font-size: 18px; font-weight: 900; color: #2d2438; }
.plaque-reps { font-size: 16px; font-weight: 700; color: #5a4a6e; margin-top: 4px; }
.plaque-tier { font-size: 14px; font-weight: 800; color: #b07b50; margin-top: 2px; }

/* Water bowl */
.water-bowl {
  position: absolute;
  bottom: 4%;
  left: 22%;
  width: 70px;
  height: 32px;
  z-index: 2;
}
.bowl-body {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #6a6a6a 0%, #3a3a3a 100%);
  border-radius: 50%;
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.2);
}
.bowl-water {
  position: absolute;
  top: 6px;
  left: 8px;
  right: 8px;
  height: 12px;
  background: linear-gradient(180deg, #7fc9d9 0%, #4a96b8 100%);
  border-radius: 50%;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.45);
}

/* Central barbell (interactive — starts rhythm game) */
.central-barbell {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 56px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  z-index: 3;
  font-family: inherit;
}
.central-barbell:active { transform: translateX(-50%) scale(0.97); }
.central-barbell:hover .lift-prompt {
  transform: translateX(-50%) translateY(-4px);
  background: #ffd76b;
}
.barbell-bar {
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 10px;
  margin-top: -5px;
  background: linear-gradient(180deg, #cfcfcf 0%, #7a7a7a 100%);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.barbell-plate {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 56px;
  margin-top: -28px;
  background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 100%);
  border-radius: 6px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.35);
}
.barbell-plate.left  { left: 0; }
.barbell-plate.right { right: 0; }
.barbell-collar {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 22px;
  margin-top: -11px;
  background: #888;
  border-radius: 3px;
}
.barbell-collar.left  { left: 32px; }
.barbell-collar.right { right: 32px; }

.lift-prompt {
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-bottom: 12px;
  transform: translateX(-50%);
  background: #ffd76b;
  color: #2d2438;
  font-size: 16px;
  font-weight: 900;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(200, 140, 40, 0.4);
  white-space: nowrap;
  animation: liftPromptPulse 1.5s ease-in-out infinite;
  transition: transform 0.15s ease, background 0.15s ease;
}
@keyframes liftPromptPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%      { transform: translateX(-50%) scale(1.07); }
}

.gym-dragon {
  bottom: 6%;
  left: 26%;
  transform: translateX(-50%);
  width: 220px;
  max-width: 38%;
  z-index: 2;
}

/* ============================================================
   RHYTHM MINI-GAME
   ============================================================ */
.rhythm-overlay {
  background: #ece4d4;
  padding: 0;
  display: block;
  overflow: hidden;
}
.rhythm-room {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.rhythm-hud {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* extra right padding so the reps pill clears the mute button (52 + 12 = 64 + breathing room) */
  padding: 12px 88px 12px 24px;
  z-index: 5;
  pointer-events: none;
}
.rhythm-time, .rhythm-reps {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 900;
  font-size: 22px;
  color: #2d2438;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-height: 48px;
  display: flex;
  align-items: center;
}

.rhythm-track {
  position: absolute;
  top: 14%;
  left: 0;
  right: 0;
  height: 140px;
  background: linear-gradient(180deg, rgba(255,248,232,0.85) 0%, rgba(253,226,182,0.85) 100%);
  border-top: 4px solid #cb965b;
  border-bottom: 4px solid #cb965b;
  overflow: hidden;
  z-index: 3;
}
.rhythm-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6%;
  width: 110px;
  background: rgba(118, 191, 118, 0.30);
  border-left: 4px solid #2f8a4a;
  border-right: 4px solid #2f8a4a;
  z-index: 2;
  pointer-events: none;
}
.rhythm-zone-inner {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.4), transparent);
  animation: zonePulse 1.1s ease-in-out infinite;
}
@keyframes zonePulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}
.rhythm-zone-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 38px;
  color: #2f6a3a;
  text-shadow: 0 2px 0 rgba(255,255,255,0.6);
  pointer-events: none;
}
/* Beat-pulse animation — applied briefly on every beat */
.rhythm-zone.beat-pulse {
  animation: zoneBeat 0.30s ease-out;
}
@keyframes zoneBeat {
  0%   { background: rgba(118, 191, 118, 0.30); transform: scaleX(1); }
  30%  { background: rgba(118, 220, 130, 0.65); transform: scaleX(1.04); }
  100% { background: rgba(118, 191, 118, 0.30); transform: scaleX(1); }
}

/* Tap targets — large circles with the dragon color, big enough for Michael */
.rhythm-target {
  position: absolute;
  top: 50%;
  width: 92px;
  height: 92px;
  margin-top: -46px;
  border-radius: 50%;
  background: var(--target-color, #f4d250);
  box-shadow:
    0 6px 14px rgba(0,0,0,0.25),
    inset 0 3px 0 rgba(255,255,255,0.6),
    inset 0 -6px 0 rgba(0,0,0,0.18);
  border: 4px solid rgba(255,255,255,0.75);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  pointer-events: none;
}
.rhythm-target.hit {
  animation: targetHit 0.4s ease-out forwards;
}
.rhythm-target.missed {
  animation: targetMiss 0.6s ease-out forwards;
}
@keyframes targetHit {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes targetMiss {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.7); opacity: 0; filter: grayscale(0.8); }
}

.rhythm-feedback {
  position: absolute;
  top: 8%;
  left: 6%;
  width: 220px;
  height: 60px;
  z-index: 5;
  pointer-events: none;
}
.rhythm-fb-text {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 32px;
  font-weight: 900;
  color: #2d2438;
  text-shadow: 0 2px 0 rgba(255,255,255,0.7), 0 4px 12px rgba(0,0,0,0.25);
  animation: fbFloat 0.9s ease-out forwards;
}
.rhythm-fb-text.perfect { color: #d8a020; }
.rhythm-fb-text.good    { color: #2f8a4a; }
.rhythm-fb-text.miss    { color: #888888; font-size: 24px; }
@keyframes fbFloat {
  0%   { opacity: 0; transform: translateY(8px) scale(0.7); }
  20%  { opacity: 1; transform: translateY(-4px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-46px) scale(1); }
}

.rhythm-dragon-area {
  position: absolute;
  inset: auto 0 0 0;
  height: 38%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4%;
  z-index: 2;
}
.rhythm-dragon {
  position: relative;
  width: 280px;
  height: 240px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.rhythm-dragon-svg {
  width: 100%;
  height: 100%;
}
.rhythm-dragon-svg svg { width: 100%; height: 100%; overflow: visible; }
.rhythm-barbell {
  position: absolute;
  top: 12%;
  left: 50%;
  width: 220px;
  height: 32px;
  margin-left: -110px;
  z-index: 3;
  opacity: 0;
  transition: top 0.18s ease, opacity 0.18s ease;
}
.rhythm-barbell .barbell-bar {
  top: 50%;
  left: 12%;
  right: 12%;
  height: 7px;
  margin-top: -3.5px;
}
.rhythm-barbell .barbell-plate {
  width: 20px;
  height: 40px;
  margin-top: -20px;
}
.rhythm-dragon.lifting .rhythm-barbell {
  opacity: 1;
}
.rhythm-dragon.lifting .rhythm-dragon-svg {
  animation: dragonLift 0.4s ease-out;
}
@keyframes dragonLift {
  0%   { transform: translateY(0)    scale(1); }
  40%  { transform: translateY(-4px) scale(1.03); }
  100% { transform: translateY(0)    scale(1); }
}
/* Beat bob — gentle vertical nod on every beat for visual sync */
.rhythm-dragon.beat-bob {
  animation: rhythmBob 0.34s ease-out;
}
@keyframes rhythmBob {
  0%, 100% { transform: translateY(0); }
  35%      { transform: translateY(-8px); }
}

.rhythm-tap-shield {
  position: absolute;
  inset: 0;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  z-index: 1;
}

/* ============ THE BIG OBVIOUS TAP BUTTON ============ */
.rhythm-tap-button {
  position: absolute;
  /* Sits in the gap between the rhythm track and the dragon */
  bottom: 42%;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #ffe888 0%, #f4a93a 65%, #d68028 100%);
  border: 6px solid #b06820;
  color: white;
  cursor: pointer;
  font-family: inherit;
  z-index: 4;
  box-shadow:
    0 12px 28px rgba(200, 120, 30, 0.55),
    inset 0 6px 0 rgba(255, 255, 255, 0.45),
    inset 0 -8px 0 rgba(120, 60, 10, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  filter: brightness(1);
  transition: filter 0.08s ease;
}
.tap-button-label {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 3px 0 rgba(140, 60, 10, 0.75);
  pointer-events: none;
}
.rhythm-tap-button.beat-pulse {
  animation: tapBeat 0.30s ease-out;
}
@keyframes tapBeat {
  0%   { transform: translateX(-50%) scale(1);    filter: brightness(1); }
  30%  { transform: translateX(-50%) scale(1.10); filter: brightness(1.22); }
  100% { transform: translateX(-50%) scale(1);    filter: brightness(1); }
}
.rhythm-tap-button.tap-pressed {
  animation: tapPress 0.15s ease-out;
}
@keyframes tapPress {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%      { transform: translateX(-50%) scale(0.90); filter: brightness(1.3); }
}

/* ============ "GET READY!" banner ============ */
.rhythm-ready {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 900;
  color: #2d2438;
  letter-spacing: 2px;
  text-shadow: 4px 4px 0 #ffe06b, 6px 6px 0 rgba(45, 36, 56, 0.18);
  opacity: 0;
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
}
.rhythm-ready.show {
  animation: readyShow 1.1s ease-out forwards;
}
@keyframes readyShow {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(0.6); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.10); }
  35%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  82%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.95); }
}

/* ============ COUNTOFF number ("1", "2", "3", "4") ============ */
.rhythm-countoff {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(64px, 12vw, 110px);
  font-weight: 900;
  color: #d8a020;
  text-shadow: 4px 4px 0 #fff8e8, 8px 8px 0 rgba(45, 36, 56, 0.18);
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  font-family: inherit;
}
.rhythm-countoff.show {
  animation: countoffPop 1.0s ease-out forwards;
}
@keyframes countoffPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

/* ============ INSTRUCTIONS overlay (pre-game) ============ */
.rhythm-instructions {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 240, 225, 0.94);
  z-index: 30;
  padding: 20px;
}
.rhythm-instructions.hide {
  animation: instructionsFade 0.30s ease-out forwards;
  pointer-events: none;
}
@keyframes instructionsFade {
  to { opacity: 0; transform: scale(0.96); }
}
.instructions-card {
  background: white;
  border-radius: 28px;
  padding: 32px 28px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.instructions-icon {
  font-size: 56px;
  margin-bottom: 8px;
}
.instructions-card h2 {
  font-size: clamp(28px, 5vw, 38px);
  margin: 6px 0 12px;
  color: #2d2438;
}
.instructions-card p {
  font-size: clamp(18px, 2.6vw, 22px);
  color: #5a4a6e;
  font-weight: 600;
  margin: 0 0 22px;
  line-height: 1.4;
}
.star-icon {
  display: inline-block;
  color: #d8a020;
  font-weight: 900;
  font-size: 1.1em;
  text-shadow: 0 2px 0 rgba(0,0,0,0.1);
}
.instructions-go {
  min-width: 200px;
  font-size: 28px;
  padding: 18px 36px;
}

/* Results screen */
.rhythm-results .score {
  font-size: 28px;
  font-weight: 800;
  color: #2d2438;
  margin: 12px 0 4px;
}
.tier-banner {
  display: inline-block;
  background: linear-gradient(135deg, #ffd76b, #f29849);
  color: white;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 20px;
  margin: 14px 0 8px;
  animation: sparkle 1.4s ease-in-out infinite;
  box-shadow: 0 6px 16px rgba(200, 140, 40, 0.4);
}

/* ============================================================
   PICKER MUSCLE BADGE
   Small overlay on each dragon card; only visible at tier ≥ 1.
   ============================================================ */
.muscle-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: #fff8e8;
  border: 2px solid #d8a020;
  color: #6a4a10;
  font-size: 13px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 999px;
  box-shadow: 0 3px 6px rgba(200, 140, 40, 0.3);
  display: flex;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

/* ============================================================
   DRAGON MUSCLE OVERLAYS (used inside the SVG)
   Visibility is controlled by .muscle-t1, .muscle-t2, .muscle-t3
   classes on the parent <svg>. We show the appropriate group only
   at or above its tier so tiers stack naturally.
   ============================================================ */
.muscle-t1-only, .muscle-t2-only, .muscle-t3-only { display: none; }
.muscle-t1 .muscle-t1-only { display: inline; }
.muscle-t2 .muscle-t2-only { display: inline; }
.muscle-t3 .muscle-t3-only { display: inline; }
/* Tier 3 holds a pronounced "double-bicep flex" pose every 4 seconds */
.muscle-t3 .muscle-flex {
  transform-origin: center 30%;  /* anchor near the shoulders so the bulges visibly puff out */
  animation: muscleFlex 4s ease-in-out infinite;
}
@keyframes muscleFlex {
  0%, 76%, 100% { transform: scale(1)    translateY(0); }
  80%           { transform: scale(1.07) translateY(-1px); }
  84%, 92%      { transform: scale(1.20) translateY(-3px); }
  96%           { transform: scale(1.05) translateY(-1px); }
}
