/* ═══════════════════════════════════════════════════════════════════
   SONARE OF THE LAKE — Global Styles
   Aesthetic: Quiet luxury. Deep water. Bioluminescent accents.
   Fonts: Shippori Mincho (display) + DM Mono (UI/data)
   ═══════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ────────────────────────────────────────────────── */
:root {
  /* Core palette — derived from deep lake water */
  --lake-void:      #03080f;   /* near-black deep water */
  --lake-deep:      #071828;   /* dark midnight blue    */
  --lake-mid:       #0d3050;   /* medium depth blue     */
  --lake-surface:   #1a6080;   /* surface shimmer       */
  --lake-light:     #4db8d4;   /* refracted light       */
  --lake-foam:      #b8eaf4;   /* light foam/mist       */

  /* Accent — bioluminescent teal-green */
  --accent:         #00e5c3;
  --accent-dim:     #00a88f55;
  --accent-glow:    0 0 12px #00e5c388, 0 0 32px #00e5c322;

  /* Text */
  --text-primary:   #dff0f5;
  --text-secondary: #7aafc0;
  --text-dim:       #3a6070;

  /* UI surfaces */
  --surface-1:      rgba(7, 24, 40, 0.85);
  --surface-2:      rgba(13, 48, 80, 0.6);
  --border:         rgba(77, 184, 212, 0.2);

  /* Spacing */
  --radius:         10px;
  --radius-lg:      18px;

  /* Transitions */
  --ease-lake:      cubic-bezier(0.23, 1, 0.32, 1);
  --t-fast:         180ms;
  --t-mid:          360ms;
  --t-slow:         600ms;

  /* Fonts */
  --font-display:   'Shippori Mincho', serif;
  --font-ui:        'DM Mono', monospace;
}

/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--lake-void);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

/* ── Focus Visible ────────────────────────────────────────────────── */
/* Replace the browser's default blue focus ring with the accent colour.
   :focus-visible only fires for keyboard navigation, not mouse clicks,
   so sighted mouse users never see the ring. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: var(--accent-glow);
}

/* Edge buttons already have a border; mirror the hover state instead of
   drawing a second outline on top of it. */
.edge-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
  color: var(--accent);
}

/* Start button: accent-coloured text mirrors the hover state. */
.home-start-btn:focus,
.home-start-btn:focus-visible { outline: none; box-shadow: none; }
.home-start-btn:focus-visible .home-btn-jp,
.home-start-btn:focus-visible .home-btn-en  { color: var(--accent); }
.home-start-btn:focus-visible .home-btn-arrow { transform: translateX(6px); }

/* Icon-only close buttons: colour change is sufficient. */
.drawer-close-btn:focus-visible,
.info-panel-close:focus-visible { outline: none; color: var(--accent); }

/* ── Three.js Canvas ──────────────────────────────────────────────── */
#three-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ── Scene Overlay ────────────────────────────────────────────────── */
/*
  Each scene injects its own HTML into #scene-overlay.
  Scenes should add/remove a class on this element to show/hide.
  Use .scene-overlay--visible to fade in.
*/
#scene-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none; /* scenes enable this selectively */
  opacity: 0;
  transition: opacity var(--t-mid) var(--ease-lake);
}

#scene-overlay.visible {
  opacity: 1;
  /* pointer-events stays none — overlay is display-only;
     interactive children must set pointer-events: auto themselves */
}

/* ── Global UI Layer ──────────────────────────────────────────────── */
#global-ui {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none; /* children opt in individually */
}

/* ── Loading Screen ───────────────────────────────────────────────── */
#loading-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--lake-void);
  pointer-events: auto;
  transition: opacity var(--t-slow) var(--ease-lake);
  z-index: 100;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Animated ripple ring for loading */
.loading-lake {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  box-shadow: var(--accent-glow);
  animation: ripple-pulse 2s var(--ease-lake) infinite;
  margin-bottom: 1rem;
}

@keyframes ripple-pulse {
  0%   { transform: scale(0.8); opacity: 0.3; }
  50%  { transform: scale(1.1); opacity: 1;   }
  100% { transform: scale(0.8); opacity: 0.3; }
}

