/* ==========================================================================
   UCL East First-Person Experience — Sticker-Illustration UI Stylesheet
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height);
  color: var(--ink);
  background-color: #241C2A;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

/* ==========================================================================
   App Shell & Stage Framing (Mobile portrait cover + Desktop 2:3 frame)
   ========================================================================== */

#app-shell {
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #241C2A;
  background-image: radial-gradient(rgba(255, 248, 236, 0.08) 1.5px, transparent 1.5px);
  background-size: 20px 20px;
  overflow: hidden;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #E9DEC9;
  isolation: isolate;
}

/* Desktop / wide viewport: centered 2:3 vertical stage with warm dark desk frame */
@media (min-width: 600px) and (min-aspect-ratio: 3/4) {
  #stage {
    height: min(95dvh, 960px);
    width: auto;
    aspect-ratio: 2 / 3;
    max-width: 96vw;
    border-radius: 26px;
    border: 3px solid #4A3B56;
    box-shadow: 0 24px 64px rgba(10, 6, 16, 0.55);
  }
}

/* ==========================================================================
   Camera Rig & 1024x1536 Art Plane (Layers 1–3)
   ========================================================================== */

#camera-rig {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: var(--z-bg);
  transform-origin: center center;
  will-change: transform;
}

#camera-rig.is-pushing {
  animation: cameraPushIn 1.4s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

#camera-rig.is-bobbing {
  animation: gentleHeadBob 2.6s ease-in-out infinite;
}

@keyframes cameraPushIn {
  0%   { transform: scale(1.0); }
  55%  { transform: scale(1.08); }
  100% { transform: scale(1.0); }
}

/* Strictly <= 1 Hz (2.6s = 0.38 Hz) and <= 3px vertical amplitude */
@keyframes gentleHeadBob {
  0%, 100% { transform: translateY(0px); }
  50%      { transform: translateY(-2.5px); }
}

#art-plane {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1024px;
  height: 1536px;
  transform: translate(-50%, -50%) scale(var(--plane-scale, 0.5));
  transform-origin: center center;
}

#layer-bg,
#layer-entities,
#layer-walk-debug {
  position: absolute;
  inset: 0;
  width: 1024px;
  height: 1536px;
}

#layer-bg { z-index: var(--z-bg); background: #EFE3CE; }
#layer-entities { z-index: var(--z-entities); pointer-events: none; }
#layer-walk-debug { z-index: var(--z-walk-debug); pointer-events: none; }

.bg-img {
  position: absolute;
  inset: 0;
  width: 1024px;
  height: 1536px;
  object-fit: cover;
  object-position: center center;
  opacity: 0;
  transition: opacity 0.65s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.bg-img.is-active {
  opacity: 1;
}

/* Subtle prologue tea steam & feet animation overlay (<= 0.4 Hz) */
.home-anim-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.home-steam {
  animation: steamDrift 3.4s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes steamDrift {
  0%, 100% { transform: translateY(0px) scaleY(1); opacity: 0.72; }
  50%      { transform: translateY(-9px) scaleY(1.06); opacity: 0.95; }
}

/* ==========================================================================
   Layers 4–7 (Viewport-relative inside #stage)
   ========================================================================== */

#layer-hands {
  position: absolute;
  inset: 0;
  z-index: var(--z-hands);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#layer-hands.is-dimmed {
  opacity: 0.24;
  transform: translateY(14px);
}

#layer-hands .hand-interactive {
  pointer-events: auto;
}

#layer-fx {
  position: absolute;
  inset: 0;
  z-index: var(--z-fx);
  pointer-events: none;
}

#layer-body-fx {
  position: absolute;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  transition: opacity 0.18s ease-out;
}

#layer-hotspots {
  position: absolute;
  inset: 0;
  z-index: var(--z-hotspots);
  pointer-events: none;
}

#layer-ui {
  position: absolute;
  inset: 0;
  z-index: var(--z-ui);
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

