@layer reset, shell, plan, rooms, mechanisms, state, motion, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { width: 100%; min-height: 100%; margin: 0; }
  button, output { font: inherit; }
  button { color: inherit; }
  :focus-visible { outline: 3px dashed #ffd98a; outline-offset: 5px; }
}

@layer shell {
  :root {
    --ink: #0b1020;
    --blueprint: #111c31;
    --blueprint-raised: #18263e;
    --wall: #e5dcc8;
    --wall-muted: #9e9a91;
    --copper: #ed8f55;
    --copper-dark: #8e4e34;
    --butter: #ffd98a;
    --coral: #d86f64;
    --teal: #5e9a91;
    --plum: #77566f;
    --chalk: #f2eadb;
    --muted: #9da8b8;
    --shadow: rgba(2, 5, 13, 0.56);
    --room-pad: clamp(0.62rem, 1.3vw, 1.15rem);
  }

  body {
    overflow: hidden;
    background: var(--ink);
    color: var(--chalk);
    font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  }

  .skip-link {
    position: fixed;
    z-index: 1000;
    left: 1rem;
    top: 1rem;
    translate: 0 -200%;
    padding: 0.72rem 0.9rem;
    border: 1px solid var(--wall);
    background: var(--ink);
    color: var(--chalk);
  }

  .skip-link:focus { translate: 0; }

  .house {
    position: relative;
    width: 100%;
    height: 100svh;
    min-height: 0;
    overflow: hidden;
    isolation: isolate;
    background: var(--ink);
  }

  .plan-key {
    position: absolute;
    z-index: 80;
    left: clamp(0.8rem, 2vw, 1.8rem);
    bottom: clamp(0.7rem, 1.8vw, 1.55rem);
    width: min(16rem, 46vw);
    min-height: 4.7rem;
    margin: 0;
    padding: 0.75rem 4.8rem 0.25rem 0.75rem;
    border-top: 1px solid rgba(229, 220, 200, 0.52);
    border-right: 1px solid rgba(229, 220, 200, 0.28);
    color: var(--muted);
    background: linear-gradient(90deg, rgba(11, 16, 32, 0.94), rgba(11, 16, 32, 0.62) 78%, transparent);
  }

  .plan-key::before {
    content: "";
    position: absolute;
    left: 0;
    top: -0.3rem;
    width: 2.9rem;
    height: 0.3rem;
    background: var(--copper);
  }

  .plan-kicker,
  .plan-help,
  .location {
    margin: 0;
    font-size: clamp(0.49rem, 0.72vw, 0.61rem);
    line-height: 1.45;
  }

  .plan-kicker { color: var(--wall-muted); letter-spacing: 0.08em; text-transform: uppercase; }

  .plan-key h1 {
    margin: 0.28rem 0 0.36rem;
    color: var(--wall);
    font: 400 clamp(1.25rem, 2.15vw, 1.95rem)/0.95 Georgia, "Times New Roman", serif;
    letter-spacing: -0.02em;
  }

  .location { margin-top: 0.18rem; color: var(--butter); }

  .rewind {
    position: absolute;
    right: 0.65rem;
    bottom: 0.4rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0.35rem 0.45rem;
    border: 1px solid rgba(229, 220, 200, 0.36);
    border-radius: 2px;
    background: rgba(17, 28, 49, 0.72);
    color: var(--muted);
    font-size: 0.55rem;
    cursor: pointer;
  }

  .rewind:hover,
  .rewind:focus-visible { color: var(--chalk); border-color: var(--copper); }

  .not-found {
    display: grid;
    min-height: 100svh;
    place-items: center;
    overflow: hidden;
    background:
      linear-gradient(rgba(157,168,184,0.05) 1px, transparent 1px),
      linear-gradient(90deg, rgba(157,168,184,0.05) 1px, transparent 1px),
      var(--ink);
    background-size: 2rem 2rem;
  }

  .not-found main { width: min(88vw, 34rem); text-align: center; }
  .not-found p { color: var(--copper); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; }
  .not-found h1 { max-width: 12ch; margin: 0.9rem auto 2rem; font: 400 clamp(2rem, 7vw, 4rem)/0.95 Georgia, serif; }
  .not-found a { display: inline-grid; min-height: 44px; place-items: center; padding: 0.65rem 0.85rem; border: 1px solid var(--wall-muted); color: var(--chalk); }
  .lost-room { position: relative; width: 11rem; height: 8rem; margin: 0 auto 1.4rem; border: 0.35rem solid var(--wall); background: var(--blueprint-raised); box-shadow: 0.7rem 0.9rem 1rem var(--shadow); }
  .lost-room::before { content: ""; position: absolute; right: -0.35rem; bottom: 1.2rem; width: 2rem; height: 0.6rem; border: 1px solid var(--wall); background: var(--ink); }
  .lost-room span { position: absolute; left: 50%; top: 50%; translate: -50% -50%; color: var(--butter); font: 400 3rem/1 Georgia, serif; }
}