.loading-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-primary);
}

.loading-sub {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.loading-status {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  min-height: 1.2em;
}

/* ── Edge Trigger Buttons ─────────────────────────────────────────── */

/* Base styles shared by both edge buttons */
.edge-btn {
  position: absolute;
  background: var(--surface-1);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  color: var(--lake-light);
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast),
              opacity var(--t-mid) var(--ease-lake);
  z-index: 25;
}

.edge-btn:hover {
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
  color: var(--accent);
}

/* Left-edge tab — vertically centred, rounded right corners only */
.edge-btn--left {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 64px;
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  flex-direction: column;
  gap: 5px;
}

/* Hamburger lines inside the left tab */
.edge-btn--left span {
  display: block;
  width: 14px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
}

/* Bottom-right floating music button */
.edge-btn--bottom {
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
}

/* Fullscreen button — sits above the music button, touch devices only */
.edge-btn--fullscreen {
  bottom: 80px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.1rem;
  display: none;
}

@media (pointer: coarse) {
  .edge-btn--fullscreen:not(.hidden) {
    display: flex;
  }
}

/* ── Now-playing pill ─────────────────────────────────────────────── */
/* Sits to the left of the menu button; purely decorative (pointer-events: none). */
#now-playing {
  position: absolute;
  bottom: 24px;
  right: 76px; /* 24px right margin + 44px btn + 8px gap */
  height: 44px;
  max-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: rgba(3, 8, 15, 0.15);
  border: 1px solid var(--border);
  border-radius: 22px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(28px);
  pointer-events: none;
  transition: opacity var(--t-mid) var(--ease-lake);
  z-index: 25;
}

.now-playing-icon {
  color: var(--accent);
  font-size: 0.9rem;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px #00e5c388);
}

#now-playing-title {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Home Screen ──────────────────────────────────────────────────── */
#home-screen {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  overflow: hidden;
  transition: opacity var(--t-mid) var(--ease-lake);
}

#home-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Three concentric rings expanding outward — water ripple motif */
.home-ripples {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.home-ripples span {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(0, 229, 195, 0.18);
  animation: home-ring 9s ease-out infinite;
}
.home-ripples span:nth-child(1) { animation-delay: 0s; }
.home-ripples span:nth-child(2) { animation-delay: 3s; }
.home-ripples span:nth-child(3) { animation-delay: 6s; }

@keyframes home-ring {
  0%   { width: 8vmin;   height: 8vmin;   opacity: 0.7; }
  100% { width: 180vmin; height: 180vmin; opacity: 0;   }
}

/* Corner bracket flourishes — L-shaped accents in each viewport corner */
.home-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.home-corners span {
  position: absolute;
  width: 44px;
  height: 44px;
  opacity: 0.5;
}

.home-corners span:nth-child(1) { top: 2rem;    left: 2rem;  border-top: 1px solid var(--accent); border-left: 1px solid var(--accent); }
.home-corners span:nth-child(2) { top: 2rem;    right: 2rem; border-top: 1px solid var(--accent); border-right: 1px solid var(--accent); }
.home-corners span:nth-child(3) { bottom: 2rem; left: 2rem;  border-bottom: 1px solid var(--accent); border-left: 1px solid var(--accent); }
.home-corners span:nth-child(4) { bottom: 2rem; right: 2rem; border-bottom: 1px solid var(--accent); border-right: 1px solid var(--accent); }

/* Vertical Japanese label — fixed to left edge */
.home-vertical {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.5em;
  color: var(--text-secondary);
  pointer-events: none;
  user-select: none;
}
.home-vertical--left  { left:  2.5rem; }
.home-vertical--right { right: 2.5rem; }

/* Centred content block */
.home-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}

.home-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.home-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 2.5rem;
}

/* Large italic-style display word — the visual anchor of the page */
.home-title-main {
  font-family: var(--font-display);
  font-size: clamp(4rem, 11vw, 8rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.06em;
  line-height: 1;
  text-shadow: 0 0 80px rgba(0, 229, 195, 0.18);
}

.home-title-sub {
  font-family: var(--font-ui);
  font-size: clamp(0.85rem, 2vw, 1.15rem);
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--lake-light);
}