#layer-ui > * {
  pointer-events: none;
}

/* ==========================================================================
   Sticker Primitives (Buttons, Pills, Badges, Dani Mini-Browser Window)
   ========================================================================== */

.sticker-card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sticker);
  color: var(--ink);
}

.sticker-window {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sticker-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 36px - var(--safe-top) - var(--safe-bottom));
}

.window-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  background: var(--lilac);
  border-bottom: var(--border);
  flex-shrink: 0;
}

.window-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.window-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  display: inline-block;
}

.window-dot.dot-1 { background: var(--dot-coral); }
.window-dot.dot-2 { background: var(--dot-yellow); }
.window-dot.dot-3 { background: var(--dot-green); }

.window-title {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 4px;
}

.window-close {
  width: var(--tap-compact);
  height: var(--tap-compact);
  min-width: var(--tap-compact);
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-sticker-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.window-close:active {
  transform: translateY(2px);
  box-shadow: none;
}

.window-body {
  padding: 16px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-min);
  padding: 10px 18px;
  border-radius: 15px;
  border: var(--border);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  box-shadow: var(--shadow-sticker);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--paper-alt);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn-primary {
  background: var(--teal-btn);
  color: #FFFDF8;
}

.btn-primary:hover {
  background: var(--teal-dark);
}

.btn-warm {
  background: var(--marker);
  color: var(--ink);
}

.btn-warm:hover {
  background: #EAC120;
}

.btn-lilac {
  background: var(--lilac);
  color: var(--ink);
}

.btn-lilac:hover {
  background: #C9BDEB;
}

.btn-soft {
  background: var(--paper-alt);
  color: var(--ink);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-width: var(--tap-compact);
  min-height: var(--tap-compact);
  padding: 7px 13px;
  font-size: var(--text-sm);
  border-radius: 12px;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--ink);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.3;
  background: var(--paper-alt);
}

.badge-confirmed {
  background: #DDF2E7;
}

.badge-verify {
  background: var(--orange-soft);
  border-style: dashed;
}

.badge-tag {
  background: var(--lilac-soft);
}

.fact-block {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--ink);
  background: var(--paper-alt);
}

.fact-block.is-to-verify {
  background: #FFF2E5;
  border-style: dashed;
}

.fact-source {
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--ink-soft);
  font-weight: 600;
}

/* ==========================================================================
   Top Bar & Subbar
   ========================================================================== */

#ui-topbar {
  position: relative;
  z-index: var(--z-topbar);
  padding: calc(8px + var(--safe-top)) calc(8px + var(--safe-right)) 4px calc(8px + var(--safe-left));
  pointer-events: none;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  pointer-events: auto;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tb-btn {
  width: var(--tap-compact);
  height: var(--tap-compact);
  min-width: var(--tap-compact);
  padding: 0;
  border-radius: 13px;
  border: 2.2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-sticker-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}

.tb-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.tb-btn[aria-pressed="true"],
.tb-btn.is-active {
  background: var(--marker);
}

.tb-btn.is-calm-active {
  background: var(--calm);
}

.tb-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--ink);
  stroke-width: 2.3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sensory Load Ring (non-numeric) */
.load-ring-btn {
  width: var(--tap-compact);
  height: var(--tap-compact);
  min-width: var(--tap-compact);
  padding: 0;
  border-radius: 50%;
  border: 2.2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-sticker-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.load-ring-svg {
  width: 34px;
  height: 34px;
  transform: rotate(-90deg);
}

.load-ring-track {
  fill: none;
  stroke: #E9DEC9;
  stroke-width: 5;
}

.load-ring-arc {
  fill: none;
  stroke: var(--calm);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease, stroke 0.5s ease;
}

.load-ring-dot {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--calm);
  transition: background-color 0.4s ease;
}

