.dollhouse-stairs-modal {
  position: fixed;
  inset: 0;
  z-index: 760;
  display: grid;
  place-items: center;
  padding: 18px;
  color: #552444;
}

.dollhouse-stairs-modal[hidden] {
  display: none;
}

body.dollhouse-stairs-locked {
  overflow: hidden;
}

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

.dollhouse-stairs-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 248, 196, 0.46), transparent 26%),
    linear-gradient(180deg, rgba(59, 33, 71, 0.72), rgba(42, 26, 58, 0.84));
}

.dollhouse-stairs-shell {
  position: relative;
  box-sizing: border-box;
  width: min(1180px, 96vw, calc((94dvh - 170px) * 1.6));
  max-height: min(820px, 94dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border: 3px solid rgba(255, 220, 129, 0.9);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8fb, #ffe4f0);
  box-shadow:
    0 24px 70px rgba(37, 17, 48, 0.38),
    inset 0 0 0 2px rgba(255, 255, 255, 0.58);
}

.dollhouse-stairs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dollhouse-stairs-kicker {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9b3b74;
}

.dollhouse-stairs-topbar h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.dollhouse-stairs-close,
.dollhouse-talk,
.dollhouse-pretend,
.dollhouse-controls button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 900;
  color: #5c2449;
  background: linear-gradient(180deg, #fff9d8, #ffd36f);
  box-shadow: 0 4px 0 #b06b24;
  cursor: pointer;
  touch-action: manipulation;
}

.dollhouse-stairs-close,
.dollhouse-talk,
.dollhouse-pretend {
  padding: 0 18px;
}

.dollhouse-stairs-close:focus-visible,
.dollhouse-talk:focus-visible,
.dollhouse-pretend:focus-visible,
.dollhouse-controls button:focus-visible,
.dollhouse-sprite-npc:focus-visible,
.dollhouse-sprite-player:focus-visible {
  outline: 3px solid rgba(67, 182, 217, 0.95);
  outline-offset: 3px;
}

.dollhouse-stairs-stage {
  position: relative;
  min-height: 0;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 3px solid rgba(181, 83, 127, 0.55);
  border-radius: 12px;
  background: #f4eadb;
  box-shadow: inset 0 0 28px rgba(96, 53, 76, 0.18);
  isolation: isolate;
}

.dollhouse-world {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--dollhouse-world-width, 190%);
  min-width: 100%;
  aspect-ratio: var(--dollhouse-world-aspect, 1.75);
  min-height: 100%;
  transform: translate(0, 0);
  transform-origin: 0 0;
  will-change: transform;
}

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

.dollhouse-sprite-layer {
  position: absolute;
  inset: 0;
}

.dollhouse-goal {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, calc(100% - 24px));
  padding: 8px 11px;
  border: 2px solid rgba(255, 220, 129, 0.9);
  border-radius: 999px;
  background: rgba(255, 250, 232, 0.9);
  box-shadow: 0 8px 18px rgba(75, 36, 59, 0.18);
  color: #64274d;
  font-size: 13px;
  font-weight: 900;
}

.dollhouse-goal strong {
  padding: 3px 8px;
  border-radius: 999px;
  background: #ffd976;
  color: #4d2140;
  white-space: nowrap;
}

.dollhouse-stairs-modal.goal-complete .dollhouse-goal {
  background: rgba(232, 255, 243, 0.94);
  border-color: rgba(102, 204, 148, 0.9);
}

.dollhouse-sprite {
  position: absolute;
  border: 0;
  padding: 0;
  background-color: transparent;
  background-repeat: no-repeat;
  transform: translate(-50%, -100%) scale(var(--dollhouse-sprite-scale, 0.75));
  transform-origin: 50% 100%;
  image-rendering: auto;
  filter: drop-shadow(0 7px 4px rgba(63, 37, 55, 0.26));
  transition: filter 0.18s ease;
}

.dollhouse-sprite-player {
  cursor: pointer;
  pointer-events: auto;
}

.dollhouse-sprite-npc {
  cursor: pointer;
}

.dollhouse-sprite-npc.near {
  filter:
    drop-shadow(0 7px 4px rgba(63, 37, 55, 0.25))
    drop-shadow(0 0 9px rgba(255, 226, 102, 0.95));
}

.dollhouse-sprite-npc.talking {
  animation: dollhouse-talk-bounce 360ms ease;
}

.dollhouse-dialogue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 14px;
  border: 2px solid rgba(176, 88, 127, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.dollhouse-action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.dollhouse-dialogue h3 {
  margin: 0 0 3px;
  font-size: 17px;
}

.dollhouse-dialogue p {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.dollhouse-talk:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

.dollhouse-pretend-popup,
.dollhouse-word-popup {
  position: absolute;
  inset: 10px;
  z-index: 9;
  display: grid;
  place-items: center;
}

.dollhouse-pretend-popup[hidden],
.dollhouse-word-popup[hidden] {
  display: none;
}

.dollhouse-pretend-popup-backdrop,
.dollhouse-word-popup-backdrop {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: rgba(62, 31, 70, 0.54);
}

.dollhouse-pretend-card,
.dollhouse-word-popup-card {
  position: relative;
  box-sizing: border-box;
  width: min(760px, calc(100% - 24px));
  max-height: min(520px, calc(100% - 24px));
  overflow: auto;
  padding: 18px;
  border: 3px solid rgba(255, 219, 112, 0.96);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(240, 255, 246, 0.94)),
    #fff;
  box-shadow: 0 18px 46px rgba(53, 25, 60, 0.34);
}

.dollhouse-pretend-close,
.dollhouse-word-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: #ffe58e;
  color: #552444;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 4px 0 #b06b24;
}