.home-title-name {
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  letter-spacing: 0.12em;
  line-height: 1.15;
  text-shadow: 0 0 80px rgba(0, 229, 195, 0.18);
}
.home-title-name--sm     { font-size: clamp(1.4rem, 3.5vw, 2.5rem); transform: translateX(clamp(-2rem, -4.5vw, -0.5rem)); }
.home-title-name--indent { transform: translateX(clamp(0.5rem, 4.5vw, 2rem)); }
.home-title-accent       { color: var(--lake-light); }

.home-title-jp {
  font-family: var(--font-display);
  font-size: clamp(0.75rem, 1.6vw, 1rem);
  letter-spacing: 0.3em;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.home-sonare {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.65;
  margin-top: -1.25rem;
  margin-bottom: 2rem;
}

.home-copyright {
  font-family: var(--font-ui);
  font-size: 0.75 rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  opacity: 0.4;
  margin-top: 2.5rem;
}

/* Thin divider with centred glowing accent dot */
.home-rule {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: min(280px, 55vw);
  margin-bottom: 2.75rem;
}
.home-rule::before,
.home-rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.home-rule span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--accent-glow);
  flex-shrink: 0;
}

/* Start button — Japanese label above, English text below, no background box */
.home-start-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 1rem;
  color: inherit;
}

.home-btn-jp {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.4em;
  color: var(--text-dim);
  transition: color var(--t-mid) var(--ease-lake);
}

.home-btn-en {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  transition: color var(--t-mid) var(--ease-lake);
}

.home-btn-arrow {
  display: inline-block;
  transition: transform var(--t-mid) var(--ease-lake);
}

.home-start-btn:hover .home-btn-jp    { color: var(--accent); }
.home-start-btn:hover .home-btn-en    { color: var(--accent); }
.home-start-btn:hover .home-btn-arrow { transform: translateX(6px); }

/* ── Combined scene + music drawer — slides up from bottom ───────── */
#combo-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100vh;
  background: rgba(3, 8, 15, 0.15);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(28px);
  display: flex;
  flex-direction: row;
  pointer-events: auto;
  transform: translateY(100%);
  transition: transform var(--t-mid) var(--ease-lake);
  z-index: 30;
  overflow: hidden;
}

#combo-drawer.open {
  transform: translateY(0);
}

.combo-scenes {
  width: 50%;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  z-index: 1;
}

.combo-player {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}

.combo-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 5;
}

.player-illustration-wrap {
  position: relative;
  /* min() clamps height so the player image never overflows its 50vw panel:
     at 16:9 and wider 80vw > 100vh so 100% wins; on narrower viewports
     80vw becomes the binding constraint and the image scales down. */
  height: min(100%, 80vw);
  flex-shrink: 0;
  isolation: isolate; /* scope z-index so strap:-1 stays inside the wrapper */
}

#player-illustration {
  height: 100%;
  width: auto;
  display: block;
  position: relative; /* z-index: auto — sits above strap within wrapper */
}

/* Zero-size pivot point — position left/top to match the attachment spot on the illustration */
#player-strap-anchor {
  position: absolute;
  left: 71%;
  top: 35%;
  width: 0;
  height: 0;
  z-index: -1;
}

/* Strap hangs from the anchor's top-centre and swings like a pendulum */
#player-strap {
  position: absolute;
  left: 0;
  top: 0;
  height: 65vh;
  width: auto;
  transform-origin: 50% 0%;
  animation: strap-swing 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes strap-swing {
  0%   { transform: translateX(-50%) rotate(-14deg); }
  50%  { transform: translateX(-50%) rotate(14deg); }
  100% { transform: translateX(-50%) rotate(-14deg); }
}

.drawer-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color var(--t-fast);
}
.drawer-close-btn:hover { color: var(--accent); }
/* :focus-visible rule is in the global focus section above */