.load-ring-btn[data-band="calm"] .load-ring-arc { stroke: var(--calm); }
.load-ring-btn[data-band="calm"] .load-ring-dot { background: var(--calm); }
.load-ring-btn[data-band="busy"] .load-ring-arc { stroke: var(--busy); }
.load-ring-btn[data-band="busy"] .load-ring-dot { background: var(--busy); }
.load-ring-btn[data-band="overload"] .load-ring-arc { stroke: var(--over); }
.load-ring-btn[data-band="overload"] .load-ring-dot { background: var(--over); }

/* Subbar: Scene Title, Clock, "I'm uncomfortable" button & Quick Equipped Gear pills */
#ui-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px;
  padding: 2px calc(10px + var(--safe-right)) 4px calc(10px + var(--safe-left));
  pointer-events: none;
}

.scene-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 4px 12px;
  min-width: 0;
  flex: 0 1 auto;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sticker-sm);
  font-size: var(--text-xs);
  font-weight: 800;
  max-width: 52%;
}

.scene-pill-clock {
  color: var(--teal-btn);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.scene-pill-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gear-bar {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.uncomfortable-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  border: 2.2px solid var(--ink);
  background: #FDE8EE;
  color: var(--ink);
  box-shadow: var(--shadow-sticker-sm);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.uncomfortable-btn:hover {
  background: #F9D5DF;
}

.uncomfortable-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.gear-chip {
  min-width: 44px;
  height: 44px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  border: 2.2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-sticker-sm);
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.gear-chip:active {
  transform: translateY(2px);
  box-shadow: none;
}

.gear-chip[aria-pressed="true"] {
  background: var(--marker);
  color: var(--ink);
}

/* ==========================================================================
   Captions Slot (#layer-captions)
   ========================================================================== */

#layer-captions {
  position: relative;
  z-index: var(--z-captions);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  pointer-events: none;
  min-height: 0;
}

.caption-pill {
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: var(--radius-pill);
  padding: 5px 14px;
  font-size: var(--text-xs);
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(46, 36, 51, 0.35);
  max-width: 92%;
  text-align: center;
}

/* ==========================================================================
   v2.1 Ambient Voices (Overheard): Directional Chips, Directed Drawer & Log
   ========================================================================== */

#layer-voice-chips {
  position: relative;
  z-index: 77;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 2px calc(10px + var(--safe-right)) 4px calc(10px + var(--safe-left));
  pointer-events: none;
  min-height: 0;
  max-height: 185px;
  overflow: hidden;
}

.voice-chip {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: min(82%, 310px);
  padding: 7px 11px;
  border-radius: 14px;
  border: 2.2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-sticker-sm);
  font-size: var(--text-xs);
  line-height: 1.4;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.voice-chip[data-dir="left"] {
  align-self: flex-start;
}

.voice-chip[data-dir="center"] {
  align-self: center;
}

.voice-chip[data-dir="right"] {
  align-self: flex-end;
}

.voice-chip[data-kind="pa"] {
  background: var(--lilac-soft);
}

.voice-chip[data-kind="ph"] {
  background: #E8F4F8;
}

.voice-chip[data-kind="dir"] {
  background: #FFF3D4;
  border-color: var(--ink);
}

.voice-chip.is-fragmented {
  opacity: 0.84;
  border-style: dashed;
  transform: translateX(3px);
}

body.clear-text .voice-chip.is-fragmented {
  opacity: 1;
  border-style: solid;
  transform: none;
}

.voice-chip-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

.voice-chip-en {
  font-weight: 800;
  color: var(--ink);
}

.voice-chip-zh {
  font-weight: 600;
  color: var(--ink-soft);
}

.voice-chip-example {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--ink);
  background: var(--orange-soft);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.voice-chip-note {
  margin-top: 2px;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1.5px dashed var(--ink);
  background: var(--lilac-soft);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 700;
}

.voice-chip-reply-btn {
  align-self: flex-start;
  margin-top: 3px;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--ink);
  background: var(--marker);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 800;
  box-shadow: var(--shadow-sticker-sm);
}

