.room {
  --hud: 6.75rem;
  position: relative;
  overflow: clip;
  scroll-margin-top: var(--mast);
  background: #211417;
}
.room-window {
  position: relative;
  height: max(25rem, calc(100svh - var(--mast) - var(--hud)));
  overflow: auto hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
  cursor: grab;
  background: #261719;
}
.room-window::-webkit-scrollbar { display: none; }
.room-window.dragging { cursor: grabbing; user-select: none; }
.room-world { position: relative; height: 100%; width: var(--world-size,100%); overflow: hidden; }
.room-world img,#room-spots,.room-glow { position: absolute; inset-inline-start: 0; top: var(--picture-y,0); width: 100%; height: var(--picture-h,100%); }
.room-world img { object-fit: fill; user-select: none; pointer-events: none; }
#room-spots { pointer-events: none; }
.room-glow { pointer-events: none; opacity: 0; background: radial-gradient(ellipse 20% 36% at 86% 52.4%,#f8b36c80,transparent 73%); mix-blend-mode: screen; transition: opacity .4s ease; }
.room-world.lit .room-glow { opacity: 1; }
.room-caption {
  position: absolute;
  z-index: 1;
  inset: 0 0 auto;
  padding: clamp(1rem,2.7vh,2rem) 1.1rem 3.2rem;
  text-align: center;
  pointer-events: none;
  background: linear-gradient(#231218ee,#241319ae 47%,transparent);
}
.room-caption h2 { font-size: clamp(2.15rem,5vw,4.15rem); letter-spacing: -.061em; line-height: 1.05; text-shadow: 0 2px 1rem #190b0c; }
.room-caption em { color: var(--gold); font-weight: 425; }
.room-hint { margin-top: .4rem; color: #f5e4cb; font-size: clamp(.91rem,1.6vw,1.06rem); line-height: 1.35; text-shadow: 0 1px .4rem #251618; }
.room-hint-pointer { display: none; }
@media (hover: hover) and (pointer: fine) {
  .room-hint-touch { display: none; }
  .room-hint-pointer { display: inline; }
}
.room-controls {
  position: relative;
  border-top: 1px solid #88613b;
  min-height: var(--hud);
  padding: .55rem clamp(.75rem,3.8vw,3.5rem) max(.55rem,env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 clamp(.95rem,3.7vw,3rem);
  background: radial-gradient(ellipse at 50% 0,#39221f,#211417 86%);
}
.room-map { display: flex; justify-content: center; gap: .35rem; }
.room-map button,.room-tools button { min-height: 44px; border: 1px solid transparent; color: #ead6b8; background: transparent; font-size: .95rem; padding: .5rem .8rem; white-space: nowrap; }
.room-map button { position: relative; border-radius: 2rem; }
.room-map button[aria-current] { color: var(--gold); border-color: #ad8a4e; background: #1f1216; }
.room-map button:hover { border-color: #8d7049; }
.room-tools { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0 .85rem; }
.room-tools button { text-decoration: underline; text-underline-offset: .22em; border: 0; padding-inline: .15rem; }
.room-tools button:hover { color: var(--gold); }
.room-tools button[aria-disabled=true] { opacity: .65; cursor: wait; }
#room-mode { color: #e1c493; font-size: .82rem; }
#room-status { flex: 0 0 100%; margin: .12rem 0 0; text-align: center; font-size: .9rem; color: #f0d9c0; }
#room-status:empty { display: none; }
.room-spot,.lamp-switch { display: inline-grid; position: absolute; place-items: center; pointer-events: auto; transform: translate(-50%,-50%); margin: 0; }
.room-spot {
  width: 47px;
  height: 47px;
  border: 1px solid #f2d28d;
  border-radius: 50%;
  color: #ffe6a4;
  background: #2b171ce8;
  box-shadow: 0 0 1.1rem #ffbd607a,0 .25rem .7rem #130909b8,inset 0 0 0 3px #a87c4e59;
}
.room-spot::before { content: ""; position: absolute; inset: -.34rem; border: 1px solid #eec77d7d; border-radius: 50%; animation: location-spark 1.4s ease-out 2; }
.room-spot .icon { width: 1.21rem; height: 1.21rem; }
.room-spot.first-secret,.room-spot:active { color: #341d20; background: #edcc77; }
@media (hover: hover) { .room-spot:hover { color: #341d20; background: #edcc77; } }
.room-spot.was-read { box-shadow: 0 .18rem .65rem #170d0d8f,inset 0 0 0 3px #a87c4e33; }
.room-spot.was-read::before { opacity: 0; }
.spot-label {
  position: absolute;
  top: calc(100% + .3rem);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: .28rem .57rem;
  border: 1px solid #a97e519e;
  border-radius: .15rem;
  background: #28171aef;
  color: #fff0d3;
  font-size: .79rem;
  font-weight: 520;
  line-height: 1.2;
  pointer-events: auto;
}
.room-spot:is([data-slot="3"],[data-slot="4"],[data-slot="5"]) .spot-label {
  top: auto;
  bottom: calc(100% + .3rem);
}
.room-spot.first-secret .spot-label {
  width: max-content;
  max-width: min(15rem,70vw);
  padding: .49rem .75rem;
  border-color: #dcb879;
  color: var(--cream);
  font-size: .92rem;
  text-align: center;
  white-space: normal;
}
.lamp-switch { z-index: 1; top: calc(var(--picture-y,0px) + var(--picture-h,0px) * .524); left: 86%; width: 44px; height: 44px; background: #342024b5; color: #ffe5a0; border: 1px solid #e1b964; border-radius: 50%; box-shadow: 0 0 .8rem #eebe67b3; }
.lamp-switch[aria-pressed=true] { color: #4a2426; background: #ffe2a2; }
@keyframes location-spark { 0% { transform: scale(.84); opacity: .88; } 100% { transform: scale(1.35); opacity: 0; } }
.room::before,.room::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0 auto 0 0;
  width: 50%;
  transform-origin: left;
  background: repeating-linear-gradient(90deg,#1b0b13,#542331 16%,#2a121c 29%);
  pointer-events: none;
  transform: scaleX(0);
}
.room::after { inset: 0 0 0 auto; transform-origin: right; }
.room.reveal::before,.room.reveal::after { animation: curtain-uncover .72s cubic-bezier(.68,.03,.25,1) both; }
@keyframes curtain-uncover { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.wall-dialog {
  --accent: #843c46;
  width: min(39rem,calc(100% - 1.35rem));
  max-height: calc(100dvh - 1.5rem);
  padding: clamp(1.45rem,5vw,3.25rem);
  border: 1px solid #bf965f;
  border-radius: .1rem .27rem .18rem .12rem;
  background: radial-gradient(ellipse at top left,#fff5df,#efe0bf 80%,#e5d1ac);
  color: #392421;
  box-shadow: 0 2rem 6rem #190a10bf;
  overscroll-behavior: contain;
  animation: wall-letter .3s ease-out;
}
.wall-dialog::backdrop { background: #190b12d6; backdrop-filter: blur(4px); }
@keyframes wall-letter { from { opacity: 0; transform: translateY(.75rem) rotate(-2.8deg) scale(.97); } to { opacity: 1; transform: none; } }
.wall-dialog-title { margin: 0 3.5rem 1.55rem 0; color: var(--accent); font-size: .84rem; line-height: 1.3; font-weight: 640; letter-spacing: .093em; text-transform: uppercase; }
.wall-dialog-close { position: absolute; top: .85rem; right: .85rem; }
.wall-dialog-mark { display: block; color: var(--accent); font-size: 4.6rem; height: 2.3rem; line-height: .83; user-select: none; }
.wall-dialog-text { margin: .45rem 0 1.6rem; font-size: clamp(1.8rem,5vw,3.2rem); font-style: italic; line-height: 1.13; letter-spacing: -.046em; overflow-wrap: anywhere; }
.wall-dialog-text:focus { outline: 0; }
.wall-dialog-turns { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1rem; padding-top: .45rem; border-top: 1px solid #b49270; }
.wall-dialog-turn { min-height: 44px; padding: .5rem 0; border: 0; color: #65323f; background: transparent; text-decoration: underline; text-underline-offset: .22em; }
.wall-dialog-turn:disabled { color: #77685c; text-decoration: none; cursor: default; }
.wall-index { list-style: none; padding: 0; margin: .4rem 0 0; }
.wall-index button { min-height: 44px; display: block; width: 100%; border: 0; padding: .8rem 0; border-top: 1px solid #c2a480; color: #412926; background: none; text-align: left; overflow-wrap: anywhere; }
.wall-index button:hover { color: #8c394a; }
.wall-dialog :focus-visible { outline-color: #81424b; }

@media (max-width: 680px) {
  .room { --hud: 6.65rem; }
  .room-caption { padding: 1.25rem .6rem 2.8rem; }
  .room-controls { display: grid; justify-items: center; justify-content: stretch; padding-top: .49rem; }
  .room-map button,.room-tools button { font-size: .89rem; }
  .room-map button { padding-inline: .67rem; }
  .room-tools { gap: 0 .85rem; }
  #room-mode { font-size: .74rem; }
  .room-spot { width: 48px; height: 48px; }
}
/* Móvil en horizontal: los controles de la sala deben caber sin hacer scroll. */
@media (orientation: landscape) and (max-height: 520px) {
  .room { --hud: 3.4rem; }
  .room-window { height: max(13rem, calc(100svh - var(--mast) - var(--hud))); }
  .room-caption { padding: .45rem 1rem 1.6rem; }
  .room-caption h2 { font-size: clamp(1.5rem, 7svh, 2rem); }
  .room-hint { display: none; }
  .room-controls { padding-block: .2rem; }
  #room-status { position: absolute; bottom: calc(100% + .4rem); left: 50%; transform: translateX(-50%); width: max-content; max-width: 90%; padding: .25rem .6rem; background: #28171aef; }
}
@media (max-width: 360px) {
  .room-window { height: max(22rem, calc(100svh - var(--mast) - var(--hud))); }
  .room-caption h2 { font-size: 2rem; }
  .room-hint { font-size: .83rem; }
  .room-tools { gap: 0 .55rem; }
  .room-tools button { font-size: .82rem; }
}