/* ── Signpost illustration (left half of drawer) ──────────────────── */

/* Signpost — anchored to the bottom-left of its panel.
   width: max-content matches the wrap to the rendered image width exactly so
   %-positioned overlay buttons track the image correctly at all viewport sizes.
   height: min() shrinks on narrow screens to prevent overflow into the player. */
.signpost-illustration-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  width: max-content;
  height: min(96vh, 77vw);
  isolation: isolate;
}

#signpost-base {
  height: 100%;
  width: auto;
  display: block;
  filter: brightness(1.45);
}

#signpost-lake {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: auto;
  pointer-events: none;
  filter: brightness(1.45);
  transform-origin: center center;
  transition: transform var(--t-mid) var(--ease-lake);
}

/* Remaining sign overlays — same base styles as #signpost-lake */
#sign-garden,
#sign-dock,
#sign-depths,
#sign-fireworks {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: auto;
  pointer-events: none;
  filter: brightness(1.45);
  transform-origin: center center;
  transition: transform var(--t-mid) var(--ease-lake);
}

/* Each button hover scales its associated sign overlay */
.signpost-illustration-wrap:has(#scene-btn-0:hover) #signpost-lake   { transform: scale(1.05); }
.signpost-illustration-wrap:has(#scene-btn-1:hover) #sign-garden     { transform: scale(1.05); }
.signpost-illustration-wrap:has(#scene-btn-2:hover) #sign-dock       { transform: scale(1.05); }
.signpost-illustration-wrap:has(#scene-btn-3:hover) #sign-depths     { transform: scale(1.05); }
.signpost-illustration-wrap:has(#scene-btn-4:hover) #sign-fireworks  { transform: scale(1.05); }

/* Invisible hit areas on the signpost.
   Each button has its own left/width so hit areas can be fine-tuned per sign. */
.signpost-overlay-btn {
  position: absolute;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1;
  transform: translateY(-50%);
}

#scene-btn-0 { top: 22%;   height: 16%; left: 22%; width: 48%; }
#scene-btn-1 { top: 37.5%; height: 14%; left: 32%; width: 48%; }
#scene-btn-2 { top: 52%;   height: 14%; left: 20%; width: 42%; }
#scene-btn-3 { top: 67.5%;   height: 16%; left: 30%; width: 41%; }
#scene-btn-4 { top: 84%;   height: 16%; left: 20%; width: 42%; }

/* Home button — top-left corner of the drawer */
.signpost-home-btn {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.3rem 0.7rem;
  pointer-events: auto;
  transition: border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  z-index: 5;
}

.signpost-home-btn:hover,
.signpost-home-btn:focus-visible,
.signpost-home-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--accent-glow);
}

/* Invisible hit areas overlaid on the illustration — adjust per button to match your image */
.player-overlay-btn {
  position: absolute;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1;
}

/* Positions are percentages of the illustration dimensions.
   Tweak left/top/width/height until each hit area aligns with its button in the image. */
#music-btn-prev {
  left: 52%;
  top:  32%;
  width: 10%;
  height: 9%;
  transform: translate(-50%, -50%);
}

#music-btn-stop {
  left: 52%;
  top:  41.75%;
  width: 10%;
  height: 9%;
  transform: translate(-50%, -50%);
}

#music-btn-play-pause {
  left: 62.5%;
  top:  32%;
  width: 10%;
  height: 9%;
  transform: translate(-50%, -50%);
}

#music-btn-next {
  left: 62.5%;
  top:  41.75%;
  width: 10%;
  height: 9%;
  transform: translate(-50%, -50%);
}

/* LCD screen overlay on the illustration — position/rotate to match the drawn screen */
#player-screen-overlay {
  position: absolute;
  left: 28%;
  top: 44%;
  width: 30%;
  height: 18%;
  transform: rotate(-50deg);
  transform-origin: center center;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  padding: 3% 6%;
  box-sizing: border-box;
  background: transparent;
  color: #fff;
  font-family: 'DM Mono', monospace;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  text-shadow: 0 0 6px rgba(160, 220, 255, 0.7);
}