.voice-dir-bar,
.voice-dir-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.voice-dir-quote {
  padding: 10px 12px;
  border-radius: 14px;
  border: 2.2px solid var(--ink);
  background: #FFF4DC;
  box-shadow: var(--shadow-sticker-sm);
}

.voice-dir-reply-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.voice-dir-reply-btn {
  flex: 1;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 13px;
  border: 2.2px solid var(--ink);
  background: #FFFDF8;
  box-shadow: var(--shadow-sticker-sm);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 700;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.voice-dir-reply-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.voice-practice-btn {
  min-width: 48px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 13px;
  border: 2.2px solid var(--ink);
  background: var(--lilac-soft);
  box-shadow: var(--shadow-sticker-sm);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.heard-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.heard-log-item {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: var(--paper-alt);
  box-shadow: var(--shadow-sticker-sm);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.heard-log-item:hover,
.heard-log-item.is-playing {
  background: #FFF3D4;
}

.heard-chip {
  background: var(--lilac-soft);
}

/* v2 Body Reaction Captions, Somatic Coping Bar, Close-Eyes Curtain & Demo Presenter Bar */
#ui-body-caption {
  position: relative;
  z-index: 76;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 14px;
  pointer-events: none;
  min-height: 0;
}

#ui-somatic-bar {
  position: relative;
  z-index: 78;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 2px calc(10px + var(--safe-right)) 4px calc(10px + var(--safe-left));
  pointer-events: none;
}

#ui-somatic-bar > * {
  pointer-events: auto;
}

#ui-demo-bar {
  position: relative;
  z-index: 88;
  pointer-events: auto;
}

.somatic-heading {
  margin: 14px 0 6px;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--ink-soft);
}

.somatic-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.somatic-chip {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-sticker-sm);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: auto;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.somatic-chip:active {
  transform: translateY(2px);
  box-shadow: none;
}

.somatic-chip[aria-pressed="true"],
.somatic-chip.is-active {
  background: var(--calm);
}

.calibration-step {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--ink);
  background: var(--paper-alt);
}

.close-eyes-curtain {
  position: absolute;
  inset: 0;
  z-index: 58;
  background: rgba(24, 18, 28, 0.94);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 800;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.18s ease-out;
}

/* ==========================================================================
   Hotspots (Yellow Numbered Sticker Markers)
   ========================================================================== */

.hotspot-btn {
  position: absolute;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  padding: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 2;
}

.hotspot-disc {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--marker);
  border: 2.5px solid var(--ink);
  box-shadow: var(--shadow-sticker);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1;
  transition: transform 0.15s ease, background-color 0.2s ease;
  animation: markerPulse 2.4s ease-in-out infinite;
}

.hotspot-btn:hover .hotspot-disc {
  transform: scale(1.08);
}

.hotspot-btn:active .hotspot-disc {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 1px 0 var(--ink);
}

.hotspot-btn.is-visited .hotspot-disc {
  background: var(--marker-done);
  animation: none;
  font-size: 16px;
}

.hotspot-clamped-arrow {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--ink);
  border-radius: 50%;
  opacity: 0.7;
}

/* Strictly <= 1 Hz (2.4s = 0.42 Hz) */
@keyframes markerPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

/* Stage bottom hint (e.g. Dani's "Tap where you want to look") */
#ui-stage-hint {
  position: absolute;
  left: 50%;
  bottom: calc(14px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: var(--z-panel);
  width: min(350px, calc(100% - 24px));
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--paper);
  border: var(--border);
  box-shadow: var(--shadow-sticker-lg);
  font-size: var(--text-sm);
  font-weight: 800;
  text-align: center;
  pointer-events: auto;
}

/* ==========================================================================
   Bottom 3-Layer Story Panel (#ui-panel)
   ========================================================================== */

#ui-panel {
  margin-top: auto;
  position: relative;
  z-index: var(--z-panel);
  padding: 0 calc(10px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));
  pointer-events: none;
}

.panel-shell {
  pointer-events: auto;
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sticker-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 54dvh;
}