@layer plan {
  .plan {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: inherit;
    overflow: hidden;
    background:
      radial-gradient(circle at 53% 46%, rgba(94, 154, 145, 0.08), transparent 34%),
      var(--ink);
  }

  .draft-grid {
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.4;
    pointer-events: none;
    background-image:
      linear-gradient(rgba(157, 168, 184, 0.07) 1px, transparent 1px),
      linear-gradient(90deg, rgba(157, 168, 184, 0.07) 1px, transparent 1px),
      linear-gradient(rgba(157, 168, 184, 0.025) 1px, transparent 1px),
      linear-gradient(90deg, rgba(157, 168, 184, 0.025) 1px, transparent 1px);
    background-size: 4rem 4rem, 4rem 4rem, 0.8rem 0.8rem, 0.8rem 0.8rem;
  }

  .draft-grid::after {
    content: "";
    position: absolute;
    inset: clamp(0.65rem, 1.4vw, 1.2rem);
    border: 1px solid rgba(229, 220, 200, 0.14);
  }

  .house-foundation {
    position: absolute;
    z-index: 1;
    left: 4.2%;
    top: 3.1%;
    width: 93.8%;
    height: 80.8%;
    border: clamp(2px, 0.28vw, 4px) solid rgba(229, 220, 200, 0.5);
    background: rgba(17, 28, 49, 0.68);
    box-shadow: 1rem 1.2rem 2rem rgba(2, 5, 13, 0.45);
    clip-path: polygon(2% 2%, 33% 2%, 33% 6%, 59% 6%, 59% 1%, 92% 1%, 92% 28%, 100% 28%, 100% 63%, 95% 63%, 95% 100%, 60% 100%, 60% 96%, 35% 96%, 35% 100%, 2% 100%, 2% 57%, 0 57%, 0 9%);
    pointer-events: none;
  }

  .hall {
    position: absolute;
    z-index: 5;
    border: 2px solid rgba(229, 220, 200, 0.62);
    background: #15233a;
    box-shadow: inset 0 0 0 1px rgba(11, 16, 32, 0.8);
    pointer-events: none;
  }

  .hall-time-weather { left: 34.2%; top: 20.5%; width: 4.4%; height: 6%; border-inline: 0; }
  .hall-weather-music { left: 57.4%; top: 20%; width: 4%; height: 6%; border-inline: 0; }
  .hall-time-question { left: 18%; top: 42%; width: 5%; height: 7%; border-block: 0; }
  .hall-weather-foyer { left: 47%; top: 37%; width: 5%; height: 9%; border-block: 0; }
  .hall-question-foyer { left: 34%; top: 61%; width: 6%; height: 6%; border-inline: 0; }
  .hall-foyer-quiet { left: 62%; top: 63%; width: 6%; height: 6%; border-inline: 0; }

  .route-canvas {
    position: absolute;
    inset: 0;
    z-index: 30;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  .resident {
    position: absolute;
    z-index: 46;
    left: 51%;
    top: 62%;
    display: grid;
    width: clamp(2.25rem, 4vw, 3.8rem);
    aspect-ratio: 1;
    place-items: center;
    border: 1px solid rgba(255, 217, 138, 0.56);
    border-radius: 50%;
    background: var(--blueprint);
    color: var(--butter);
    box-shadow: 0 0.55rem 1.15rem var(--shadow), 0 0 1.2rem rgba(237, 143, 85, 0.34);
    font: 400 clamp(1.35rem, 2.8vw, 2.5rem)/1 Georgia, "Times New Roman", serif;
    translate: -50% -50%;
    pointer-events: none;
    transition: left 520ms cubic-bezier(.16,.86,.28,1), top 520ms cubic-bezier(.16,.86,.28,1), box-shadow 220ms ease;
  }

  .resident::before,
  .resident::after {
    content: "";
    position: absolute;
    inset: -0.48rem;
    border: 1px solid rgba(237, 143, 85, 0.2);
    border-radius: 50%;
  }

  .resident::after { inset: -0.9rem; opacity: 0.58; }

  .plan[data-current="time"] .resident { left: 20.5%; top: 24.5%; }
  .plan[data-current="weather"] .resident { left: 48%; top: 23.5%; }
  .plan[data-current="music"] .resident { left: 76%; top: 24%; }
  .plan[data-current="switch"] .resident { left: 93.5%; top: 41%; }
  .plan[data-current="question"] .resident { left: 20.5%; top: 64.5%; }
  .plan[data-current="quiet"] .resident { left: 78.5%; top: 66%; }
  .plan[data-current="foyer"] .resident { left: 51%; top: 63%; }

  .spark-layer {
    position: absolute;
    inset: 0;
    z-index: 55;
    overflow: hidden;
    pointer-events: none;
  }

  .spark {
    position: absolute;
    left: var(--spark-left, 50%);
    top: var(--spark-top, 50%);
    width: var(--spark-size, 4px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--spark-color, var(--butter));
    box-shadow: 0 0 0.7rem var(--spark-color, var(--butter));
    animation: spark-out 1.2s ease-out both;
  }

  .toast,
  .noscript-note {
    position: absolute;
    z-index: 70;
    left: 50%;
    bottom: 3.1%;
    width: max-content;
    max-width: min(88vw, 30rem);
    margin: 0;
    padding: 0.4rem 0.58rem;
    border: 1px solid rgba(229, 220, 200, 0.24);
    background: rgba(11, 16, 32, 0.9);
    color: var(--chalk);
    font-size: clamp(0.56rem, 0.8vw, 0.66rem);
    text-align: center;
    opacity: 0;
    translate: -50% 0.35rem;
    pointer-events: none;
    transition: opacity 160ms ease, translate 160ms ease;
  }

  .toast.is-visible { opacity: 1; translate: -50% 0; }
  .noscript-note { bottom: 2.4%; opacity: 1; translate: -50% 0; }
}

@layer rooms {
  .room {
    position: absolute;
    z-index: 10;
    display: block;
    min-width: 44px;
    min-height: 44px;
    padding: var(--room-pad);
    overflow: hidden;
    border: clamp(2px, 0.31vw, 5px) solid rgba(229, 220, 200, 0.72);
    border-radius: 2px;
    background: var(--blueprint-raised);
    color: var(--chalk);
    box-shadow: 0.35rem 0.5rem 0.9rem rgba(2, 5, 13, 0.46), inset 0 0 0 1px rgba(11, 16, 32, 0.76);
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 220ms ease, background-color 350ms ease, filter 220ms ease, box-shadow 220ms ease;
  }

  .room::before {
    content: "";
    position: absolute;
    z-index: 0;
    inset: 0;
    opacity: 0.45;
    background-image:
      linear-gradient(rgba(242, 234, 219, 0.035) 1px, transparent 1px),
      linear-gradient(90deg, rgba(242, 234, 219, 0.035) 1px, transparent 1px);
    background-size: 1rem 1rem;
    pointer-events: none;
  }

  .room::after {
    content: "";
    position: absolute;
    z-index: 8;
    width: clamp(1.4rem, 3vw, 2.8rem);
    height: clamp(0.36rem, 0.7vw, 0.58rem);
    border: 1px solid rgba(229, 220, 200, 0.78);
    background: var(--ink);
    box-shadow: inset 0 0 0 2px var(--blueprint);
  }

  .room:hover { filter: brightness(1.08); border-color: var(--wall); }
  .room:active { filter: brightness(1.16); }
  .room > * { position: relative; z-index: 2; }

  .room-time {
    left: 6%; top: 6%; width: 29%; height: 37%;
    border-radius: 1rem 0.2rem 0.2rem 0.45rem;
    background: #16253d;
  }
  .room-time::after { right: -0.2rem; top: 48%; bottom: auto; rotate: 90deg; }

  .room-weather {
    left: 38%; top: 8%; width: 20%; height: 30%;
    background: #18313d;
  }
  .room-weather::after { left: 50%; bottom: -0.22rem; translate: -50% 0; }

  .room-music {
    left: 61%; top: 5%; width: 27%; height: 38%;
    border-radius: 0.2rem 1rem 0.4rem 0.2rem;
    background: #22263e;
  }
  .room-music::after { left: 4%; bottom: -0.22rem; }

  .room-switch {
    left: 89%; top: 29%; width: 9%; height: 24%;
    border-radius: 0.2rem 0.8rem 0.8rem 0.2rem;
    background: #24363e;
  }
  .room-switch::after { left: -1rem; bottom: 16%; rotate: 90deg; }

  .room-question {
    left: 6%; top: 48%; width: 29%; height: 34%;
    border-radius: 0.35rem 0.2rem 0.2rem 1rem;
    background: #31233a;
  }
  .room-question::after { right: -0.2rem; top: 16%; rotate: 90deg; }

  .room-foyer {
    left: 39%; top: 45%; width: 24%; height: 36%;
    border-radius: 0.2rem 0.2rem 1rem 1rem;
    background: #16243b;
  }
  .room-foyer::after { left: 50%; top: -0.22rem; translate: -50% 0; }

  .room-quiet {
    left: 67%; top: 50%; width: 23%; height: 32%;
    border-radius: 0.2rem 0.45rem 1rem 0.2rem;
    background: #29243a;
  }
  .room-quiet::after { left: -0.2rem; top: 52%; rotate: 90deg; }

  .room-number,
  .room-name {
    position: absolute;
    z-index: 5;
    left: var(--room-pad);
    top: var(--room-pad);
    line-height: 1;
    pointer-events: none;
  }

  .room-number {
    top: calc(var(--room-pad) + 1.25rem);
    color: var(--muted);
    font-size: clamp(0.45rem, 0.66vw, 0.57rem);
  }

  .room-name {
    color: var(--wall);
    font-size: clamp(0.53rem, 0.77vw, 0.67rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .room-reading {
    position: absolute;
    z-index: 6;
    right: var(--room-pad);
    bottom: calc(var(--room-pad) * 0.72);
    max-width: 70%;
    color: var(--muted);
    font-size: clamp(0.48rem, 0.72vw, 0.62rem);
    line-height: 1.2;
    text-align: right;
  }

  .room.is-visited { border-color: rgba(237, 143, 85, 0.7); }
  .room.is-visited .room-number { color: var(--copper); }
  .room.is-current {
    z-index: 18;
    border-color: var(--copper);
    box-shadow: 0.8rem 1rem 1.45rem var(--shadow), inset 0 0 0 1px rgba(255, 217, 138, 0.3), 0 0 1.4rem rgba(237, 143, 85, 0.2);
  }

  .no-js .room { cursor: default; }
}

@layer mechanisms {
  .clock {
    position: absolute;
    left: 50%; top: 52%;
    width: min(68%, 13rem);
    aspect-ratio: 1;
    border: clamp(1px, 0.18vw, 3px) solid rgba(229, 220, 200, 0.56);
    border-radius: 50%;
    translate: -50% -50%;
    background:
      repeating-conic-gradient(from -1deg, rgba(229,220,200,0.62) 0 1deg, transparent 1deg 30deg),
      radial-gradient(circle, transparent 0 42%, rgba(229,220,200,0.12) 42.5% 44%, transparent 44.5%);
  }

  .clock-orbit { position: absolute; inset: 16%; border: 1px solid rgba(237, 143, 85, 0.54); border-radius: 50%; }
  .clock-orbit-two { inset: 31%; border-color: rgba(229, 220, 200, 0.28); }
  .clock-hand { position: absolute; left: 50%; bottom: 50%; width: 2px; border-radius: 1rem; background: var(--butter); transform-origin: 50% 100%; }
  .clock-hour { height: 24%; transform: translateX(-50%) rotate(var(--hour-angle, 0deg)); }
  .clock-minute { height: 35%; background: var(--copper); transform: translateX(-50%) rotate(var(--minute-angle, 0deg)); }
  .clock-pin { position: absolute; left: 50%; top: 50%; width: 0.5rem; aspect-ratio: 1; border-radius: 50%; background: var(--copper); translate: -50% -50%; }

  .window {
    position: absolute;
    left: 16%; right: 14%; top: 23%; bottom: 21%;
    overflow: hidden;
    border: clamp(3px, 0.45vw, 7px) solid #595362;
    background: #151b34;
    box-shadow: inset 0 0 2rem rgba(2, 5, 13, 0.75), 0 0.7rem 0.9rem rgba(2,5,13,0.35);
  }

  .window-frame::before,
  .window-frame::after { content: ""; position: absolute; z-index: 4; background: #595362; }
  .window-frame::before { left: calc(50% - 0.2rem); top: 0; width: 0.4rem; height: 100%; }
  .window-frame::after { left: 0; top: calc(50% - 0.2rem); width: 100%; height: 0.4rem; }
  .window-moon { position: absolute; right: 12%; top: 12%; width: clamp(1rem, 2.5vw, 2.2rem); aspect-ratio: 1; border-radius: 50%; background: var(--butter); box-shadow: 0 0 1rem rgba(255,217,138,0.42); transition: translate 650ms ease, background 650ms ease; }
  .window-star { position: absolute; width: 0.22rem; aspect-ratio: 1; border-radius: 50%; background: var(--chalk); }
  .window-star-one { left: 18%; top: 21%; }
  .window-star-two { left: 61%; top: 71%; }
  .window-star-three { left: 34%; top: 66%; }
  .window-rain { position: absolute; top: -20%; width: 1px; height: 35%; opacity: 0; background: linear-gradient(transparent, #9fc8d4); rotate: 14deg; }
  .window-rain-one { left: 27%; }
  .window-rain-two { left: 70%; animation-delay: -0.45s; }

  .plan[data-weather="rain"] .window { background: #345065; }
  .plan[data-weather="rain"] .window-moon,
  .plan[data-weather="rain"] .window-star { opacity: 0.16; }
  .plan[data-weather="rain"] .window-rain { opacity: 0.9; animation: rain 950ms linear infinite; }
  .plan[data-weather="dawn"] .window { background: #8f5861; }
  .plan[data-weather="dawn"] .window-moon { translate: -240% 110%; background: #ffbd79; }
  .plan[data-weather="dawn"] .window-star { opacity: 0; }
  .plan[data-weather="void"] .window { background: #030711; }
  .plan[data-weather="void"] .window-moon { background: transparent; border: 1px solid var(--wall); box-shadow: 0 0 0 0.35rem rgba(229,220,200,0.09); }

  .resonators {
    position: absolute;
    left: 13%; right: 10%; top: 25%; bottom: 31%;
    display: flex;
    align-items: end;
    justify-content: space-around;
    border-bottom: 2px solid rgba(237, 143, 85, 0.64);
  }

  .resonators span {
    display: block;
    width: clamp(1.15rem, 3.3vw, 3rem);
    aspect-ratio: 1;
    border: clamp(2px, 0.3vw, 4px) solid #a97750;
    border-radius: 50%;
    background: radial-gradient(circle at 42% 38%, #e7b76d 0 13%, #8b5e3c 15% 46%, #33293a 48%);
    box-shadow: 0 0.7rem 0.7rem rgba(2,5,13,0.42);
    transform-origin: 50% 100%;
  }

  .resonators span:nth-child(2) { width: clamp(1.5rem, 4.2vw, 3.7rem); }
  .resonators span:nth-child(3) { width: clamp(1rem, 2.5vw, 2.25rem); }
  .resonators span:nth-child(4) { width: clamp(1.3rem, 3.7vw, 3.2rem); }
  .music-wave { position: absolute; left: 20%; right: 15%; bottom: 18%; height: 1.3rem; border-top: 1px dashed rgba(229,220,200,0.25); }
  .music-wave::after { content: ""; position: absolute; left: 0; top: -0.2rem; width: 100%; height: 0.42rem; background: linear-gradient(90deg, transparent 0 4%, var(--copper) 4% 5%, transparent 5% 12%, var(--copper) 12% 14%, transparent 14% 26%, var(--copper) 26% 27%, transparent 27% 46%, var(--copper) 46% 50%, transparent 50% 65%, var(--copper) 65% 67%, transparent 67% 89%, var(--copper) 89% 90%, transparent 90%); }
  .room-music.is-playing .resonators span { animation: resonate 420ms ease-in-out infinite alternate; }
  .room-music.is-playing .resonators span:nth-child(2) { animation-delay: -0.18s; }
  .room-music.is-playing .resonators span:nth-child(3) { animation-delay: -0.31s; }

  .switch-bank {
    position: absolute;
    left: 50%; top: 51%;
    display: flex;
    gap: clamp(0.3rem, 0.7vw, 0.65rem);
    translate: -50% -50%;
  }

  .switch-bank span { position: relative; display: block; width: clamp(0.45rem, 0.8vw, 0.68rem); height: clamp(1.6rem, 3.8vw, 3rem); border: 1px solid #917b65; background: #172338; }
  .switch-bank span::before { content: ""; position: absolute; left: 50%; top: 48%; width: clamp(0.52rem, 1vw, 0.8rem); height: 45%; border-radius: 1rem 1rem 0.15rem 0.15rem; background: var(--coral); transform: translate(-50%, -50%) rotate(8deg); transform-origin: 50% 90%; transition: transform 450ms ease, background 450ms ease; }
  body[data-power="bright"] .switch-bank span::before { background: var(--butter); transform: translate(-50%, -50%) rotate(172deg); }

  .question-mechanism {
    position: absolute;
    left: 50%; top: 52%;
    width: min(56%, 9rem);
    aspect-ratio: 1;
    translate: -50% -50%;
  }

  .question-ring { position: absolute; inset: 0; border: 1px solid rgba(216, 111, 100, 0.72); border-radius: 50%; }
  .question-ring::before,
  .question-ring::after { content: ""; position: absolute; left: 50%; top: -0.24rem; width: 0.45rem; aspect-ratio: 1; border-radius: 50%; background: var(--coral); translate: -50% 0; }
  .question-ring::after { top: auto; bottom: -0.24rem; }
  .question-ring-two { inset: 23%; rotate: 45deg; border-color: rgba(229,220,200,0.28); }
  .question-mark { position: absolute; inset: 31%; display: grid; place-items: center; border: 1px solid rgba(229,220,200,0.35); border-radius: 50%; color: var(--butter); font: 400 clamp(1.5rem, 4vw, 3.6rem)/1 Georgia, serif; }
  .room-question.is-answering .question-ring-one { animation: question-turn 700ms cubic-bezier(.2,.8,.2,1); }

  .quiet-field { position: absolute; inset: 20% 16% 19%; border: 1px solid rgba(229,220,200,0.18); }
  .quiet-bulb { position: absolute; left: 50%; top: 44%; width: clamp(1.1rem, 2.8vw, 2.4rem); aspect-ratio: 1; border: 2px solid #a18e72; border-radius: 50% 50% 44% 44%; background: var(--butter); box-shadow: 0 0 1.6rem rgba(255,217,138,0.32); translate: -50% -50%; transition: opacity 500ms ease, box-shadow 500ms ease; }
  .quiet-bulb::after { content: ""; position: absolute; left: 28%; right: 28%; bottom: -25%; height: 28%; background: #887866; }
  .quiet-pull { position: absolute; left: 50%; top: 56%; width: 1px; height: 35%; background: rgba(229,220,200,0.42); }
  .plan.is-quiet .quiet-bulb { opacity: 0.28; box-shadow: none; }

  .foyer-rings { position: absolute; left: 50%; top: 52%; width: min(68%, 11rem); aspect-ratio: 1; translate: -50% -50%; }
  .foyer-rings span { position: absolute; inset: 0; border: 1px solid rgba(237,143,85,0.22); border-radius: 50%; }
  .foyer-rings span:nth-child(2) { inset: 23%; border-color: rgba(229,220,200,0.18); }
  .foyer-rings span:nth-child(3) { inset: 41%; border-color: rgba(237,143,85,0.48); }
}

@layer state {
  body[data-power="bright"] .plan { background: radial-gradient(circle at 53% 46%, rgba(255,217,138,0.12), transparent 38%), #0f1830; }
  body[data-power="bright"] .room { filter: brightness(1.1) saturate(1.06); }
  body[data-power="bright"] .resident { box-shadow: 0 0.55rem 1.15rem var(--shadow), 0 0 2rem rgba(255,217,138,0.54); }

  .plan.is-quiet .room:not(.is-current) { filter: brightness(0.67) saturate(0.78); }
  .plan.is-quiet .draft-grid { opacity: 0.2; }

  .plan.is-complete .room.is-visited { border-color: var(--butter); }

  @media (forced-colors: active) {
    .plan, .room, .plan-key, .rewind { forced-color-adjust: auto; }
    .room { border: 3px solid CanvasText; background: Canvas; color: CanvasText; }
    .room.is-current { outline: 4px solid Highlight; }
    .resident { border: 3px solid Highlight; color: Highlight; }
    .route-canvas { display: none; }
  }
}

@layer motion {
  @keyframes rain { from { translate: 0 -80%; } to { translate: -0.7rem 250%; } }
  @keyframes resonate { to { transform: translateY(-0.38rem) rotate(-3deg); filter: brightness(1.22); } }
  @keyframes question-turn { to { rotate: 720deg; } }
  @keyframes spark-out { 0% { opacity: 0; scale: 0.2; translate: 0 0; } 20% { opacity: 1; } 100% { opacity: 0; scale: 0; translate: var(--spark-x, 0) var(--spark-y, -3rem); } }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      scroll-behavior: auto !important;
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
    }
  }
}

@layer responsive {
  @media (max-width: 46rem) {
    .draft-grid { background-size: 3rem 3rem, 3rem 3rem, 0.75rem 0.75rem, 0.75rem 0.75rem; }

    .house-foundation {
      left: 1.4%; top: 1.2%; width: 97.2%; height: 91.2%;
      clip-path: polygon(2% 2%, 46% 2%, 46% 0, 98% 0, 98% 43%, 100% 43%, 100% 98%, 54% 98%, 54% 100%, 2% 100%, 2% 68%, 0 68%, 0 5%);
      box-shadow: 0.55rem 0.7rem 1.1rem rgba(2,5,13,0.42);
    }
    .hall-time-weather { left: 45%; top: 10%; width: 7%; height: 6%; border-inline: 0; }
    .hall-weather-music { left: 71%; top: 22%; width: 6%; height: 5%; border-block: 0; }
    .hall-time-question { left: 21%; top: 22%; width: 6%; height: 26%; border-block: 0; }
    .hall-weather-foyer { left: 47%; top: 40%; width: 6%; height: 9%; border-block: 0; }
    .hall-question-foyer { left: 21%; top: 66%; width: 6%; height: 6%; border-block: 0; }
    .hall-foyer-quiet { left: 45%; top: 79%; width: 7%; height: 6%; border-inline: 0; }

    .plan-key {
      left: 0.65rem;
      right: 0.65rem;
      bottom: 0.48rem;
      width: auto;
      min-height: 3.6rem;
      padding: 0.5rem 4.2rem 0.18rem 0.55rem;
      background: linear-gradient(90deg, rgba(11,16,32,0.96), rgba(11,16,32,0.74) 82%, transparent);
    }

    .plan-key h1 { margin: 0.17rem 0 0.2rem; font-size: 1.15rem; }
    .plan-kicker, .plan-help, .location { font-size: 0.46rem; line-height: 1.25; }
    .wide-help { display: none; }
    .rewind { right: 0.35rem; bottom: 0.12rem; font-size: 0.49rem; }

    .room { --room-pad: 0.52rem; border-width: 2px; box-shadow: 0.35rem 0.45rem 0.8rem var(--shadow), inset 0 0 0 1px rgba(11,16,32,0.74); }
    .room::after { width: 1.2rem; height: 0.34rem; }
    .room-number { top: calc(var(--room-pad) + 0.92rem); font-size: 0.4rem; }
    .room-name { font-size: 0.48rem; }
    .room-reading { font-size: 0.42rem; }

    .room-time { left: 3%; top: 3%; width: 43%; height: 20%; border-radius: 0.65rem 0.15rem 0.15rem 0.2rem; }
    .room-weather { left: 51%; top: 3%; width: 46%; height: 20%; }
    .room-music { left: 12%; top: 26%; width: 76%; height: 17%; border-radius: 0.15rem; }
    .room-question { left: 3%; top: 47%; width: 43%; height: 20%; border-radius: 0.2rem; }
    .room-switch { left: 51%; top: 47%; width: 46%; height: 20%; border-radius: 0.2rem 0.65rem 0.2rem 0.2rem; }
    .room-foyer { left: 3%; top: 71%; width: 43%; height: 20%; border-radius: 0.2rem 0.2rem 0.2rem 0.65rem; }
    .room-quiet { left: 51%; top: 71%; width: 46%; height: 20%; border-radius: 0.2rem 0.2rem 0.65rem 0.2rem; }

    .room-time::after,
    .room-weather::after,
    .room-question::after,
    .room-switch::after,
    .room-quiet::after { right: auto; left: 50%; top: auto; bottom: -0.19rem; rotate: 0deg; translate: -50% 0; }
    .room-music::after { left: 25%; bottom: -0.19rem; }
    .room-foyer::after { left: 50%; top: -0.19rem; translate: -50% 0; }

    .resident { width: 2.15rem; font-size: 1.25rem; }
    .plan[data-current="time"] .resident { left: 24.5%; top: 13%; }
    .plan[data-current="weather"] .resident { left: 74%; top: 13%; }
    .plan[data-current="music"] .resident { left: 50%; top: 34.5%; }
    .plan[data-current="question"] .resident { left: 24.5%; top: 57%; }
    .plan[data-current="switch"] .resident { left: 74%; top: 57%; }
    .plan[data-current="foyer"] .resident { left: 24.5%; top: 81%; }
    .plan[data-current="quiet"] .resident { left: 74%; top: 81%; }

    .clock { left: 66%; top: 52%; width: min(42%, 5.5rem); }
    .window { left: 36%; right: 7%; top: 16%; bottom: 16%; }
    .resonators { left: 31%; right: 9%; top: 17%; bottom: 30%; }
    .resonators span { width: 1.5rem; }
    .resonators span:nth-child(2) { width: 2rem; }
    .resonators span:nth-child(3) { width: 1.2rem; }
    .resonators span:nth-child(4) { width: 1.7rem; }
    .music-wave { left: 32%; right: 10%; bottom: 16%; }
    .question-mechanism { left: 67%; top: 52%; width: min(40%, 4.7rem); }
    .switch-bank { left: 68%; top: 50%; }
    .quiet-field { left: 38%; top: 12%; right: 9%; bottom: 12%; }
    .foyer-rings { left: 67%; top: 50%; width: min(42%, 5rem); }

    .toast, .noscript-note { bottom: 8.5%; font-size: 0.5rem; }
  }

  @media (max-height: 39rem) and (min-width: 47rem) {
    .plan-key { min-height: 3.5rem; padding-top: 0.48rem; }
    .plan-key h1 { font-size: 1.22rem; margin: 0.2rem 0; }
    .room-time, .room-music { top: 3%; height: 39%; }
    .room-weather { top: 4%; height: 34%; }
    .room-question, .room-foyer, .room-quiet { top: 46%; height: 36%; }
    .room-switch { top: 28%; height: 27%; }
  }
}
