@font-face {
  font-family: Alexandria;
  src: url("./assets/fonts/alexandria-arabic-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: Alexandria;
  src: url("./assets/fonts/alexandria-latin-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0300-036F, U+2000-206F, U+20AC, U+2122;
}

:root {
  color-scheme: light;
  --font: Alexandria, "Segoe UI", Tahoma, sans-serif;
  --ink: #37264f;
  --ink-muted: #503b66;
  --edge: #fffaff;
  --focus: #503272;
  font-family: var(--font);
  background: #f2ded2;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 240px; }
button { font-family: inherit; }
[hidden] { display: none !important; }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }

.world {
  position: relative;
  isolation: isolate;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #f0dcd0;
}
.stage {
  position: absolute;
  border: 0;
  padding: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
  cursor: default;
}
.stage[data-hit] { cursor: grab; }
.stage[data-dragging] { cursor: grabbing; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage:focus-visible { outline-offset: -9px; }

.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 1.2em;
  height: 1.2em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand {
  position: absolute;
  left: clamp(24px, 4.1vw, 70px);
  top: max(clamp(22px, 4.4vh, 55px), env(safe-area-inset-top));
  display: flex;
  gap: 9px;
  align-items: center;
  height: 36px;
  font: 800 19px/1 "Trebuchet MS", system-ui, sans-serif;
  letter-spacing: .19em;
  color: #443160;
  pointer-events: none;
}
.brand img { filter: drop-shadow(0 2px 5px #8666b159); }
.frame { position: absolute; inset: 16px; pointer-events: none; }
.frame i { position: absolute; width: 18px; height: 18px; border: 1px solid #fffaffb0; }
.frame i:nth-child(1) { top: 0; left: 0; border-width: 1px 0 0 1px; }
.frame i:nth-child(2) { top: 0; right: 0; border-width: 1px 1px 0 0; }
.frame i:nth-child(3) { bottom: 0; right: 0; border-width: 0 1px 1px 0; }
.frame i:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 1px 1px; }

.loading {
  --progress: 0;
  --loader-paper: #fbefe7;
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  color: #573967;
}
.loading-cover { position: absolute; inset: 0; width: 100%; height: 100%; }
.loading-cover > rect { fill: var(--loader-paper); }
.loading-center {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(90vw, 290px);
}
.loading-sketch { width: 128px; height: 128px; overflow: visible; }
.loading-ghost { fill: #e8d9ef; stroke: #d1b8dd; stroke-width: 1.2; }
.loading-ink {
  fill: #d7bce9;
  transform: scaleY(var(--progress));
  transform-origin: 0 52px;
}
.loading-trace {
  fill: none;
  stroke: #714a88;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--progress));
}
.loading-face { fill: #734f87; opacity: calc(.24 + .76 * var(--progress)); }
.loading-face path { fill: none; stroke: #734f87; stroke-width: 1.55; stroke-linecap: round; }
.loading-face .loading-blush { stroke: #ca83b5; stroke-width: 2.8; }
.loading-counter {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: .78rem;
  font-weight: 650;
}
.loading-value { color: #765783; min-width: 3.3em; font-variant-numeric: tabular-nums; }
.loading[data-opening] .loading-center { animation: clear-mark .32s ease-in both; }
@keyframes clear-mark { to { opacity: 0; transform: scale(.95); } }

.intro {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: clamp(42px, 8vw, 170px);
  width: min(48vw, 620px);
  translate: 0 -48%;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity .48s, transform .62s cubic-bezier(.18,.7,.22,1);
}
.intro[data-active] { opacity: 1; transform: none; }
.intro[data-active] button { pointer-events: auto; }
.intro h1 { margin: 0; font-size: inherit; }
.intro-kicker {
  display: block;
  margin-bottom: 10px;
  color: #503365;
  font-size: clamp(1.1rem, 1.9vw, 1.8rem);
  font-weight: 550;
}
.intro-title {
  display: flex;
  align-items: baseline;
  gap: .20em;
  color: #35204e;
  font-size: clamp(3rem, 7vw, 8.2rem);
  line-height: .97;
  font-weight: 790;
}
.intro-ar { font-size: .60em; font-weight: 660; }
.pixi-name { display: inline-flex; letter-spacing: -.065em; padding-right: .065em; }
.pixi-name > span { position: relative; }
.pixi-name i {
  position: absolute;
  inset: 0;
  display: none;
  font-style: normal;
  text-align: center;
  color: #73548a;
}
.pixi-name .scrambling > span { visibility: hidden; }
.pixi-name .scrambling i { display: block; }
.intro-actions { display: flex; align-items: center; gap: 13px; margin-top: clamp(21px, 4vh, 37px); }

#begin, .chapter-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 7px 16px;
  color: #3d294e;
  border: 1px solid #b59dc6;
  border-radius: 23px;
  background: #e9d7f0;
  box-shadow: 0 3px 0 #a488b6;
  font: 750 .91rem/1.35 var(--font);
  white-space: nowrap;
  cursor: pointer;
  transition: transform .17s, background .17s, box-shadow .17s, opacity .23s;
}
#begin {
  padding: 9px 26px;
  min-height: 52px;
  min-width: 140px;
  font-size: 1.03rem;
  border-radius: 32px;
  background: #e5c9ef;
}
#begin:hover, .chapter-primary:hover { transform: translateY(-2px); background: #f3e0f8; box-shadow: 0 5px 0 #a488b6; }
#begin:active, .chapter-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #a488b6; }
#begin:disabled { opacity: .55; cursor: default; }
.world[data-ceremony] #begin { opacity: .32; }
.world:not([data-screen="welcome"]) .intro { display: none; }

.world-nav {
  position: absolute;
  z-index: 4;
  top: max(24px, 4.25vh);
  left: 50%; transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: 96%;
  padding: 4px;
  border: 1px solid #fffcf6;
  border-radius: 32px;
  background: #fffaf2ed;
  box-shadow: 0 4px 17px #75586e1d;
}
.world-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 37px;
  padding: 5px 11px;
  color: #59436b;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 23px;
  white-space: nowrap;
  font: 680 .79rem/1 var(--font);
  transition: background .2s, transform .2s;
}
.world-nav a .icon { width: 17px; height: 17px; }
.world-nav a[aria-current="page"] { color: #48345c; background: #eadbf2; border-color: #e1cbe9; }
.world-nav a:hover { background: #f2e0eb; transform: translateY(-1px); }
.world-nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.corner-sound {
  position: fixed;
  z-index: 21;
  top: max(clamp(20px, 4.1vh, 50px), env(safe-area-inset-top));
  right: clamp(20px, 4.1vw, 70px);
}
.round-button {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  padding: 0;
  border: 1px solid #fffaf6;
  border-radius: 50%;
  background: #fff8f0;
  color: #503961;
  cursor: pointer;
  box-shadow: 0 2px 0 #d9c2d6;
  font-size: 16px;
}
.round-button:hover { background: #f4e4f6; }
#sound .sound-off, #sound[aria-pressed="false"] .sound-on { display: none; }
#sound[aria-pressed="false"] .sound-off { display: block; }

.chapter { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.chapter-panel {
  position: absolute;
  top: 51%;
  right: clamp(30px, 7.2vw, 144px);
  width: min(40vw, 520px);
  transform: translateY(-45%);
  pointer-events: auto;
  animation: appear .36s ease both;
}
.chapter-panel h1 {
  margin: 0 0 13px;
  color: #432a52;
  font: 760 clamp(1.55rem, 3.4vw, 2.8rem)/1.22 var(--font);
}
.chapter-panel h1:focus, #request-line:focus { outline: none; }
.story-card {
  background: #fff9f2f7;
  border: 1px solid #fffdf9;
  border-radius: 26px;
  padding: clamp(15px, 2.1vw, 26px);
  box-shadow: 0 12px 30px #78586d2e;
}
.story-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
#request-step {
  margin: 0;
  color: #70517c;
  font-size: .76rem;
  font-weight: 720;
}
.story-header .round-button { width: 35px; height: 35px; background: #f1e3f5; box-shadow: none; }
.story-header .round-button:disabled { opacity: .47; cursor: default; }
#request-line {
  margin: 7px 0 14px;
  color: #3f2b50;
  font: 680 clamp(.96rem, 1.55vw, 1.24rem)/1.75 var(--font);
}
.request-prompt { margin: 0 0 8px; color: #685371; font-size: .82rem; font-weight: 680; }
.request-choices { display: grid; gap: 7px; }
.request-choices button {
  padding: 8px 11px;
  min-height: 42px;
  background: #f5ebf7;
  border: 1px solid #e5d4ec;
  border-radius: 13px;
  color: #4f3864;
  text-align: start;
  font: 675 .85rem/1.4 var(--font);
  cursor: pointer;
}
.request-choices button:hover { background: #ecdbf0; }
.request-choices button[data-right] { color: #284e3f; border-color: #a8c5ae; background: #dfefe4; }
.request-choices button[data-retry] { color: #794440; border-color: #dfb3ae; background: #f7e4e0; }
.request-choices button:disabled { cursor: default; opacity: 1; }
#request-feedback { margin: 10px 0 0; font: 630 .82rem/1.5 var(--font); color: #634973; }
.request-next { margin-top: 13px; min-height: 41px; }
.world:is([data-screen="surprise"], [data-screen="home"], [data-screen="design"]) .stage { visibility: hidden; }
.world[data-screen="home"] .brand { z-index: 3; }
.world[data-screen="home"]::after { display: none; }
.home-chapter {
  position: absolute;
  z-index: 2;
  inset: 0;
}
.home-room {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #ead9e7;
}
.home-room canvas { width: 100%; height: 100%; display: block; }
.home-transition {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(ellipse at center, #fae8ec, #ecd6ea);
}
.home-transition svg { width: clamp(68px, 11vw, 140px); fill: #d1b0e5; stroke: #b387cd; stroke-width: 1.5; }
.world[data-home-reveal] .home-transition { display: grid; }
.world[data-home-reveal="covering"] .home-transition { animation: home-cover .24s ease-in both; }
.world[data-home-reveal="revealing"] .home-transition { animation: home-reveal .66s ease-out both; }
@keyframes home-cover { from { opacity: 0; } to { opacity: 1; } }
@keyframes home-reveal {
  0% { opacity: 1; }
  25% { opacity: .85; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .world[data-home-reveal="revealing"] .home-transition,
  .world[data-home-reveal="covering"] .home-transition { display: none; }
}
.home-actions {
  position: absolute;
  inset-inline: 0;
  bottom: max(12px, 2.7vh, env(safe-area-inset-bottom));
  margin-inline: auto;
  width: min(94%, 710px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.4vw, 16px);
}
.home-actions button {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  min-height: clamp(48px, 8.8vh, 80px);
  padding: 8px 4px;
  border: 1px solid var(--action-border);
  border-radius: clamp(12px, 2vw, 22px);
  background: var(--action-color);
  box-shadow: 0 3px 0 var(--action-border);
  color: #473353;
  font: 760 clamp(.94rem, 2.5vw, 1.4rem)/1.2 var(--font);
  cursor: pointer;
}
.home-actions [data-home-action="dance"] { --action-color: #f3cde0; --action-border: #dba6c3; }
.home-actions [data-home-action="sleep"] { --action-color: #e4d5f5; --action-border: #c6afe7; }
.home-actions [data-home-action="jump"] { --action-color: #e5ccfa; --action-border: #c3a1e1; }
.home-actions button:hover { filter: brightness(1.04); }
.home-actions button:disabled { cursor: default; opacity: .76; }
.home-actions [data-home-action="sleep"][data-awake-toggle] { --action-color: #ffebc7; --action-border: #dbb98e; }
.home-actions button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px #725781, 0 3px 0 var(--action-border); }
.home-actions .icon { width: 1.22em; height: 1.22em; }
@media (max-width: 380px) {
  .world .world-nav a { gap: 4px; padding-inline: 6px; }
}
@media (max-width: 340px) {
  .world .world-nav a .icon { display: none; }
}
.world[data-screen="surprise"] .brand { z-index: 3; }
.maze {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 24% 45%, #efe0f4, #f7ede4 84%);
  color: #3f294d;
}
.world[data-screen="surprise"]::after { display: none; }
.maze-shell {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.8vh, 17px);
  width: min(96%, 1540px);
  margin-inline: auto;
  padding: max(99px, 11.7vh) 0 clamp(12px, 2.4vh, 24px);
  opacity: 1;
  transition: opacity .72s ease;
}
.maze[data-phase="intro"] .maze-shell { pointer-events: none; }
.maze[data-phase="intro"] { background: #260710; }
.maze[data-phase="intro"] .maze-heading { opacity: 0; }
.maze[data-phase="intro"] .maze-map { visibility: hidden; }
.maze-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}
.maze-title { display: flex; align-items: center; gap: clamp(13px, 2vw, 28px); }
.maze-heading h1 {
  margin: 0;
  color: #432a52;
  font-size: clamp(1.3rem, 2.5vw, 2.2rem);
  line-height: 1.2;
  font-weight: 790;
}
.maze-heading h1:focus, #maze-prompt:focus { outline: none; }
#maze-instruction {
  margin: 0;
  padding: 7px 13px;
  border: 1px solid #e3cce9;
  border-radius: 22px;
  background: #fffaf3e8;
  color: #59406b;
  font-size: clamp(.78rem, 1.1vw, 1rem);
  font-weight: 720;
}
.maze-progress {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid #dfc7e7;
  border-radius: 24px;
  background: #fff9f3e8;
  color: #655071;
  font-size: clamp(.74rem, 1vw, .9rem);
  font-weight: 660;
  white-space: nowrap;
}
.maze-progress strong { font-size: 1rem; color: #523367; font-variant-numeric: tabular-nums; }
.maze-map {
  position: relative;
  width: 100%;
  max-width: 1380px;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  align-self: center;
  margin: 0;
  overflow: hidden;
  border: 1px solid #fff9ff;
  border-radius: clamp(16px, 2.2vw, 28px);
  background: #e9d7ef;
  box-shadow: 0 16px 38px #8061912b, inset 0 1px #fff;
}
.maze-canvas { position: absolute; inset: 0; }
.maze-canvas canvas { width: 100%; height: 100%; display: block; }
.maze-canvas[data-fallback] { display: grid; place-items: center; color: #603b75; font-weight: 730; }
.maze-canvas[data-fallback]::after { content: "متاهة بيكسي • ١ • ٢ • ٣"; }
.maze-modal-backdrop, .maze-victory {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}
.maze-modal-backdrop { background: #30243c75; backdrop-filter: blur(5px) brightness(.78); }
.maze-modal {
  width: min(100%, 760px);
  max-height: min(88vh, 780px);
  overflow: auto;
  padding: clamp(22px, 3vw, 42px);
  border: 1px solid #fff;
  border-radius: clamp(20px, 2.4vw, 32px);
  background: linear-gradient(145deg, #fffdf8, #f8eff9);
  box-shadow: 0 24px 70px #1c102c4a, inset 0 1px #fff;
  animation: modal-arrive .42s cubic-bezier(.18,.76,.22,1) both;
}
.maze-step { margin: 0 0 12px; color: #795890; font-size: clamp(.88rem, 1.4vw, 1.08rem); font-weight: 760; }
#maze-prompt { margin: 0; color: #342541; font-size: clamp(1.2rem, 2vw, 1.75rem); line-height: 1.65; font-weight: 730; }
.maze-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 11px; margin-top: 22px; }
.maze-options button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: clamp(58px, 7.3vh, 76px);
  padding: 10px 15px;
  text-align: right;
  border: 1px solid #dfcde7;
  border-radius: 16px;
  background: #f5edf8;
  color: #493453;
  font: 680 clamp(1.05rem, 1.65vw, 1.42rem)/1.45 var(--font);
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .2s;
}
.maze-options button:hover { transform: translateY(-1px); background: #eddef5; }
.maze-choice-label {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  min-width: 2em;
  height: 2em;
  border-radius: 9px;
  background: #e8d8f0;
  font: inherit;
}
.maze-options button[data-wrong] { border-color: #d99491; background: #fae1dc; color: #773f43; animation: answer-shake .34s ease; }
.maze-options button[data-correct] { border-color: #8db99a; background: #dff0e3; color: #315d43; }
.maze-feedback { margin: 16px 0 0; color: #654b6d; font-size: clamp(.94rem, 1.25vw, 1.08rem); line-height: 1.6; font-weight: 680; }
.maze-victory { background: radial-gradient(ellipse at center, #fff5d4dd, #46305a83); backdrop-filter: blur(3px); }
.victory-card {
  width: min(100%, 820px);
  padding: clamp(25px, 4vw, 58px);
  border: 1px solid #fff;
  border-radius: clamp(22px, 3vw, 36px);
  background: linear-gradient(145deg, #fffaf1, #f1e4f8 58%, #e0f2e4);
  box-shadow: 0 24px 70px #2c18384a;
  text-align: center;
  animation: modal-arrive .65s cubic-bezier(.18,.76,.22,1) both;
}
.victory-kicker { margin: 0 0 15px; color: #72518a; font: 850 clamp(1.2rem, 3vw, 2rem)/1.2 var(--font); letter-spacing: .11em; }
.victory-card h2 { margin: 0; color: #50335e; font-size: clamp(1.55rem, 3.6vw, 2.8rem); line-height: 1.45; }
.victory-dialogue { max-width: 630px; margin: 15px auto 0; color: #654d6e; font-size: clamp(1.05rem, 1.8vw, 1.4rem); line-height: 1.75; font-weight: 650; }
#request-summary { margin: 18px 0 0; color: #5a3e6e; }
#request-summary h3 { margin: 0 0 5px; font-size: .9rem; }
#request-summary ul { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px 20px; margin: 0; padding-inline-start: 20px; font-size: .82rem; }
.maze-go-home { margin-top: 23px; }

.emergency-scene {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: end center;
  overflow: hidden;
  padding: 22px;
  color: #fff4f0;
  isolation: isolate;
  background: radial-gradient(ellipse at 50% 53%, #20060b08 16%, #21070ec4 82%);
  opacity: 1;
  transition: opacity .78s ease;
}
.maze:not([data-phase="intro"]) .emergency-scene { opacity: 0; pointer-events: none; }
.emergency-scene::before, .emergency-scene::after,
.emergency-beacons, .emergency-signal { position: absolute; inset: 0; pointer-events: none; }
.emergency-scene::before {
  content: "";
  background: radial-gradient(ellipse at 50% 53%, transparent 33%, #ec192e69 100%);
  box-shadow: inset 0 0 clamp(46px, 10vw, 150px) #dd062e99;
  opacity: calc(.52 + var(--alarm-glow, .25) * .36);
}
.emergency-scene::after {
  content: "";
  inset: clamp(12px, 2.3vw, 38px);
  border: 1px dashed #ff596d;
  border-radius: clamp(14px, 2vw, 28px);
  box-shadow: 0 0 25px #ff193b59, inset 0 0 22px #ff193b40;
  opacity: .68;
}
.emergency-beacons {
  inset: -90% -70%;
  background: conic-gradient(from 20deg at 50% 50%,
    transparent 0deg 16deg, #ff26385c 34deg, #ff263824 65deg, transparent 105deg 184deg,
    #ff344a56 209deg, #ff344a19 238deg, transparent 272deg);
  opacity: calc(.64 + var(--alarm-glow, .25) * .26);
}
.emergency-signal {
  background: repeating-linear-gradient(0deg, transparent 0 8px, #ffadbb18 9px 10px);
  mask-image: radial-gradient(ellipse at center, #0005 15%, #000 82%);
}
.emergency-signal::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 23%, #ff556b33 23% 24%, transparent 24% 76%, #ff62772b 76% 77%, transparent 77%);
}
.emergency-scene[aria-hidden="false"]::after { animation: emergency-edge 3.4s ease-in-out infinite; }
.emergency-scene[aria-hidden="false"] .emergency-beacons { animation: alarm-turn 9s linear infinite; }
.emergency-scene[aria-hidden="false"] .emergency-signal { animation: emergency-glitch .52s ease-out both; }
.emergency-scene[aria-hidden="false"] .emergency-signal::after { animation: emergency-drift 7s ease-in-out infinite; }
.emergency-scene[aria-hidden="true"] :is(.emergency-signal, .emergency-beacons) { visibility: hidden; }
.emergency-message {
  position: absolute;
  inset: max(94px, 10.5vh) 0 max(24px, 4vh);
  margin-inline: auto;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: clamp(4px, 1vh, 10px);
  justify-items: center;
  width: min(680px, 92vw);
  text-align: center;
}
.emergency-scene[aria-hidden="false"] .emergency-message { animation: emergency-reveal .58s ease-out both; }
.emergency-mark { width: clamp(52px, 7vw, 82px); height: auto; fill: none; stroke: #ff6b73; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 14px #f51c4199); }
.emergency-label { margin: 0; color: #fff1ed; font-size: clamp(2rem, 4vw, 3.4rem); font-weight: 850; text-shadow: 0 4px 24px #e51d4073; }
.emergency-character {
  position: relative;
  width: min(100%, 620px);
  align-self: stretch;
  mask-image: linear-gradient(transparent, #000 7% 93%, transparent),
    linear-gradient(90deg, transparent, #000 7% 93%, transparent);
  mask-composite: intersect;
}
.emergency-character .maze-canvas { pointer-events: none; }
.emergency-bubble {
  max-width: 100%;
  padding: clamp(14px, 2vw, 23px) clamp(17px, 2.7vw, 34px);
  border: 1px solid #ffe6e4aa;
  border-radius: 23px;
  background: #fff8f1f2;
  box-shadow: 0 12px 36px #16050c6b;
  color: #4e2539;
  font-size: clamp(1rem, 1.65vw, 1.38rem);
  line-height: 1.8;
  font-weight: 690;
}
.emergency-primary {
  min-height: 57px;
  padding: 10px 29px;
  border: 1px solid #ffaaa3;
  border-radius: 32px;
  background: linear-gradient(135deg, #ffb08e, #f87978);
  box-shadow: 0 5px 0 #b3475a, 0 12px 30px #dc36565c;
  color: #401b35;
  font: 790 clamp(1rem, 1.45vw, 1.2rem)/1.35 var(--font);
  cursor: pointer;
  transition: transform .18s, filter .18s;
}
.emergency-primary:hover { transform: translateY(-2px); filter: brightness(1.07); }
.emergency-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #b3475a; }

@keyframes alarm-turn { to { transform: rotate(360deg); } }
@keyframes emergency-edge { 0%, 100% { opacity: .55; } 36% { opacity: .9; } 58% { opacity: .72; } 74% { opacity: .82; } }
@keyframes emergency-reveal { from { opacity: .55; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes emergency-glitch {
  0% { transform: translateX(-12px) skewX(-5deg); clip-path: inset(8% 0 40%); }
  36% { transform: translateX(8px) skewX(3deg); clip-path: inset(30% 0 10%); }
  100% { transform: none; clip-path: inset(0); }
}
@keyframes emergency-drift { 0%, 100% { transform: translateY(-4%); } 50% { transform: translateY(9%); } }
@keyframes modal-arrive { from { opacity: 0; transform: scale(.92) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes answer-shake { 20%, 60% { transform: translateX(6px); } 40%, 80% { transform: translateX(-6px); } }

@media (max-width: 759px), (max-aspect-ratio: 999/1000) {
  .maze-shell { width: 94%; padding-top: max(105px, calc(env(safe-area-inset-top) + 96px)); padding-bottom: max(10px, env(safe-area-inset-bottom)); gap: 9px; }
  .maze-heading { align-items: center; gap: 7px; }
  .maze-title { display: block; }
  .maze-heading h1 { font-size: clamp(1.05rem, 4.4vw, 1.45rem); }
  #maze-instruction { margin-top: 5px; padding: 5px 8px; font-size: .68rem; }
  .maze-progress { display: grid; justify-items: center; gap: 0; padding: 5px 8px; font-size: .63rem; }
  .maze-progress strong { font-size: .8rem; }
  .maze-map { border-radius: 15px; }
  .emergency-scene { padding: 14px; }
  .emergency-message { width: min(590px, 90vw); top: max(108px, calc(env(safe-area-inset-top) + 98px)); bottom: max(20px, env(safe-area-inset-bottom)); }
  .emergency-bubble { border-radius: 18px; font-size: clamp(.87rem, 3.2vw, 1.1rem); line-height: 1.7; }
  .emergency-primary { min-height: 49px; padding-inline: 23px; }
  .maze-modal-backdrop, .maze-victory { padding: 13px; }
  .maze-modal { padding: 21px 17px; border-radius: 20px; }
  .maze-options { gap: 8px; margin-top: 15px; }
  .maze-options button { gap: 6px; min-height: 54px; padding: 8px 10px; border-radius: 13px; }
  .maze-feedback { margin-top: 11px; font-size: .9rem; }
  .victory-card { padding: 27px 19px; border-radius: 22px; }
  .victory-kicker { font-size: 1.05rem; }
  .victory-card h2 { font-size: clamp(1.35rem, 6vw, 1.8rem); }
  .victory-dialogue { font-size: .98rem; }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .maze-shell { padding-top: 68px; padding-bottom: 8px; gap: 5px; }
  .maze-heading h1 { font-size: 1.2rem; }
  .maze-map { max-width: 1160px; }
  .emergency-message { top: 63px; bottom: 13px; }
  .emergency-mark { width: 42px; }
  .emergency-label { font-size: 1.8rem; }
  .emergency-bubble { padding-block: 9px; font-size: .91rem; }
  .emergency-primary { min-height: 41px; }
}
@media (prefers-reduced-motion: reduce) {
  .maze-shell, .emergency-scene, .emergency-primary { transition: none; }
  .emergency-scene[aria-hidden="false"]::after,
  .emergency-scene[aria-hidden="false"] :is(.emergency-beacons, .emergency-signal, .emergency-message),
  .emergency-scene[aria-hidden="false"] .emergency-signal::after,
  .maze-modal, .victory-card, .maze-options button[data-wrong] { animation: none; }
  .emergency-scene { --alarm-glow: .25 !important; }
}

@media (min-width: 760px) and (min-aspect-ratio: 1/1) {
  .world::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent 52%, #f7e7d9f2 100%);
  }
  .intro { right: clamp(42px, 8vw, 170px); }
}
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 759px), (max-aspect-ratio: 999/1000) {
  .frame { inset: 11px; }
  .brand { top: max(13px, env(safe-area-inset-top)); font-size: 15px; gap: 7px; }
  .brand img { width: 19px; height: 19px; }
  .corner-sound { top: max(14px, env(safe-area-inset-top)); width: 34px; height: 34px; }
  .world-nav { top: max(59px, calc(env(safe-area-inset-top) + 49px)); }
  .world-nav a { min-height: 33px; padding: 4px 9px; font-size: .72rem; }
  .world-nav a .icon { width: 15px; height: 15px; }
  .world::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(transparent 55%, #f0decfc9 74%, #f4e2d5 92%);
  }
  .intro {
    top: auto;
    bottom: max(8vh, calc(env(safe-area-inset-bottom) + 23px));
    left: 50%;
    right: auto;
    width: min(91%, 550px);
    translate: -50% 0;
    text-align: center;
  }
  .intro-title, .intro-actions { justify-content: center; }
  .intro-title { font-size: clamp(3rem, 11vw, 5.5rem); }
  .intro-actions { margin-top: 17px; }
  .chapter-panel {
    top: auto; right: 50%;
    bottom: max(17px, calc(env(safe-area-inset-bottom) + 10px));
    width: min(93%, 520px); max-height: 44vh;
    transform: translateX(50%);
    overflow: auto;
    border-radius: 22px;
    scrollbar-width: thin;
  }
  .chapter-panel h1 { font-size: 1.32rem; margin: 0 2px 7px; }
  .story-card { padding: 12px; border-radius: 19px; }
  #request-line { font-size: .89rem; margin-bottom: 8px; }
  #request-step, .request-prompt, #request-feedback { font-size: .72rem; }
  .request-choices button { min-height: 36px; font-size: .76rem; padding-block: 6px; }
  .request-next { margin-top: 8px; }
}
@media (max-width: 330px) {
  .world-nav a { gap: 4px; padding-inline: 6px; font-size: .67rem; }
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  .world-nav { top: 13px; }
  .intro-kicker { font-size: .96rem; }
  .intro-title { font-size: clamp(2.85rem, 6vw, 4.4rem); }
  .intro-actions { margin-top: 15px; }
  #begin { min-height: 40px; min-width: 122px; font-size: .9rem; }
  .chapter-panel { top: 60%; max-height: 75vh; overflow: auto; scrollbar-width: thin; }
  .chapter-panel h1 { font-size: 1.19rem; margin-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .intro, #begin, .chapter-primary, .world-nav a { transition: none; }
  .loading[data-opening] .loading-center, .chapter-panel { animation: none; }
}


#emotions { color: #432a52; }
#emotions .room-sr {
  position: absolute;
  overflow: hidden;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
}
#emotions .room-dialogue {
  position: absolute;
  z-index: 4;
  top: 53%;
  right: 6%;
  width: min(35vw, 520px);
  transform: translateY(-32%);
  pointer-events: none;
}
#emotions #request-line {
  position: relative;
  margin: 0;
  padding: clamp(14px, 1.65vw, 24px);
  border-radius: 30px 30px 13px 30px;
  background: #fff6ebf2;
  box-shadow: 0 8px 26px #593d5e21, inset 0 1px #fffdf8;
  font: 690 clamp(1.16rem, 1.9vw, 2rem)/1.55 var(--font);
}
#emotions #request-line::after {
  content: "";
  position: absolute;
  left: -12px;
  top: 42%;
  width: 24px;
  height: 23px;
  border-radius: 5px;
  rotate: 45deg;
  background: #fff6ebf2;
}
#emotions[data-phase="opening"] .room-dialogue { top: 42%; }
#emotions[data-phase="opening"] #request-line { animation: room-rise .55s both; }
#emotions #request-comparison, #emotions #request-feedback, #emotions .room-flight {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: 13px;
  background: #ead9f3f2;
  box-shadow: 0 3px 13px #69498522;
  color: #432a52;
  font: 680 clamp(.95rem, 1.5vw, 1.4rem)/1.55 var(--font);
}
#emotions #request-comparison { animation: room-rise .4s both; }
#emotions #request-feedback { background: #fff0e4ed; }
#emotions .room-flight { position: fixed; z-index: 7; pointer-events: none; margin: 0; }
#emotions #next, #emotions .room-controls button {
  cursor: pointer;
  pointer-events: auto;
  color: #4a325d;
  background: #f7e6f7;
  border: 1px solid #fff8fb;
  border-radius: 30px;
  font: 690 .85rem/1.4 var(--font);
}
#emotions #next {
  margin-top: 10px;
  min-height: 44px;
  padding: 6px 16px;
  box-shadow: 0 3px 0 #b99aca, 0 7px 18px #5f49782c;
  font-size: clamp(.87rem, 1.16vw, 1.08rem);
}
#emotions #next:hover, #emotions .room-controls button:hover { background: #fff5fb; }
#emotions .room-controls {
  position: absolute;
  z-index: 5;
  right: 3%;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
}
#emotions .room-controls button { padding: 6px 10px; min-height: 34px; background: #fff3e9ed; }
#emotions .room-controls button:disabled { opacity: .52; cursor: default; }
#emotions .room-spot {
  position: absolute;
  left: var(--spot-x, 44%);
  top: var(--spot-y, 43%);
  display: grid;
  place-items: center;
  width: 1px;
  height: 1px;
  direction: ltr;
  z-index: 2;
}
#emotions .room-spot[data-current] { z-index: 3; }
#emotions .room-objects, #emotions .room-marker { position: absolute; }
#emotions .room-objects { display: flex; gap: clamp(6px, .9vw, 14px); align-items: end; }
#emotions .room-objects:empty { display: none; }
#emotions .room-objects:not(:empty) {
  position: fixed;
  align-items: end;
  animation: room-rise .38s both;
}
#emotions [data-spot="theme"] .room-objects {
  bottom: 4%;
  left: 50%;
  translate: -50% 0;
  gap: clamp(14px, 3vw, 50px);
  padding: 5px 20px 12px;
  background: linear-gradient(0deg, #f7e8f4ed, #f7e8f420 75%, transparent);
  border-radius: 45%;
  box-shadow: 0 10px 16px -15px #624381bb;
}
#emotions [data-spot="decor"] .room-objects {
  top: 19%;
  right: 5%;
  gap: clamp(13px, 2.3vw, 38px);
}
#emotions [data-spot="sky"] .room-objects {
  left: 3%;
  top: 49%;
  align-items: center;
  flex-direction: column;
  gap: clamp(4px, 1vh, 10px);
}
#emotions [data-spot] .room-objects[data-exit] {
  animation: room-dismiss .23s ease-in both;
  pointer-events: none;
}
@keyframes room-dismiss {
  to { opacity: 0; transform: translateY(8px) scale(.92); }
}
#emotions .room-object, #emotions .room-skip {
  position: relative;
  cursor: pointer;
  pointer-events: auto;
  color: #432a52;
  direction: rtl;
  font: 720 clamp(.79rem, 1.35vw, 1.2rem)/1.28 var(--font);
}
#emotions .room-object {
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 43px;
  padding: 0;
  border: none;
  background: transparent;
  white-space: nowrap;
  animation: room-rise .55s both;
}
#emotions .room-object:nth-child(2) { animation-delay: .09s; }
#emotions .room-object:nth-child(3) { animation-delay: .18s; }
#emotions .room-object svg {
  display: block;
  width: clamp(45px, 6.2vw, 104px);
  filter: drop-shadow(0 7px 5px #714c7059);
  transition: transform .2s, filter .2s;
}
#emotions .room-object:hover svg { transform: translateY(-5px); }
#emotions .room-object:active svg { transform: translateY(3px) scale(.95); }
#emotions .room-object[aria-pressed="true"] svg {
  filter: drop-shadow(0 0 8px #fff7c7) drop-shadow(0 4px 6px #85559989);
}
#emotions [data-spot="theme"] .room-object svg { width: clamp(59px, 6.4vw, 110px); }
#emotions [data-spot="theme"] .room-object span,
#emotions [data-spot="decor"] .room-object span,
#emotions [data-spot="sky"] .room-object span {
  background: #fff3e8f2;
  border-radius: 16px;
  padding: 3px 9px;
}
#emotions [data-spot="decor"] .room-object svg { width: clamp(50px, 6vw, 100px); }
#emotions [data-spot="decor"] .room-object:nth-child(2) { translate: 0 -12px; }
#emotions [data-spot="sky"] .room-object {
  grid-template-columns: auto auto;
  align-items: center;
  justify-self: start;
  direction: ltr;
}
#emotions [data-spot="sky"] .room-object svg { width: clamp(44px, 4.9vw, 80px); }
#emotions .room-object[aria-pressed="true"] span { box-shadow: inset 0 0 0 2px #9976ab; }
#emotions .room-decoration {
  position: absolute;
  z-index: 2;
  left: var(--spot-x);
  top: var(--spot-y);
  translate: -50% -100%;
  width: clamp(48px, 5vw, 77px);
  filter: drop-shadow(0 4px 4px #754b6c55);
}
#emotions .room-decoration svg { display: block; width: 100%; animation: room-rise .6s both; }
#emotions .room-marker {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 20px;
  background: #f7e0f2;
  box-shadow: 0 2px 6px #6d4a6a65, 0 0 14px #ffedbf;
  color: #35624d;
  font-size: .86rem;
}
#emotions .room-marker svg { width: 22px; }
#emotions .room-marker:not([data-confirmed]) {
  padding: 0;
  background: none;
  box-shadow: none;
}
#emotions .room-marker i {
  width: 15px;
  height: 15px;
  background: #fff6db;
  border: 1px solid #a67cb3;
  border-radius: 45% 50% 45% 50%;
  rotate: 45deg;
  box-shadow: 0 0 9px 3px #fff0bc;
  animation: room-glow 2.6s ease-in-out infinite;
}
#emotions [data-spot="decor"] .room-marker i { animation-delay: .4s; }
#emotions [data-spot="sky"] .room-marker i { animation-delay: .8s; }
#emotions .room-particles { position: absolute; inset: 36% auto auto 30%; z-index: 3; }
#emotions .room-effect { position: absolute; display: block; pointer-events: none; }
#emotions .room-effect i {
  position: absolute;
  left: calc((var(--i) - 2) * clamp(17px, 2.9vw, 47px));
  bottom: calc(var(--i) * 4px);
  color: #8b4b99;
  font: 780 clamp(1.15rem, 2.9vw, 2.8rem)/1 var(--font);
  text-shadow: 0 0 8px #fff3ef, 0 2px 1px #fff7e5;
  animation: room-spark 1.35s calc(.09s * var(--i)) both;
}
#emotions [data-effect="magic"] i { color: #9a641f; }
#emotions [data-effect="magic"] { bottom: 54%; }
#emotions .room-trail { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
#emotions .room-trail polyline {
  fill: none;
  stroke: #fff0bd;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 6 9;
  filter: drop-shadow(0 0 5px #b671b2);
}
#emotions[data-phase="gather"] .room-trail { animation: room-trail 1.45s both; }
#emotions[data-phase="summary"] .room-spot { visibility: hidden; }
#emotions .room-summary {
  position: absolute;
  z-index: 6;
  top: var(--final-top);
  right: var(--final-right);
  width: var(--final-width);
  rotate: -1.4deg;
  font: 560 clamp(.86rem, 1.2vw, 1.13rem)/1.45 var(--font);
}
#emotions .room-file-paper {
  position: relative;
  padding: clamp(16px, 1.85vw, 29px);
  border: 1px solid #f9eaf9;
  border-radius: 22px 14px 25px 32px / 16px 23px 20px 27px;
  background: linear-gradient(146deg, #fff4df 4%, #fbefee 54%, #efe0f5);
  box-shadow: 0 19px 34px #67486338, inset 0 0 0 4px #fff5e68f;
  animation: room-file-unfold .55s .78s both;
}
#emotions .room-file-paper::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px dashed #ad86b67a;
  border-radius: inherit;
  pointer-events: none;
}
#emotions .room-file-paper::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: -1px;
  width: 36px;
  height: 26px;
  border-radius: 0 13px 0 25px;
  background: linear-gradient(145deg, #e2c8e9, #fff4e6 54%, #d5b5df);
  box-shadow: 2px -2px 4px #865b9334;
  clip-path: polygon(0 100%, 18% 65%, 26% 25%, 55% 10%, 100% 0, 74% 53%, 64% 82%, 43% 100%);
}
#emotions .room-file-clip {
  position: absolute;
  z-index: 1;
  top: -12px;
  right: 22%;
  width: 27px;
  height: 23px;
  border-radius: 6px 7px 4px 4px;
  border: 2px solid #ba92c5;
  background: linear-gradient(#f6d8ed, #d7acd8);
  box-shadow: 0 3px 5px #704a7938;
  rotate: 9deg;
}
#emotions .room-file-clip::after {
  content: "";
  position: absolute;
  top: -8px;
  inset-inline: 6px;
  height: 15px;
  border: 2px solid #9872a6;
  border-radius: 6px 6px 3px 3px;
}
#emotions .room-summary h2 {
  margin: 0 0 7px;
  padding-block-end: 5px;
  font-size: clamp(1.17rem, 1.95vw, 1.8rem);
  animation: room-file-ink .32s 1.05s both;
}
#emotions .room-summary h2::after {
  content: "";
  position: absolute;
  left: 25px;
  top: 33px;
  width: 23px;
  height: 9px;
  border-top: 2px solid #bd95bc;
  border-radius: 60%;
  rotate: -17deg;
}
#emotions .room-summary h2 span {
  background: linear-gradient(transparent 62%, #dfb8e8 62% 90%, transparent 90%);
}
#emotions .room-summary ol { margin: 0; padding: 0; list-style: none; }
#emotions .room-summary li {
  display: grid;
  grid-template-columns: 2em 1fr 24px;
  gap: 9px;
  align-items: center;
  padding: 6px 8px;
  background: #fff9f46b;
  border-radius: 9px 13px 10px 12px;
  animation: room-file-ink .36s calc(1.22s + var(--row) * .17s) both;
}
#emotions .room-summary li + li { margin-top: 4px; }
#emotions .room-file-number {
  justify-self: center;
  min-width: 1.85em;
  padding: 2px 4px;
  border-radius: 8px 6px 9px 7px;
  background: #e9d3ee;
  color: #684a78;
  text-align: center;
  font-weight: 720;
  rotate: -5deg;
}
#emotions .room-summary li:nth-child(2) .room-file-number { background: #f2d7df; rotate: 4deg; }
#emotions .room-summary li:nth-child(3) .room-file-number { background: #e1e9d7; }
#emotions .room-summary h3, #emotions .room-summary p { margin: 0; font-size: inherit; }
#emotions .room-file-symbol { color: #90659d; }
#emotions .room-file-symbol svg {
  display: block;
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#emotions .room-file-flight {
  position: fixed;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 20px;
  color: #35624d;
  background: #f7e0f2;
  box-shadow: 0 0 14px #ffedbf;
  pointer-events: none;
}
#emotions .room-file-flight svg { width: 22px; }
#emotions .room-file-glints i {
  position: absolute;
  right: -13px;
  top: 23%;
  width: 14px;
  height: 14px;
  background: #e8b8dc;
  clip-path: polygon(50% 0, 63% 36%, 100% 50%, 63% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
  animation: room-file-glint .75s 1.82s both;
}
#emotions .room-file-glints i:nth-child(2) { right: auto; left: -12px; top: 70%; background: #f9dd9a; }
#emotions .room-file-glints i:nth-child(3) { right: -19px; top: 37%; width: 5px; height: 5px; border-radius: 50%; clip-path: none; }
@keyframes room-file-unfold {
  from { opacity: 0; clip-path: inset(8% -20px 83% round 22px); }
  to { opacity: 1; clip-path: inset(-20px -30px -35px round 26px); }
}
@keyframes room-file-ink {
  from { opacity: 0; translate: 0 5px; }
  to { opacity: 1; translate: 0 0; }
}
@keyframes room-file-glint {
  0%, 100% { opacity: 0; scale: .4; }
  42% { opacity: 1; scale: 1.2; }
}
#emotions {
  --final-top: max(104px, 15%);
  --final-right: clamp(18px, 4.5vw, 86px);
  --final-width: min(36vw, 555px);
}
#emotions[data-phase="summary"] {
  display: grid;
  grid-template-columns: var(--final-width) minmax(0, 1fr);
  grid-template-rows: max-content max-content;
  align-content: start;
  gap: clamp(12px, 3vh, 34px);
  padding: var(--final-top) var(--final-right) 58px;
}
#emotions[data-phase="summary"] .room-summary,
#emotions[data-phase="summary"] .room-dialogue {
  grid-column: 1;
  position: relative;
  inset: auto;
  width: 100%;
  transform: none;
}
#emotions[data-phase="summary"] .room-summary { grid-row: 1; }
#emotions[data-phase="summary"] .room-dialogue { grid-row: 2; }
#emotions[data-phase="summary"] #request-line {
  font-size: clamp(.94rem, 1.66vw, 1.56rem);
  padding: clamp(9px, 1.15vw, 20px);
}
@media (max-height: 650px) and (min-aspect-ratio: 1/1) {
  #emotions { --final-top: 88px; }
  #emotions .room-file-paper { padding: 12px 15px; }
  #emotions .room-summary { font-size: .81rem; }
  #emotions .room-summary h2 { font-size: 1.2rem; margin-bottom: 4px; }
  #emotions .room-summary li { padding-block: 3px; }
}
@media (max-aspect-ratio: 999/1000) {
  #emotions { --final-top: max(267px, 48%); }
  #emotions[data-phase="summary"] {
    grid-template-columns: minmax(0, 385px);
    grid-template-rows: max-content 1fr max-content;
    justify-content: center;
    align-content: stretch;
    gap: 0;
    padding: var(--final-top) 5% max(55px, calc(env(safe-area-inset-bottom) + 50px));
  }
  #emotions[data-phase="summary"] .room-summary,
  #emotions[data-phase="summary"] .room-dialogue { grid-column: 1; }
  #emotions[data-phase="summary"] .room-dialogue { grid-row: 3; }
  #emotions .room-summary { font-size: clamp(.74rem, 2.9vw, .91rem); }
  #emotions .room-file-paper { padding: 11px 13px; }
  #emotions .room-summary h2 { font-size: clamp(1rem, 4vw, 1.31rem); margin-bottom: 4px; }
  #emotions .room-summary li { padding: 2px 5px; gap: 6px; grid-template-columns: 2em 1fr 17px; }
  #emotions .room-summary li + li { margin-top: 2px; }
  #emotions .room-file-symbol svg { width: 17px; }
}
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  #emotions { --final-top: 76px; --final-width: min(43vw, 450px); }
  #emotions[data-phase="summary"] { gap: 10px; }
  #emotions .room-file-paper { padding: 8px 12px; }
  #emotions .room-summary { line-height: 1.24; }
  #emotions .room-summary h2 { padding-block-end: 2px; }
  #emotions .room-summary li { padding-block: 2px; }
  #emotions .room-summary li + li { margin-top: 2px; }
  #emotions .room-summary li div { display: contents; }
  #emotions .room-summary li { grid-template-columns: 2em minmax(42px, max-content) 1fr; gap: 6px; }
  #emotions .room-file-symbol { display: none; }
  #emotions[data-phase="summary"] #request-line { padding: 5px 10px; font-size: .87rem; line-height: 1.32; }
  #emotions[data-phase="summary"] #next { min-height: 34px; margin-top: 5px; }
}
@media (max-height: 700px) and (max-aspect-ratio: 999/1000) {
  #emotions .room-summary { line-height: 1.27; }
  #emotions .room-file-paper { padding-block: 8px; }
  #emotions .room-summary h2 { padding-block-end: 2px; }
  #emotions[data-phase="summary"] { row-gap: 4px; }
  #emotions[data-phase="summary"] #request-line { padding: 6px 10px; font-size: .84rem; line-height: 1.38; }
  #emotions[data-phase="summary"] #next { min-height: 32px; margin-top: 5px; }
  #emotions .room-summary li div { display: contents; }
  #emotions .room-summary li { grid-template-columns: 2em minmax(44px, max-content) 1fr; }
  #emotions .room-file-symbol { display: none; }
}

@media (min-width: 360px) and (max-height: 700px) and (max-aspect-ratio: 999/1000) {
  #emotions { --final-top: max(276px, 50%); }
}
@keyframes room-rise {
  from { opacity: 0; transform: translateY(13px) scale(.82); }
  75% { opacity: 1; transform: translateY(-3px) scale(1.035); }
  to { opacity: 1; transform: none; }
}
@keyframes room-glow { 50% { scale: .8; box-shadow: 0 0 6px 1px #fff0bc; } }
@keyframes room-spark {
  0% { opacity: 0; transform: translateY(8px) scale(.4); }
  33%, 60% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-57px) scale(1.15); }
}
@keyframes room-trail {
  25%, 75% { opacity: 1; }
  from, to { opacity: 0; }
}
@media (max-aspect-ratio: 1/1) {
  #emotions .room-dialogue, #emotions[data-phase="opening"] .room-dialogue {
    top: auto;
    right: 5%;
    bottom: 62px;
    width: 90%;
    transform: none;
  }
  #emotions #request-line { font-size: clamp(.95rem, 3.8vw, 1.2rem); padding: 10px 14px; }
  #emotions #request-line::after { display: none; }
  #emotions #next { min-height: 36px; }
  #emotions [data-spot="theme"] .room-objects { bottom: 58px; }
  #emotions[data-phase="ideas"]:has([data-spot="theme"][data-current]) .room-dialogue,
  #emotions[data-phase="preview"]:has([data-spot="theme"][data-current]) .room-dialogue,
  #emotions[data-phase="clarified"]:has([data-spot="theme"][data-current]) .room-dialogue { bottom: 165px; }
  #emotions [data-spot="decor"] .room-objects {
    top: auto;
    right: 5%;
    bottom: min(26%, 220px);
  }
  #emotions [data-spot="sky"] .room-objects { top: 18%; left: auto; right: 5%; }
  #emotions [data-spot="sky"] .room-object svg { width: 38px; }
  #emotions .room-controls { right: 5%; gap: 4px; }
  #emotions .room-controls button { padding: 5px 7px; font-size: .75rem; }
}
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  #emotions .room-dialogue { top: 48%; }
  #emotions #request-line { font-size: 1rem; padding: 9px 12px; }
  #emotions #request-comparison { font-size: .87rem; }
}
@media (prefers-reduced-motion: reduce) {
  #emotions *, #emotions *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  #emotions .room-effect i { animation: none !important; }
}