.panel-shell.is-expanded {
  max-height: 64dvh;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: var(--lilac);
  border-bottom: var(--border);
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.panel-chapter {
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-toggle-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: var(--shadow-sticker-sm);
}

.panel-scroll {
  padding: 12px 14px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Layer 1: Narration */
.narration-box {
  position: relative;
  cursor: pointer;
}

.narration-text {
  margin: 0;
  font-size: var(--text-base);
  line-height: var(--line-height);
  font-weight: 600;
  color: var(--ink);
}

.narration-nav {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.narration-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.narration-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.8px solid var(--ink);
  background: var(--paper-alt);
}

.narration-dot.is-current {
  background: var(--marker);
  width: 18px;
  border-radius: 99px;
}

/* Layer 2: Inner Thought (Dani thought-cloud styling) */
.inner-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inner-toggle {
  align-self: flex-start;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--ink);
  background: var(--lilac-soft);
  box-shadow: var(--shadow-sticker-sm);
  font-size: var(--text-sm);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.inner-bubble {
  padding: 11px 14px;
  border-radius: 20px;
  border: 2.2px solid var(--ink);
  background: #FFFDF8;
  box-shadow: var(--shadow-sticker-sm);
  font-size: var(--text-sm);
  line-height: var(--line-height);
  color: var(--ink);
  position: relative;
}

/* Dialogue Speech Bubble */
.dialogue-box {
  padding: 11px 14px;
  border-radius: 16px;
  border: 2.2px solid var(--ink);
  background: #FFF4DC;
  box-shadow: var(--shadow-sticker-sm);
}

.dialogue-speaker {
  display: inline-block;
  margin-bottom: 4px;
  padding: 1px 9px;
  border-radius: var(--radius-pill);
  border: 1.8px solid var(--ink);
  background: var(--marker);
  font-size: var(--text-xs);
  font-weight: 800;
}

.dialogue-line {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 700;
  transition: filter 0.3s ease;
}

.dialogue-disclaimer {
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--ink-soft);
  font-style: italic;
}

/* Seminar Discussion Rhythm Bar (Scene 21) */
.rhythm-bar {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 2.2px solid var(--ink);
  background: var(--lilac-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rhythm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.rhythm-title {
  font-size: var(--text-xs);
  font-weight: 800;
}

.rhythm-track {
  position: relative;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.rhythm-stream {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  white-space: nowrap;
  animation: rhythmScroll 9s linear infinite;
}

@keyframes rhythmScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.rhythm-chip {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1.8px solid var(--ink);
  background: var(--paper-alt);
  font-size: 13px;
  font-weight: 700;
}

.rhythm-chip.is-pause {
  background: var(--calm);
  font-weight: 900;
}

.rhythm-rule-box {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1.8px dashed var(--ink);
  background: var(--paper);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* Layer 3: Choices & Result Card */
.choices-prompt {
  margin: 0 0 2px;
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--ink-soft);
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-btn {
  width: 100%;
  min-height: var(--tap-min);
  padding: 11px 14px;
  border-radius: 14px;
  border: var(--border);
  background: #FFFDF8;
  box-shadow: var(--shadow-sticker-sm);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}

.choice-btn:hover {
  background: #FFF3D4;
}

.choice-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.choice-btn.is-picked {
  background: #DDF2E7;
}

.choice-meta {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1.6px solid var(--ink);
  background: var(--lilac-soft);
}

.result-card {
  padding: 12px 14px;
  border-radius: 14px;
  border: 2.2px solid var(--ink);
  background: #E8F6EE;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-text {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
}

.result-ask {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-soft);
}

.result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.whatif-banner {
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--lilac-soft);
  font-size: var(--text-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  background: var(--paper-alt);
  border-top: var(--border);
  flex-wrap: wrap;
}

.panel-footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Modals & Full-Screen Flows (Welcome, Quick Setup, Pause, Resources, Cards)
   ========================================================================== */

#ui-modal-root,
#ui-screen-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#ui-modal-root { z-index: var(--z-modal); }
#ui-screen-root { z-index: var(--z-screen); }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(36, 28, 42, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(14px + var(--safe-top)) calc(14px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(14px + var(--safe-left));
  pointer-events: auto;
}

.modal-backdrop .sticker-window {
  width: 100%;
  max-width: 440px;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  background: #F6EEDD;
  background-image: radial-gradient(rgba(46, 36, 51, 0.06) 1.5px, transparent 1.5px);
  background-size: 18px 18px;
  display: flex;
  flex-direction: column;
  padding: calc(14px + var(--safe-top)) calc(14px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(14px + var(--safe-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}

.screen-overlay .sticker-window {
  max-height: none;
  overflow: visible;
}

.screen-overlay .window-bar {
  border-top-left-radius: calc(var(--radius) - 3px);
  border-top-right-radius: calc(var(--radius) - 3px);
}

.screen-overlay .window-body {
  padding: 13px 15px 15px;
  overflow: visible;
}

.screen-inner {
  width: 100%;
  max-width: 440px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 14px;
}

.welcome-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.welcome-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 900;
  line-height: 1.25;
}

.welcome-subtitle {
  margin: 4px 0 0;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  font-weight: 600;
}

.notice-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2.2px solid var(--ink);
  background: #FFF2E5;
  font-size: var(--text-sm);
}

.notice-box strong {
  display: block;
  margin-bottom: 4px;
}

.pref-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.pref-card,
.bag-item {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 13px;
  border-radius: 14px;
  border: 2.2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-sticker-sm);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--text-sm);
  font-weight: 700;
}

.pref-card[aria-pressed="true"],
.bag-item[aria-pressed="true"] {
  background: var(--calm);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.preset-btn {
  min-height: var(--tap-min);
  padding: 8px 10px;
  border-radius: 13px;
  border: 2.2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-sticker-sm);
  font-size: var(--text-sm);
  font-weight: 800;
}

.preset-btn[aria-pressed="true"] {
  background: var(--marker);
}

.segment-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cta-stack {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* Skin tone swatch picker */
.swatch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  box-shadow: var(--shadow-sticker-sm);
}

.swatch-btn[aria-pressed="true"] {
  outline: 3px solid var(--teal-btn);
  outline-offset: 2px;
}

/* Resources & Crisis styling */
.crisis-card {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2.5px solid var(--ink);
  background: #FDE8EE;
}

.resource-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.resource-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--ink);
  background: var(--paper-alt);
  font-size: var(--text-sm);
}