#pso-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.4vh;
  opacity: 0.85;
  flex-shrink: 0;
}

/* Battery drawn with pseudo-elements — full charge (body filled, nub on right) */
#pso-battery {
  display: inline-flex;
  align-items: center;
}
#pso-battery::before {
  content: '';
  display: block;
  width: 1.5em;
  height: 0.65em;
  border: 1px solid currentColor;
  border-radius: 1px;
  padding: 1px;
  background-clip: content-box;
  background-color: currentColor;
}
#pso-battery::after {
  content: '';
  display: block;
  width: 2px;
  height: 0.4em;
  background: currentColor;
  border-radius: 0 1px 1px 0;
  margin-left: 1px;
}

#pso-title {
  margin: 0;
  font-size: 1.7vh;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

#pso-artist {
  margin: 0;
  font-size: 1.3vh;
  line-height: 1;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

.pso-marquee {
  display: inline-block;
  vertical-align: top;
  animation: pso-scroll var(--marquee-dur, 6s) linear infinite;
}

@keyframes pso-scroll {
  /* long pause at front */
  0%   { transform: translateX(0px); animation-timing-function: linear; }
  40%  { transform: translateX(0px); animation-timing-function: ease-in-out; }
  /* scroll to end */
  85%  { transform: translateX(var(--scroll-dist, 0px)); animation-timing-function: linear; }
  /* short pause at end — loop restart snaps back to front */
  100% { transform: translateX(var(--scroll-dist, 0px)); }
}

.pso-bottom-row {
  display: flex;
  align-items: center;
  gap: 4%;
  flex-shrink: 0;
}

#pso-status-icon {
  font-size: 1.4vh;
  flex-shrink: 0;
  display: inline-block;
  width: 1.2em;
  text-align: center;
}

.pso-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 1px;
  overflow: hidden;
}

#pso-progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width 0.15s linear;
}


/* Backdrop */
#drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 15, 0.5);
  pointer-events: auto;
  cursor: pointer;
  transition: opacity var(--t-mid);
  z-index: 29;
}


/* ── Utility ──────────────────────────────────────────────────────── */
.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Scene transition — full-screen ripple wipe */
#scene-wipe {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--lake-deep);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-mid) var(--ease-lake);
}

#scene-wipe.wipe-in  { opacity: 1; }
#scene-wipe.wipe-out { opacity: 0; }


/* ── Fireworks with Friends — silhouette overlay ─────────────────── */
/* Flex container anchors children to the bottom-centre of the viewport. */
.fireworks-sil-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow: hidden;
  pointer-events: none;
}
/* Black side bars — width set in px by JS; 0 on normal ≤1.9:1 screens */
.fireworks-sil-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  background: #000;
  width: 0;
  z-index: 3;
}
.fireworks-sil-bar-l { left:  0; }
.fireworks-sil-bar-r { right: 0; }
/* Image: JS sets exact px width+height; flex-end keeps its bottom flush */
.fireworks-sil-img {
  display: block;
  flex-shrink: 0;
  z-index: 4;
}
/* Lake water — canvas-rendered ripple animation; bottom + height set by JS */
.fireworks-water {
  position: absolute;
  left: 0; right: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.fireworks-water-cv,
.fireworks-shore-cv {
  display: block;
  width: 100%;
  height: 100%;
}
/* Near shore — dark curved strip at the base; height + border-radius set by JS */
.fireworks-near-shore {
  position: absolute;
  bottom: 0;
  left: -20%;
  width: 140%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
/* Far treeline — tiling PNG, positioned and sized in JS */
.fireworks-far-trees {
  position: absolute;
  background-image: url('images/far_trees.png');
  background-repeat: repeat-x;
  background-size: auto 100%;
  pointer-events: none;
  z-index: 2;
}

/* ── Garden Splash HUD (injected into #scene-overlay) ────────────── */
/*
  Shows a visual indicator of above/below water status
  and the current audio filter state.
  TODO: Add depth meter, filter visualizer, etc.
*/
.garden-splash-hud {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.garden-splash-depth-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.garden-splash-depth-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--lake-light);
  transition: color var(--t-mid);
}

.garden-splash-depth-value.underwater {
  color: var(--accent);
}

.garden-splash-hint {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
}


/* ── Portrait orientation warning (touch devices only) ───────────── */
#portrait-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--lake-void);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  pointer-events: auto;
}

