.castle-room-adventure {
  position: fixed;
  inset: 0;
  z-index: 780;
  display: grid;
  place-items: center;
  padding: 8px;
  color: #482443;
}

.castle-room-adventure[hidden] {
  display: none;
}

body.castle-room-adventure-locked {
  overflow: hidden;
}

body.castle-room-adventure-locked #bt-trigger,
body.castle-room-adventure-locked #bt-chime-label,
body.castle-room-adventure-locked #ew-trigger-btn,
body.castle-room-adventure-locked #ew-wheel,
body.castle-room-adventure-locked #garden-sim-panel,
body.castle-room-adventure-locked #ll-panel,
body.castle-room-adventure-locked #ll-trigger,
body.castle-room-adventure-locked #pet-egg-overlay,
body.castle-room-adventure-locked #ptt-trigger-btn,
body.castle-room-adventure-locked #rle-toggle-btn,
body.castle-room-adventure-locked #rle-panel {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.castle-room-adventure-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 236, 176, 0.38), transparent 28%),
    linear-gradient(180deg, rgba(55, 26, 64, 0.78), rgba(31, 23, 42, 0.88));
}

.castle-room-adventure-shell {
  position: relative;
  box-sizing: border-box;
  width: min(1180px, 98vw);
  height: min(920px, 98dvh);
  max-height: 98dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 8px;
  padding: 10px;
  border: 3px solid rgba(255, 221, 135, 0.92);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff9ef, #ffe4f3);
  box-shadow:
    0 24px 70px rgba(27, 15, 38, 0.4),
    inset 0 0 0 2px rgba(255, 255, 255, 0.62);
}

.castle-room-adventure-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.castle-room-adventure-kicker {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b3972;
}

.castle-room-adventure-topbar h2,
.castle-room-adventure-dialogue h3 {
  margin: 0;
  line-height: 1.1;
}

.castle-room-adventure-topbar h2 {
  font-size: 24px;
}

.castle-room-adventure-close,
.castle-room-adventure-primary,
.castle-room-adventure-controls button,
.castle-room-hotspot {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 900;
  color: #582545;
  background: linear-gradient(180deg, #fff9d6, #ffd373);
  box-shadow: 0 4px 0 #a96722;
  cursor: pointer;
  touch-action: manipulation;
}

.castle-room-adventure-close,
.castle-room-adventure-primary,
.castle-room-adventure-controls button {
  padding: 0 18px;
}

.castle-room-adventure-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  padding: 0;
  border: 3px solid rgba(155, 82, 125, 0.58);
  border-radius: 12px;
  background: #1c1722;
  box-shadow: inset 0 0 28px rgba(42, 20, 38, 0.22);
  isolation: isolate;
}

.castle-room-adventure-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}

.castle-room-adventure-hotspots {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.castle-room-hotspot {
  position: absolute;
  min-width: 54px;
  max-width: min(210px, 34vw);
  padding: 0 10px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.74);
  background: rgba(255, 249, 215, 0.94);
  box-shadow:
    0 4px 0 rgba(169, 103, 34, 0.95),
    0 0 0 5px rgba(255, 220, 112, 0.2);
  font-size: 12px;
  line-height: 1.1;
  pointer-events: auto;
  white-space: normal;
}

.castle-room-hotspot.next {
  animation: castle-room-helper-pulse 1.7s ease-in-out infinite;
  min-width: 96px;
  background: rgba(255, 247, 197, 0.97);
}

.castle-room-hotspot.done {
  background: rgba(232, 255, 239, 0.94);
  box-shadow:
    0 4px 0 rgba(57, 137, 87, 0.9),
    0 0 0 5px rgba(156, 235, 176, 0.22);
}

.castle-room-hotspot.later {
  opacity: 0.82;
}

.castle-room-adventure-player {
  position: absolute;
  z-index: 4;
  width: clamp(44px, 7vw, 82px);
  height: clamp(44px, 7vw, 82px);
  object-fit: contain;
  object-position: center bottom;
  transform: translate(-50%, -82%);
  filter: drop-shadow(0 8px 8px rgba(35, 21, 39, 0.32));
  pointer-events: none;
}

.castle-room-adventure-goal {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 5;
  max-width: min(480px, calc(100% - 24px));
  padding: 8px 12px;
  border: 2px solid rgba(255, 224, 133, 0.94);
  border-radius: 999px;
  background: rgba(255, 250, 232, 0.92);
  color: #572544;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(66, 31, 58, 0.18);
  pointer-events: none;
}

.castle-room-adventure.complete .castle-room-adventure-goal {
  background: rgba(232, 255, 242, 0.94);
  border-color: rgba(105, 205, 148, 0.9);
}

.castle-room-adventure-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.castle-room-adventure-dialogue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 2px solid rgba(255, 221, 135, 0.82);
  border-radius: 14px;
  background: rgba(255, 253, 246, 0.94);
  box-shadow: 0 10px 24px rgba(67, 31, 59, 0.14);
}

.castle-room-adventure-dialogue h3 {
  font-size: 20px;
}

.castle-room-adventure-dialogue p,
.castle-room-adventure-status {
  margin: 4px 0 0;
  color: #4f3851;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
}

.castle-room-adventure-status {
  min-height: 20px;
  padding: 0 4px;
}

.castle-room-adventure-close:focus-visible,
.castle-room-adventure-primary:focus-visible,
.castle-room-adventure-controls button:focus-visible,
.castle-room-adventure-stage:focus-visible,
.castle-room-hotspot:focus-visible {
  outline: 3px solid rgba(60, 175, 215, 0.96);
  outline-offset: 3px;
}

@keyframes castle-room-helper-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow:
      0 4px 0 rgba(169, 103, 34, 0.95),
      0 0 0 5px rgba(255, 220, 112, 0.18);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.06);
    box-shadow:
      0 4px 0 rgba(169, 103, 34, 0.95),
      0 0 0 10px rgba(255, 220, 112, 0.28);
  }
}

@media (prefers-reduced-motion: reduce) {
  .castle-room-hotspot.next {
    animation: none;
  }
}

@media (max-width: 720px) {
  .castle-room-adventure {
    padding: 4px;
  }

  .castle-room-adventure-shell {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    grid-template-rows: auto minmax(0, auto) auto minmax(0, auto) auto;
    border-radius: 0;
    border-width: 0;
    padding: 8px;
  }

  .castle-room-adventure-topbar h2 {
    font-size: 19px;
  }

  .castle-room-adventure-stage {
    max-height: 48dvh;
  }

  .castle-room-adventure-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .castle-room-adventure-dialogue {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
  }

  .castle-room-adventure-dialogue h3 {
    font-size: 18px;
  }

  .castle-room-adventure-dialogue p,
  .castle-room-adventure-status {
    font-size: 14px;
  }

  .castle-room-hotspot {
    max-width: 104px;
    min-width: 48px;
    min-height: 44px;
    padding: 0 8px;
    font-size: 11px;
  }

  .castle-room-hotspot.next {
    min-width: 84px;
  }

  .castle-room-adventure-goal {
    right: 8px;
    left: 8px;
    max-width: none;
    font-size: 12px;
    text-align: center;
  }
}