.resource-item strong {
  display: block;
}

/* Tabs */
.tab-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 10px;
}

.tab-btn {
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--paper-alt);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
}

.tab-btn[aria-selected="true"] {
  background: var(--marker);
}

/* ==========================================================================
   First-Person SVG Hands & Props
   ========================================================================== */

.hands-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hands-sunglasses-tint {
  position: absolute;
  inset: 0;
  background: rgba(58, 48, 66, 0.16);
  pointer-events: none;
}

.phone-overlay-wrap {
  position: absolute;
  right: 12px;
  bottom: 16%;
  width: min(260px, 68vw);
  pointer-events: auto;
}

/* ==========================================================================
   Clear Text Mode & Calm / Reduced-Motion Safety Guarantees
   ========================================================================== */

body.clear-text {
  --paper: var(--paper-pure);
  --ink: #1A1320;
  --ink-soft: #3D3147;
}

body.clear-text .dialogue-line {
  filter: none !important;
  opacity: 1 !important;
}

body.clear-text .panel-shell,
body.clear-text .sticker-window,
body.clear-text .sticker-card {
  background: #FFFDF8 !important;
}

body.calm-mode #camera-rig,
body.calm-mode .hotspot-disc,
body.calm-mode .home-steam,
body.calm-mode .rhythm-stream {
  animation: none !important;
}