.dollhouse-pretend-card {
  width: min(620px, calc(100% - 24px));
}

.dollhouse-pretend-card h3 {
  margin: 4px 0 6px;
  color: #552444;
  font-size: 28px;
}

.dollhouse-pretend-card p {
  margin: 0 0 12px;
  color: #4b3850;
  font-weight: 800;
}

.dollhouse-pretend-video {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px;
  border: 2px solid rgba(124, 196, 164, 0.65);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 250, 232, 0.92), rgba(240, 255, 246, 0.92));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.dollhouse-pretend-video.scene-flash .dollhouse-pretend-video-image {
  animation: dollhouse-video-pop 420ms ease;
}

.dollhouse-pretend-video-screen {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.dollhouse-pretend-video-image {
  width: 86px;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 0 rgba(176, 107, 36, 0.22);
}

.dollhouse-pretend-video-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.dollhouse-pretend-video-copy h4 {
  margin: 0;
  color: #552444;
  font-size: 18px;
  line-height: 1.08;
}

.dollhouse-pretend-video-copy p,
.dollhouse-pretend-video-copy strong {
  margin: 0;
  color: #4b3850;
  font-size: 14px;
  line-height: 1.22;
}

.dollhouse-pretend-video-copy strong {
  color: #28795e;
}

.dollhouse-pretend-video-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dollhouse-pretend-video-dots {
  display: flex;
  gap: 5px;
}

.dollhouse-pretend-video-dots span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(85, 36, 68, 0.22);
}

.dollhouse-pretend-video-dots span.active {
  background: #2f9d79;
}

.dollhouse-video-next {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #ffe58e;
  color: #552444;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 3px 0 #b06b24;
  cursor: pointer;
}

.dollhouse-video-next:focus-visible {
  outline: 3px solid rgba(67, 182, 217, 0.95);
  outline-offset: 3px;
}

.dollhouse-pretend-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.dollhouse-pretend-choice {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 128px;
  padding: 10px 8px;
  border: 2px solid rgba(124, 196, 164, 0.65);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  color: #552444;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(176, 107, 36, 0.32);
  cursor: pointer;
}

.dollhouse-pretend-choice img {
  width: min(82px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
}

.dollhouse-pretend-choice:focus-visible {
  outline: 3px solid rgba(67, 182, 217, 0.95);
  outline-offset: 3px;
}

.dollhouse-pretend-status {
  display: block;
  margin-top: 12px;
  color: #28795e;
  font-size: 14px;
  font-weight: 900;
}

.dollhouse-word-kicker {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #28795e;
}

.dollhouse-word-main {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  margin-top: 8px;
}

.dollhouse-word-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 2px solid rgba(124, 196, 164, 0.55);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
}

.dollhouse-word-copy {
  min-width: 0;
  display: grid;
  gap: 9px;
}

.dollhouse-word-copy h3 {
  margin: 0;
  font-size: 58px;
  line-height: 0.92;
  color: #552444;
}