@media (orientation: portrait) and (pointer: coarse) {
  #portrait-warning {
    display: flex;
  }
}

.portrait-warning-icon {
  font-size: 4rem;
  color: var(--accent);
  filter: drop-shadow(0 0 14px #00e5c388);
  display: block;
  animation: portrait-rotate-hint 2.4s var(--ease-lake) infinite;
}

@keyframes portrait-rotate-hint {
  0%, 100% { transform: rotate(0deg);   opacity: 0.5; }
  40%, 60%  { transform: rotate(90deg); opacity: 1;   }
}

.portrait-warning-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-align: center;
  padding: 0 2.5rem;
}

/* ── Info edge button (top right) ────────────────────────────────── */
.edge-btn--info {
  top: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
}

/* ── How-to-play modal ────────────────────────────────────────────── */
#info-modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 35;
  pointer-events: auto;
  background: rgba(3, 8, 15, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity var(--t-mid) var(--ease-lake);
}

.info-panel {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem 1.75rem;
  width: min(480px, 88vw);
  max-height: 80vh;
  overflow-y: auto;
}

.info-panel-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color var(--t-fast);
}
.info-panel-close:hover { color: var(--accent); }

.info-scene-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  margin-bottom: 1.5rem;
  padding-right: 2rem;
}

.info-section { margin-bottom: 1.25rem; }
.info-section:last-child { margin-bottom: 0; }

.info-section-label {
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.info-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(77, 184, 212, 0.07);
}
.info-row:last-child { border-bottom: none; }

.info-key {
  flex-shrink: 0;
  width: 6.5rem;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.info-desc {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ── Into the Depths Overlay ─────────────────────────────────────── */
.into-the-depths-coming-soon {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  pointer-events: none;
}

.into-the-depths-coming-soon__icon {
  font-size: 3rem;
  display: block;
}

.into-the-depths-coming-soon__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.into-the-depths-coming-soon__subtitle {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}


/* ── Home Screen — compact layout for small screens (phones in landscape) ── */
@media (max-height: 500px), (max-width: 560px) {
  /* Tighten vertical spacing so everything fits */
  .home-eyebrow  { margin-bottom: 0.6rem; letter-spacing: 0.2em; }
  .home-title    { margin-bottom: 1rem; gap: 0.15rem; }
  .home-rule     { margin-bottom: 1.25rem; }
  .home-copyright { margin-top: 1rem; }

  /* Ensure centered block doesn't bleed to edges */
  .home-content  { padding: 0 1rem; }

  /* Scale down vertical labels and let them wrap into a second column.
     max-height constrains each column so long strings break naturally.
     Left label switches to vertical-lr so its overflow column expands
     rightward (inward) rather than off the left edge. */
  .home-vertical {
    font-size: 0.58rem;
    letter-spacing: 0.18em;
    max-height: 14rem;
  }
  .home-vertical--left  { left: 0.35rem; writing-mode: vertical-lr; }
  .home-vertical--right { right: 0.35rem; }

  /* Tighten corner brackets to match smaller viewport */
  .home-corners span:nth-child(1),
  .home-corners span:nth-child(2) { top: 1rem; }
  .home-corners span:nth-child(3),
  .home-corners span:nth-child(4) { bottom: 1rem; }
  .home-corners span:nth-child(1),
  .home-corners span:nth-child(3) { left: 1rem; }
  .home-corners span:nth-child(2),
  .home-corners span:nth-child(4) { right: 1rem; }
}

/* ── Reduced Motion ───────────────────────────────────────────────── */
/* Respects the OS "reduce motion" accessibility setting.
   Collapses all CSS animations and transitions to near-instant so
   users sensitive to motion aren't affected.
   Note: Three.js RAF animations are JS-driven and not covered here. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