body.calm-mode #camera-rig {
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  #camera-rig,
  .hotspot-disc,
  .home-steam,
  .rhythm-stream {
    animation: none !important;
  }

  .bg-img {
    transition-duration: 0.15s;
  }
}

/* Narrow phone polish (360x780): keep all 8 topbar buttons >=44px with zero clipping */
@media (max-width: 382px) {
  #ui-topbar {
    padding-left: 2px;
    padding-right: 2px;
  }
  .topbar-row {
    gap: 0;
    justify-content: space-between;
  }
  .topbar-group {
    gap: 0;
  }
  .tb-btn,
  .load-ring-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 11px;
  }
  #ui-subbar {
    padding-left: 6px;
    padding-right: 6px;
  }
  .uncomfortable-btn,
  .gear-chip {
    padding: 0 8px;
    font-size: 12px;
  }
}

/* ==========================================================================
   v2.2 Fresh Airy Visual Polish & Compact Pop-ups (Less Clutter, More Artwork)
   ========================================================================== */

:focus-visible {
  outline: 3px solid #22736E;
  outline-offset: 2px;
}

#ui-topbar {
  padding: calc(6px + var(--safe-top)) calc(10px + var(--safe-right)) 3px calc(10px + var(--safe-left));
}

.topbar-row {
  gap: 6px;
}

.topbar-group {
  gap: 6px;
}

.tb-btn,
.load-ring-btn {
  background: rgba(255, 250, 242, 0.9);
  border: 1.8px solid rgba(46, 36, 51, 0.78);
  box-shadow: 0 2px 8px rgba(46, 36, 51, 0.14);
}

.uncomfortable-btn {
  border: 1.8px solid rgba(46, 36, 51, 0.75);
  background: rgba(253, 236, 240, 0.92);
  box-shadow: 0 2px 8px rgba(46, 36, 51, 0.12);
  padding: 0 10px;
  font-size: 12.5px;
}

#ui-subbar {
  padding: 2px calc(10px + var(--safe-right)) 2px calc(10px + var(--safe-left));
  gap: 6px;
}

.scene-pill {
  min-height: 36px;
  padding: 3px 10px;
  background: rgba(255, 250, 242, 0.86);
  border: 1.6px solid rgba(46, 36, 51, 0.65);
  box-shadow: 0 2px 6px rgba(46, 36, 51, 0.1);
  font-size: 12.5px;
}

.gear-chip {
  background: rgba(255, 250, 242, 0.88);
  border: 1.6px solid rgba(46, 36, 51, 0.7);
  box-shadow: 0 2px 6px rgba(46, 36, 51, 0.1);
  font-size: 12.5px;
  padding: 0 10px;
}

/* Slimmer, airier Layer-1 bottom story panel — keeps >75% of scene art visible */
#ui-panel {
  padding: 0 calc(10px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(10px + var(--safe-left));
}

.panel-shell {
  background: rgba(255, 250, 242, 0.95);
  border: 1.8px solid rgba(46, 36, 51, 0.82);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(46, 36, 51, 0.16);
  max-height: 44dvh;
}

.panel-header {
  padding: 4px 8px 4px 10px;
  background: rgba(224, 217, 244, 0.92);
  border-bottom: 1.6px solid rgba(46, 36, 51, 0.25);
}

.panel-chapter {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
}

.window-dot {
  width: 10px;
  height: 10px;
  border-width: 1.6px;
}

.panel-toggle-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 11px;
  border: 1.6px solid rgba(46, 36, 51, 0.72);
  background: rgba(255, 252, 246, 0.92);
  font-size: 12px;
  box-shadow: 0 1px 4px rgba(46, 36, 51, 0.1);
}

.panel-scroll {
  padding: 8px 12px 6px;
  gap: 6px;
}

.narration-text {
  font-size: calc(15.5px * var(--text-scale));
  line-height: 1.5;
}

.narration-nav {
  margin-top: 5px;
}