.dollhouse-word-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dollhouse-word-letters span {
  min-width: 34px;
  padding: 5px 8px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: #ffd976;
  color: #4d2140;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 3px 0 rgba(176, 107, 36, 0.42);
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.dollhouse-word-letters span.passed {
  background: #b9ead8;
  border-color: rgba(40, 121, 94, 0.3);
}

.dollhouse-word-letters span.active {
  transform: translateY(-5px) scale(1.1);
  background: #fffaf0;
  border-color: #2f9d79;
  color: #215a47;
  box-shadow:
    0 5px 0 rgba(47, 157, 121, 0.4),
    0 0 0 5px rgba(255, 217, 118, 0.45);
}

.dollhouse-word-prompt {
  margin: 0;
  color: #4b3850;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}

.dollhouse-word-slider-label,
.dollhouse-word-status {
  font-size: 13px;
  font-weight: 900;
  color: #5c4760;
}

.dollhouse-word-slider {
  width: 100%;
  height: 58px;
  margin: 0;
  border-radius: 999px;
  outline-offset: 5px;
  accent-color: #d78a22;
  appearance: none;
  -webkit-appearance: none;
  background:
    linear-gradient(
      90deg,
      #2f9d79 0%,
      #2f9d79 var(--word-slider-progress, 0%),
      #ffe6a5 var(--word-slider-progress, 0%),
      #ffe6a5 100%
    );
  border: 3px solid rgba(255, 197, 75, 0.95);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.78),
    0 5px 0 rgba(176, 107, 36, 0.42);
  cursor: grab;
}

.dollhouse-word-slider:active {
  cursor: grabbing;
}

.dollhouse-word-slider::-webkit-slider-runnable-track {
  height: 52px;
  border-radius: 999px;
  background: transparent;
}

.dollhouse-word-slider::-webkit-slider-thumb {
  width: 58px;
  height: 58px;
  margin-top: -3px;
  border: 4px solid #fffaf0;
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 28%, #fff 0 10%, transparent 11%),
    linear-gradient(180deg, #ff8ab6, #d83476);
  box-shadow:
    0 5px 0 #9a2755,
    0 0 0 5px rgba(255, 255, 255, 0.62);
  -webkit-appearance: none;
  appearance: none;
}

.dollhouse-word-slider::-moz-range-track {
  height: 52px;
  border-radius: 999px;
  background: transparent;
}

.dollhouse-word-slider::-moz-range-thumb {
  width: 50px;
  height: 50px;
  border: 4px solid #fffaf0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff8ab6, #d83476);
  box-shadow:
    0 5px 0 #9a2755,
    0 0 0 5px rgba(255, 255, 255, 0.62);
}

.dollhouse-controls {
  position: absolute;
  right: 24px;
  bottom: 118px;
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 6px;
  z-index: 4;
}

.dollhouse-controls button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.dollhouse-controls button[data-dollhouse-dir="up"] {
  grid-column: 2;
  grid-row: 1;
}

.dollhouse-controls button[data-dollhouse-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}

.dollhouse-controls button[data-dollhouse-dir="down"] {
  grid-column: 2;
  grid-row: 3;
}

.dollhouse-controls button[data-dollhouse-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}

.dollhouse-controls button.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b06b24;
}

.dollhouse-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@keyframes dollhouse-talk-bounce {
  0%,
  100% {
    transform: translate(-50%, -100%) scale(var(--dollhouse-sprite-scale, 0.75));
  }
  45% {
    transform: translate(-50%, -106%) scale(var(--dollhouse-sprite-scale, 0.75));
  }
}

@keyframes dollhouse-video-pop {
  0% {
    transform: scale(0.94);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

@media (max-width: 760px) {
  .dollhouse-stairs-modal {
    padding: 8px;
  }

  .dollhouse-stairs-shell {
    width: min(94vw, 560px);
    max-height: 96dvh;
    padding: 10px;
    border-radius: 14px;
  }

  .dollhouse-stairs-topbar h2 {
    font-size: 19px;
  }

  .dollhouse-stairs-kicker {
    font-size: 10px;
  }

  .dollhouse-dialogue {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 112px;
    padding: 10px;
  }

  .dollhouse-talk {
    width: 100%;
  }

  .dollhouse-action-row {
    width: 100%;
  }

  .dollhouse-action-row button {
    flex: 1 1 120px;
  }

  .dollhouse-pretend-popup,
  .dollhouse-word-popup {
    inset: 8px;
  }

  .dollhouse-pretend-card,
  .dollhouse-word-popup-card {
    width: min(330px, calc(100% - 12px));
    max-height: calc(100% - 12px);
    padding: 14px;
  }

  .dollhouse-pretend-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dollhouse-pretend-choice {
    min-height: 112px;
  }

  .dollhouse-pretend-choice img {
    width: 70px;
  }

  .dollhouse-pretend-video {
    padding: 8px;
  }

  .dollhouse-pretend-video-screen {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
  }

  .dollhouse-pretend-video-image {
    width: 64px;
  }

  .dollhouse-pretend-video-copy h4 {
    font-size: 16px;
  }

  .dollhouse-pretend-video-copy p,
  .dollhouse-pretend-video-copy strong {
    font-size: 12px;
  }

  .dollhouse-video-next {
    min-height: 36px;
    padding: 0 10px;
  }

  .dollhouse-word-main {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .dollhouse-word-image {
    width: min(210px, 76%);
    justify-self: center;
  }

  .dollhouse-word-copy h3 {
    font-size: 46px;
  }

  .dollhouse-word-letters span {
    min-width: 30px;
    padding: 5px 7px;
    font-size: 19px;
  }

  .dollhouse-word-slider {
    height: 62px;
  }

  .dollhouse-word-slider::-webkit-slider-runnable-track {
    height: 56px;
  }

  .dollhouse-word-slider::-webkit-slider-thumb {
    width: 62px;
    height: 62px;
  }

  .dollhouse-word-slider::-moz-range-track {
    height: 56px;
  }

  .dollhouse-word-slider::-moz-range-thumb {
    width: 54px;
    height: 54px;
  }

  .dollhouse-word-prompt {
    font-size: 15px;
  }

  .dollhouse-controls {
    position: static;
    justify-self: end;
    margin: -2px 8px 0 0;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 5px;
  }

  .dollhouse-controls button {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

@media (max-width: 440px) {
  .dollhouse-stairs-shell {
    gap: 8px;
  }

  .dollhouse-controls {
    margin-right: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dollhouse-sprite,
  .dollhouse-sprite-npc.talking,
  .dollhouse-word-letters span,
  .dollhouse-pretend-video.scene-flash .dollhouse-pretend-video-image {
    transition: none;
    animation: none;
  }
}