.panel-footer {
  padding: 6px 10px 8px;
  border-top: 1.4px solid rgba(46, 36, 51, 0.14);
  background: rgba(248, 241, 227, 0.72);
}

.panel-footer .btn-sm {
  min-height: 44px;
  padding: 0 13px;
  font-size: 13.5px;
  border-width: 1.8px;
  box-shadow: 0 2px 0 rgba(46, 36, 51, 0.85);
}

/* Compact, breathable pop-up modals (smaller footprint + lighter backdrop) */
.modal-backdrop {
  background: rgba(36, 28, 42, 0.28);
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

.modal-backdrop .sticker-window {
  width: min(344px, 88vw);
  max-width: 344px;
  max-height: 68dvh;
  border: 1.8px solid rgba(46, 36, 51, 0.84);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(36, 28, 42, 0.22);
}

.modal-backdrop .window-bar {
  padding: 6px 10px 6px 12px;
  border-bottom: 1.6px solid rgba(46, 36, 51, 0.22);
}

.modal-backdrop .window-body {
  padding: 12px 14px 14px;
}

/* Compact directed voice card (never swallows the whole scene) */
#ui-voice-dir-bar .voice-dir-card,
.voice-dir-card {
  max-height: 44dvh;
  overflow-y: auto;
  padding: 10px 12px;
  border-width: 1.8px;
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(36, 28, 42, 0.18);
  gap: 7px;
}

.voice-dir-quote {
  padding: 8px 10px;
  border-width: 1.6px;
  border-radius: 12px;
  box-shadow: none;
}

.voice-dir-reply-btn {
  padding: 6px 10px;
  border-width: 1.6px;
  border-radius: 11px;
  box-shadow: 0 1px 0 rgba(46, 36, 51, 0.75);
  font-size: 13.5px;
}

/* Lighter directional voice chips */
.voice-chip {
  background: rgba(255, 250, 242, 0.9);
  border-width: 1.6px;
  box-shadow: 0 2px 8px rgba(46, 36, 51, 0.12);
  padding: 5px 9px;
}

/* ==========================================================================
   Autism-Friendly Accessibility Modes (Settings -> Accessibility)
   ========================================================================== */

/* 1. Low-Stimulation Soft Palette: warm muted sage-cream, reduced glare & visual noise */
body.a11y-low-stim .panel-shell,
body.a11y-low-stim .sticker-window,
body.a11y-low-stim .tb-btn,
body.a11y-low-stim .load-ring-btn,
body.a11y-low-stim .scene-pill,
body.a11y-low-stim .gear-chip,
body.a11y-low-stim .somatic-btn {
  background: #F5F3EB !important;
  border-color: rgba(54, 62, 58, 0.52) !important;
  box-shadow: 0 2px 8px rgba(40, 48, 44, 0.08) !important;
}

body.a11y-low-stim .panel-header,
body.a11y-low-stim .window-bar {
  background: #E5EAE4 !important;
}

body.a11y-low-stim #layer-bg {
  opacity: 0.92;
}

/* 2. Wide Reading Spacing (Dyslexia & low-visual-crowding friendly) */
body.a11y-wide-spacing .narration-text,
body.a11y-wide-spacing .window-body,
body.a11y-wide-spacing .choice-btn,
body.a11y-wide-spacing .voice-chip,
body.a11y-wide-spacing .voice-dir-card,
body.a11y-wide-spacing .heard-log-item {
  letter-spacing: 0.045em;
  word-spacing: 0.12em;
  line-height: 1.82 !important;
}

/* 3. Minimal Focus UI: hides non-essential decorative bubbles & floating clutter */
body.a11y-minimal-ui .fx-babble-wrap,
body.a11y-minimal-ui .fx-haze-badge,
body.a11y-minimal-ui #ui-body-caption,
body.a11y-minimal-ui .window-dots {
  display: none !important;
}

body.a11y-minimal-ui .hotspot-disc {
  opacity: 0.68;
}
