/* Shared typography and controls. */
:root {
  color-scheme: dark;
  --bg: #0d1013;
  --panel: #161b21;
  --panel-strong: #12171d;
  --text: #e6e8e5;
  --cream: #f3f1ea;
  --muted: #a6aaa9;
  --amber: #d8bc91;
  --amber-soft: #b6a184;
  --cyan: #a6c9c6;
  --rose: #d6a0ad;
  --line: #ffffff16;
  --shadow: 0 24px 80px #0005;
  --font-body: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font-body); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 5px; }
h1, h2 { margin: 0; color: var(--cream); font-weight: 500; }
p { color: var(--muted); line-height: 1.85; }
.app-shell { position: relative; width: 100%; height: 100svh; }
.screen { position: absolute; inset: 0; display: none; overflow: hidden; }
.screen.is-active { display: flex; }
.eyebrow { color: var(--amber-soft); font-size: 10px; letter-spacing: .22em; }
.status-note { font-size: 12px; line-height: 1.75; }
.primary-button, .secondary-button, .ghost-button { min-height: 48px; padding: 12px 20px; line-height: 1.5; transition: background .2s, color .2s, transform .2s; }
.primary-button { border: 1px solid #f6f0e4; border-radius: 99px; background: #eee8dc; color: #222628; font-size: 14px; font-weight: 600; letter-spacing: .04em; }
.primary-button:hover:not(:disabled) { background: #fffaf0; transform: translateY(-1px); }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
.secondary-button { border: 1px solid #ffffff24; border-radius: 12px; background: #ffffff05; color: #d4d8d6; font-size: 13px; }
.secondary-button:hover:not(:disabled) { background: #ffffff0d; border-color: #ffffff48; }
.ghost-button { border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; }
.ghost-button:hover:not(:disabled) { color: var(--cream); background: #ffffff04; }

/* Title and ending keep the home as an indistinct memory. */
.screen-start, .screen-ending {
  flex-direction: column; align-items: center; justify-content: center;
  overflow-y: auto; text-align: center; isolation: isolate;
  padding: max(36px, env(safe-area-inset-top)) 24px max(36px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #0c111746, #080c12e8), url("./assets/ui/low-vision-home.png") center / cover;
}
.start-mark { position: relative; width: 100px; height: 100px; margin-bottom: 34px; flex-shrink: 0; }
.start-mark::before, .start-mark::after { content: ""; position: absolute; inset: 0; border: 1px solid #ded4ba42; border-radius: 50%; animation: breathe 6s ease-in-out infinite; }
.start-mark::after { inset: 20px; border-color: #b4ccca50; animation-delay: -3s; }
.start-mark-dot { position: absolute; inset: 46px; border-radius: 50%; background: #f5efde; box-shadow: 0 0 32px 9px #efd0a044; }
.start-copy { max-width: 500px; }
.start-copy h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(68px, 12vw, 100px); letter-spacing: .16em; margin: 22px 0; padding-left: .16em; }
.start-copy > p:last-child { color: #d0d3cf; font-size: 14px; letter-spacing: .08em; margin: 0 0 40px; }
#startButton, #playAgainButton { min-width: 220px; }
#startStatus { margin-top: 20px; font-size: 11px; }
.ending-copy { max-width: 420px; margin-bottom: 36px; }
.ending-copy h2 { margin: 24px 0; font-family: var(--font-display); font-size: 46px; }
.ending-copy > p:last-child { font-size: 14px; }

/* One quiet, unframed stage for every onboarding action. */
.screen-setup {
  flex-direction: column; align-items: center; overflow-y: auto; touch-action: pan-y;
  padding: max(30px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 25% 42%, #53575015, transparent 50%), radial-gradient(ellipse at 78% 70%, #5d514518, transparent 65%), #0e1216;
}
.setup-card { position: relative; flex: 0 0 auto; width: min(1000px, 100%); margin: auto 0; }
.setup-header { display: flex; align-items: center; justify-content: space-between; padding: 0 0 22px; gap: 24px; border-bottom: 1px solid #ffffff0c; }
.setup-brand { display: inline-flex; align-items: center; gap: 10px; color: #e4e7e2; font-size: 14px; font-weight: 500; letter-spacing: .12em; }
.setup-brand > i { width: 11px; height: 14px; background: linear-gradient(90deg, #d5c7aa 0 2px, transparent 2px 4.5px, #d5c7aa 4.5px 6.5px, transparent 6.5px 9px, #d5c7aa 9px 11px); border-radius: 2px; }
.setup-progress-group { display: flex; align-items: center; gap: 16px; }
#setupProgress { color: #97a09f; font-size: 10px; letter-spacing: .07em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.setup-track { height: 2px; width: 68px; background: #ffffff12; overflow: hidden; }
.setup-track span { display: block; width: 25%; height: 100%; background: #c8c4b4; transition: width .35s ease; }
.setup-stage { display: grid; grid-template-columns: 1.05fr 1fr; align-items: center; gap: 68px; min-height: 460px; padding: 42px 28px; }
.setup-content { min-width: 0; max-width: 372px; }
.guide-audio-status { display: inline-flex; align-items: center; gap: 8px; min-height: 18px; margin: -4px 0 14px; color: #a9bcb5; font-size: 10px; letter-spacing: .06em; }
.guide-audio-status > i { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border: 1px solid #a9bcb54a; border-radius: 50%; }
.guide-audio-status > i::before, .guide-audio-status > i::after { content: ""; position: absolute; width: 2px; border-radius: 2px; background: currentColor; }
.guide-audio-status > i::before { height: 5px; transform: translateX(-2px); }
.guide-audio-status > i::after { height: 9px; transform: translateX(2px); opacity: .62; }
.guide-audio-status[data-state="speaking"] > i { border-color: #c7d6bb9e; box-shadow: 0 0 0 4px #a6c9c615; }
.guide-audio-status[data-state="speaking"] > i::before { animation: guide-audio-wave .7s ease-in-out infinite alternate; }
.guide-audio-status[data-state="speaking"] > i::after { animation: guide-audio-wave .7s ease-in-out -.35s infinite alternate; }
.setup-content h2 { margin: 0 0 18px; font-family: var(--font-body); font-size: clamp(30px, 3.4vw, 39px); font-weight: 500; line-height: 1.3; letter-spacing: -.025em; outline: none; text-wrap: balance; }
#setupText { margin: 0; color: #b2b9b8; font-size: 14px; line-height: 1.9; }
#setupHint { margin: 20px 0; color: #939d9d; font-size: 12px; line-height: 1.7; }
.setup-next-button { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; margin-top: 24px; min-height: 50px; padding-left: 24px; padding-right: 24px; }
.setup-next-button::after { content: ""; display: block; width: 20px; height: 12px; flex: 0 0 20px; background: currentColor; clip-path: polygon(0 44%, 80% 44%, 56% 8%, 63% 0, 100% 50%, 63% 100%, 56% 92%, 80% 56%, 0 56%); opacity: .8; }
.setup-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.setup-tools .ghost-button { min-height: 38px; padding: 8px 10px; font-size: 11px; }
.setup-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #ffffff0c; }
.setup-footer:has(button:not([hidden])) { padding-top: 12px; }
.setup-footer:not(:has(button:not([hidden]))) { border: 0; }
.setup-footer .ghost-button { padding: 8px 2px; }
#setupBackButton::before { content: "←"; margin-right: 10px; }
#skipTutorialButton { margin-left: auto; }
.lesson-complete #setupHint { color: var(--cyan); }

/* Illustrations are floating objects, without a second card or a border. */
.setup-illustration { position: relative; height: 352px; isolation: isolate; }
.setup-illustration::before { content: ""; position: absolute; inset: 8% -2%; border-radius: 50%; background: radial-gradient(ellipse, #ba9c7130, #75a59c0a 50%, transparent 72%); }
.setup-art { position: absolute; inset: 0; display: none; align-items: center; justify-items: center; }
.setup-card[data-step="headphones"] .art-headphones,
.setup-card[data-step="stereo"] .art-headphones,
.setup-card[data-step="calibrate"] .art-device,
.setup-card[data-step="forward"] .art-device,
.setup-card[data-step="backward"] .art-device,
.setup-card[data-step="left"] .art-device,
.setup-card[data-step="right"] .art-device,
.setup-card[data-step="turnLeft"] .art-device,
.setup-card[data-step="turnRight"] .art-device,
.setup-card[data-step="collision"] .art-collision,
.setup-card[data-step="arrival"] .art-arrival,
.setup-card[data-step="ready"] .art-ready { display: grid; }
.art-headphones img { position: absolute; top: 50%; left: 50%; width: auto; height: 96%; max-width: 100%; object-fit: contain; transform: translate(-50%, -50%); filter: drop-shadow(0 24px 26px #0004); user-select: none; }
.listening-orbit { position: absolute; width: 96%; height: 38%; top: 39%; border: 1px solid #c8cbb119; border-radius: 50%; transform: rotate(-19deg); }
.listening-orbit::after { content: ""; position: absolute; inset: -12px 16px; border: 1px solid #a6c9c609; border-radius: inherit; }
.channel-indicators { position: absolute; bottom: -5px; left: 0; right: 0; display: none; justify-content: space-between; gap: 12px; padding: 0 7%; }
[data-step="stereo"] .channel-indicators { display: flex; }
.channel { display: flex; align-items: center; gap: 3px; height: 34px; padding: 0 11px; border-radius: 99px; border: 1px solid #ffffff1f; color: #8e9899; background: #13191dec; transition: color .2s, border-color .2s; }
.channel b { font: 500 10px var(--font-body); margin-right: 8px; }
.channel i { display: block; width: 2px; height: 5px; border-radius: 2px; background: currentColor; transform-origin: center; }
.channel i:nth-of-type(2) { height: 11px; }
.channel i:nth-of-type(3) { height: 7px; }
.channel small { margin-left: 8px; font-size: 9px; letter-spacing: .03em; white-space: nowrap; }
[data-audio-state="left"] .channel-left, [data-audio-state="complete"] .channel-left { color: #b6dfd6; border-color: #a6c9c678; }
[data-audio-state="right"] .channel-right, [data-audio-state="complete"] .channel-right { color: #e1cda7; border-color: #d8bc9180; }
[data-audio-state="left"] .channel-left i, [data-audio-state="right"] .channel-right i { animation: channel-pulse .55s ease-in-out infinite alternate; }
.gesture-label { position: absolute; bottom: -6px; left: 0; right: 0; text-align: center; font-size: 11px; letter-spacing: .12em; color: #acb5b2; }
.gesture-label:empty { display: none; }
.device-orbit { position: absolute; width: 240px; height: 110px; border: 1px solid #a6c9c626; border-radius: 50%; transform: rotate(-16deg); }
.device-body { position: relative; width: 112px; height: 216px; padding: 4px; border: 1px solid #aeb8b883; border-radius: 22px; background: linear-gradient(130deg, #6c7272, #20282b 40%, #728382); transform: perspective(700px) rotateY(-16deg) rotateZ(8deg); box-shadow: 6px 6px 0 #11171b, 8px 6px 1px #606c7070, 18px 28px 30px #0006; }
.device-screen { position: relative; width: 100%; height: 100%; border: 3px solid #11191d; border-radius: 18px; overflow: hidden; display: grid; place-items: center; background: radial-gradient(ellipse at 30% 70%, #71948666, transparent 65%), linear-gradient(140deg, #48564c, #161f24 50%, #323f49); }
.device-notch { position: absolute; top: 5px; width: 30px; height: 7px; border-radius: 99px; background: #0f1419; }
.device-ring { width: 44px; height: 44px; border: 1px solid #a6c9c64d; border-radius: 50%; box-shadow: 0 0 0 17px #a6c9c609; }
.device-point { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #eee9d6; box-shadow: 0 0 24px 7px #b1c8b45c; }
.device-home { position: absolute; bottom: 7px; width: 27px; height: 2px; border-radius: 99px; background: #f0f5ef64; }
[data-step="forward"][data-control-mode="tilt"] .device-body { animation: tilt-forward 3.2s ease-in-out infinite; }
[data-step="backward"][data-control-mode="tilt"] .device-body { animation: tilt-backward 3.2s ease-in-out infinite; }
[data-step="left"][data-control-mode="tilt"] .device-body { animation: tilt-left 3.2s ease-in-out infinite; }
[data-step="right"][data-control-mode="tilt"] .device-body { animation: tilt-right 3.2s ease-in-out infinite; }
[data-step="turnLeft"] .device-point { transform: translateX(-22px); }
[data-step="turnRight"] .device-point { transform: translateX(22px); }
[data-control-mode="keyboard"][data-setup-phase="tutorial"]:not([data-step="collision"]):not([data-step="arrival"]) .art-device { display: none; }
[data-control-mode="keyboard"][data-setup-phase="tutorial"]:not([data-step="collision"]):not([data-step="arrival"]) .art-keyboard { display: grid; }
.art-keyboard kbd { position: relative; display: grid; place-items: center; width: 120px; height: 108px; border: 1px solid #9da5a261; border-bottom: 8px solid #131c21; border-right: 6px solid #1c272a; border-radius: 20px; color: #e3e6da; background: linear-gradient(140deg, #49544f, #283339 70%); font: 400 38px var(--font-body); transform: perspective(700px) rotateX(18deg) rotateY(-18deg) rotateZ(12deg); box-shadow: 18px 30px 40px #0006, inset 3px 2px 4px #e4efe319; }
.key-shadow { position: absolute; width: 150px; height: 40px; top: 71%; border-radius: 50%; filter: blur(18px); background: #0005; }
.impact-wall { position: absolute; left: 25%; top: 20%; width: 24%; height: 55%; border-radius: 6px; background: linear-gradient(120deg, #485154, #222d32 74%); border: 1px solid #a4b5b327; transform: skewY(-12deg); box-shadow: -6px -2px 0 #121c22, 22px 16px 30px #0004; }
.impact-orb { position: absolute; left: 59%; top: 46%; width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #eed0c1, #9f6e70 65%, #5c4e54); box-shadow: 0 0 26px #d6a0ad30; }
.impact-wave { position: absolute; left: 53%; top: 29%; height: 38%; width: 20%; border-left: 1px solid #d6a0ad7f; border-radius: 50%; }
.art-arrival span { position: absolute; width: 58px; height: 58px; border: 1px solid #a6c9c684; border-radius: 50%; animation: arrival-orbit 4s ease-out infinite; }
.art-arrival span:nth-child(2) { animation-delay: -1.3s; }
.art-arrival span:nth-child(3) { animation-delay: -2.6s; }
.art-arrival i { width: 9px; height: 9px; border-radius: 50%; background: #dbe5d6; box-shadow: 0 0 32px 8px #a6c9c644; }
.door-frame { position: relative; width: 112px; height: 212px; padding: 5px; border: 1px solid #d3bd8f8a; border-radius: 2px; background: linear-gradient(125deg, #dac19b, #ae8b6266); box-shadow: 0 0 45px #dac19b22; transform: perspective(700px) rotateY(-16deg); }
.door-frame span { position: absolute; inset: 3px; background: #141d20; transform-origin: left; transform: perspective(300px) rotateY(-25deg); box-shadow: inset 1px 0 0 #ffffff22; }
.door-frame span::after { content: ""; position: absolute; right: 9px; top: 55%; width: 3px; height: 8px; border-radius: 3px; background: #ac9e84; }
.door-light { position: absolute; top: 79%; left: 21%; width: 66%; height: 25%; opacity: .55; background: linear-gradient(#cfb89364, transparent); clip-path: polygon(24% 0, 59% 0, 100% 100%, 0 100%); filter: blur(4px); }

/* Actual controls stay independent of decorative illustration assets. */
.control-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 22px; }
.control-option { position: relative; display: grid; justify-items: start; gap: 7px; min-width: 0; min-height: 100px; padding: 13px 10px; border: 1px solid #ffffff15; border-radius: 12px; background: #ffffff02; text-align: left; transition: border-color .2s, background .2s; }
.control-option svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; color: #a9b4b2; }
.control-option > span { font-size: 12px; white-space: nowrap; }
.control-option small { font-size: 10px; color: #9aa3a2; }
.control-option[aria-pressed="true"] { background: #cbd8c50c; border-color: #c3c9b9b0; }
.control-option[aria-pressed="true"]::after { content: ""; position: absolute; top: 13px; right: 11px; width: 5px; height: 5px; border-radius: 50%; background: #d8d9bf; }
.control-option:hover { border-color: #ffffff50; }
.audio-guide { margin-top: 24px; }
.audio-guide button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.audio-guide button::before { content: ""; width: 9px; height: 11px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
#audioTestStatus { min-height: 20px; margin: 10px 0 0; font-size: 11px; line-height: 1.8; color: #adb6b3; text-align: center; }
.practice-meter { height: 2px; margin-top: 22px; background: #ffffff13; }
.practice-meter span { display: block; height: 100%; background: var(--cyan); }
.practice-controls { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }
.practice-controls:empty { display: none; }
.movement-button { touch-action: none; user-select: none; -webkit-user-select: none; }
.practice-controls .movement-button { min-width: 144px; }
.movement-button:active, .movement-button.is-held { border-color: #c3c9b9; background: #cbd8c514; }
.setup-card.is-colliding .art-collision { animation: collision-shake 250ms ease; }

@keyframes breathe { 50% { transform: scale(1.06); opacity: .5; } }
@keyframes channel-pulse { from { transform: scaleY(.5); } to { transform: scaleY(1.2); } }
@keyframes tilt-forward { 50% { transform: perspective(700px) rotateX(35deg) rotateZ(8deg); } }
@keyframes tilt-backward { 50% { transform: perspective(700px) rotateX(-28deg) rotateZ(8deg); } }
@keyframes tilt-left { 50% { transform: perspective(700px) rotateZ(-16deg); } }
@keyframes tilt-right { 50% { transform: perspective(700px) rotateZ(24deg); } }
@keyframes arrival-orbit { from { transform: scale(.4); opacity: .6; } to { transform: scale(3.6); opacity: 0; } }
@keyframes guide-audio-wave { from { transform: translateX(-2px) scaleY(.65); opacity: .45; } to { transform: translateX(-2px) scaleY(1.25); opacity: 1; } }

/* ── Game screen ── */

.screen-game {
  background-color: #080b12;
  background-image: linear-gradient(180deg, rgba(4, 7, 13, 0.12), rgba(4, 7, 13, 0.52)), url("./assets/ui/low-vision-home.png");
  background-size: cover;
  background-position: center;
  isolation: isolate;
}

.screen-game.is-colliding {
  animation: collision-shake 180ms ease-out;
}

@keyframes collision-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-3px, 2px, 0); }
  55% { transform: translate3d(4px, -1px, 0); }
  78% { transform: translate3d(-2px, 1px, 0); }
}

/* Sound field rings */
.sound-field {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0.6;
  pointer-events: none;
}

.sound-field span {
  position: absolute;
  width: min(72vw, 340px);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--sight-accent, #e9bf81) 16%, transparent);
  border-radius: 50%;
  animation: pulse-ring 5.4s ease-in-out infinite;
}

.sound-field span:nth-child(2) {
  width: min(48vw, 220px);
  border-color: color-mix(in srgb, var(--sight-accent, #e9bf81) 11%, transparent);
  animation-delay: -1.8s;
}

.sound-field span:nth-child(3) {
  width: min(24vw, 110px);
  border-color: color-mix(in srgb, var(--sight-accent, #e9bf81) 9%, transparent);
  animation-delay: -3.4s;
}

.screen-game::before,
.screen-game::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.screen-game::before {
  z-index: 1;
  background:
    radial-gradient(circle at 50% 46%, color-mix(in srgb, var(--sight-accent, #e9bf81) 22%, transparent), transparent 30%),
    radial-gradient(ellipse at center, transparent 22%, color-mix(in srgb, var(--sight-scene, #5b657b) 19%, #090c13) 100%);
  opacity: 0.84;
  mix-blend-mode: screen;
  transition: opacity 600ms ease, background 700ms ease;
}

.screen-game::after {
  z-index: 2;
  background:
    radial-gradient(ellipse at center, transparent 0 34%, rgba(4, 7, 13, 0.12) 64%, rgba(4, 7, 13, 0.78) 100%),
    linear-gradient(115deg, color-mix(in srgb, var(--sight-scene, #5b657b) 13%, transparent), transparent 40%, color-mix(in srgb, var(--sight-accent, #e9bf81) 7%, transparent));
  opacity: 0.8;
  transition: opacity 500ms ease;
}

.screen-game[data-sight-mode="navigate"]::before {
  animation: sight-breathe 4.8s ease-in-out infinite;
}

.screen-game[data-sight-range="close"]::before {
  opacity: 0.96;
}

.screen-game[data-sight-range="near"]::before {
  opacity: 1;
  animation: sight-arrival 1.8s ease-out both;
}

.screen-game.is-colliding::after {
  background:
    radial-gradient(circle at 50% 48%, rgba(240, 110, 103, 0.28), transparent 36%),
    radial-gradient(ellipse at center, transparent 0 34%, rgba(142, 41, 61, 0.26) 72%, rgba(58, 16, 28, 0.68) 100%);
  animation: sight-impact 180ms ease-out;
}

@keyframes sight-breathe {
  0%, 100% { opacity: 0.62; }
  50% { opacity: 0.88; }
}

@keyframes sight-arrival {
  0% { opacity: 0.78; transform: scale(0.98); }
  45% { opacity: 1; transform: scale(1.02); }
  100% { opacity: 0.86; transform: scale(1); }
}

@keyframes sight-impact {
  0% { opacity: 0.8; }
  45% { opacity: 1; }
  100% { opacity: 0.8; }
}

@keyframes pulse-ring {
  0%, 100% {
    transform: scale(0.9);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.8;
  }
}

.arrival-ripple {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
}

.arrival-ripple.is-active {
  opacity: 1;
}

.arrival-ripple span {
  position: absolute;
  width: min(42vw, 190px);
  aspect-ratio: 1;
  border: 1px solid rgba(170, 223, 228, 0.32);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(170, 223, 228, 0.08) 0 18%, transparent 58%);
  box-shadow: 0 0 32px rgba(170, 223, 228, 0.08);
  opacity: 0;
  transform: scale(0.28);
}

.arrival-ripple.is-active span {
  animation: arrival-wave 1500ms cubic-bezier(0.18, 0.72, 0.28, 1) both;
}

.arrival-ripple.is-active span:nth-child(2) {
  animation-delay: 180ms;
}

.arrival-ripple.is-active span:nth-child(3) {
  animation-delay: 360ms;
}

@keyframes arrival-wave {
  0% {
    opacity: 0;
    transform: scale(0.22);
  }
  18% {
    opacity: 0.82;
  }
  100% {
    opacity: 0;
    transform: scale(2.65);
  }
}

/* ── Story panel (subtitle card) ── */

.story-panel {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  z-index: 12;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  min-height: 170px;
  padding: 24px 24px 22px 30px;
  border: 1px solid rgba(255, 248, 233, 0.2);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(27, 31, 47, 0.9), rgba(8, 13, 24, 0.82));
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(245, 239, 228, 0.04);
  backdrop-filter: blur(30px) saturate(1.12);
  -webkit-backdrop-filter: blur(30px) saturate(1.12);
}

.story-panel::before {
  content: "";
  position: absolute;
  top: 22px;
  bottom: 22px;
  left: 14px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(var(--amber), var(--cyan));
  opacity: 0.92;
  box-shadow: 0 0 18px rgba(239, 195, 127, 0.22);
}

.speaker-text,
.story-text,
.instruction-text {
  margin: 0;
  transition: opacity 200ms ease;
}

.speaker-text {
  color: var(--amber);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.story-text {
  color: var(--cream);
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 4.8vw, 1.38rem);
  font-weight: 400;
  line-height: 1.72;
  letter-spacing: 0.02em;
}

.instruction-text {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ── Turn zones ── */

.turn-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: 1fr 1fr;
  pointer-events: none;
}

.turn-zone {
  display: grid;
  place-items: center start;
  padding: 0 18px;
  color: rgba(245, 239, 228, 0.1);
  font-size: clamp(2.6rem, 16vw, 6rem);
  font-weight: 200;
  line-height: 1;
}

.turn-right {
  place-items: center end;
}

/* ── Debug ── */

.debug-hotspot {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  z-index: 18;
  width: 52px;
  height: 44px;
  background: transparent;
}

.debug-panel {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 16;
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 0.72rem;
  font-family: ui-monospace, "SF Mono", monospace;
  box-shadow: var(--shadow);
}

.debug-panel.is-visible {
  display: grid;
}


/* ── Developer ── */

.screen-developer {
  align-items: center;
  justify-content: center;
  padding: max(28px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse 70% 55% at 50% 12%, rgba(232, 168, 76, 0.05), transparent),
    linear-gradient(175deg, #0f0e13 0%, #0c0b0f 100%);
}

.developer-card {
  width: min(460px, 100%);
  padding: 24px 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: left;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.developer-login,
.developer-controls {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.developer-login label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.developer-login input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  padding: 0 14px;
  border-radius: 6px;
}

.developer-controls {
  display: none;
}

.developer-controls.is-visible {
  display: grid;
}

.setting-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.setting-row strong,
.setting-row small {
  display: block;
}

.setting-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

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

.segment-control label {
  cursor: pointer;
}

.segment-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment-control span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 700;
}

.segment-control input:checked + span {
  border-color: rgba(232, 168, 76, 0.46);
  color: var(--amber);
  background: rgba(232, 168, 76, 0.12);
}


/* Pause and in-game controls use the same small, quiet components. */
.pause-button { position: absolute; top: max(18px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); z-index: 18; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #ffffff2a; border-radius: 50%; background: #141c22b3; font-size: 0; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.pause-button::before { content: ""; width: 9px; height: 12px; border-left: 2px solid #dcdccb; border-right: 2px solid #dcdccb; }
.pause-button:hover { background: #283438; }
.pause-dialog { width: min(420px, calc(100% - 32px)); max-height: calc(100svh - 32px); overflow-y: auto; padding: 32px; border: 1px solid #ffffff20; border-radius: 20px; background: #151b20; color: var(--text); box-shadow: var(--shadow); }
.pause-dialog::backdrop { background: #070c14b8; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pause-dialog h2 { margin: 20px 0; font-size: 28px; font-weight: 500; }
.pause-dialog p { font-size: 13px; }
.pause-dialog label { display: block; margin: 22px 0 8px; color: var(--muted); font-size: 11px; }
.pause-dialog select { width: 100%; padding: 12px; border: 1px solid #ffffff24; border-radius: 10px; background: #222c30; }
.pause-dialog button { width: 100%; margin-top: 14px; }
#pauseStatus { color: #b6c8bc; font-size: 11px; }
.game-touch-controls { position: absolute; z-index: 15; top: 23%; left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: repeat(3, 54px); gap: 6px; padding: 8px; border: 1px solid #ffffff1a; border-radius: 16px; background: #141c22b3; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.game-touch-controls button { min-height: 46px; border-radius: 9px; padding: 7px 3px; font-size: 11px; }
.mic-actions { display: flex; gap: 8px; }
.mic-actions button { flex: 1; }
.screen-game { touch-action: none; }
noscript { position: fixed; bottom: 16px; right: 16px; z-index: 50; border-radius: 8px; padding: 16px; background: #48343b; color: #fff; }

@media (min-width: 800px) {
  .story-panel { left: 50%; right: auto; width: min(620px, calc(100% - 48px)); bottom: 26px; transform: translateX(-50%); }
}
@media (max-width: 900px) {
  .screen-setup { padding: max(28px, env(safe-area-inset-top)) 32px max(18px, env(safe-area-inset-bottom)); }
  .setup-card { width: min(580px, 100%); }
  .setup-stage { grid-template-columns: 1fr; gap: 14px; padding: 12px 0 24px; min-height: 0; }
  .setup-illustration { height: 248px; width: min(360px, 100%); margin: 0 auto; }
  .setup-content { width: min(360px, 100%); margin: 0 auto; text-align: center; }
  .guide-audio-status { justify-content: center; margin-top: -2px; }
  .setup-content h2 { font-size: 32px; margin-bottom: 14px; }
  #setupText { font-size: 13px; line-height: 1.9; }
  #setupHint { margin: 16px 0; font-size: 11px; }
  .setup-next-button { margin-top: 22px; }
  .setup-footer { width: min(360px, 100%); margin: 0 auto; }
  .art-device .device-body { width: 94px; height: 180px; border-radius: 20px; }
  .device-orbit { width: 210px; height: 88px; }
  .door-frame { width: 90px; height: 174px; }
  .door-light { top: 83%; height: 16%; }
  .channel-indicators { bottom: 2px; padding: 0 4%; }
}
@media (max-width: 480px) {
  .screen-setup { padding-left: 24px; padding-right: 24px; }
  .setup-progress-group { gap: 10px; }
  .setup-track { width: 36px; }
  .setup-header { gap: 10px; padding-bottom: 18px; }
  #setupProgress { font-size: 9px; }
  .setup-illustration { height: clamp(206px, 31svh, 268px); width: min(300px, 100%); }
  .setup-stage { padding-top: 12px; gap: 22px; }
  .setup-content h2 { font-size: 30px; }
  .story-panel { left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); padding: 20px 20px 20px 26px; min-height: 156px; }
  .story-text { font-size: 18px; }
  .instruction-text { font-size: 12px; }
  .control-option { padding: 12px 9px; }
}
@media (max-height: 680px) and (max-width: 900px) {
  .screen-setup { padding-top: max(18px, env(safe-area-inset-top)); }
  .setup-header { padding-bottom: 14px; }
  .setup-illustration { height: 166px; width: 240px; }
  .setup-stage { gap: 12px; padding-top: 12px; padding-bottom: 12px; }
  .setup-content h2 { font-size: 27px; margin-bottom: 10px; }
  .setup-next-button { margin-top: 14px; }
  #setupHint { margin: 12px 0; }
  .channel-indicators { bottom: -6px; left: -16px; right: -16px; }
  .channel small { display: none; }
  .device-body { transform: scale(.7); }
  .art-device .device-body { width: 76px; height: 145px; transform: rotate(8deg); }
  .device-orbit { width: 150px; height: 68px; }
  .door-frame { width: 65px; height: 130px; }
  .art-keyboard kbd { width: 100px; height: 84px; font-size: 30px; }
  .control-choice, .audio-guide { margin-top: 14px; }
  .control-option { min-height: 88px; gap: 4px; padding-top: 10px; padding-bottom: 10px; }
  .practice-meter { margin-top: 12px; }
  .start-mark { width: 80px; height: 80px; margin-bottom: 14px; }
  .start-mark-dot { inset: 36px; }
}
@media (max-width: 375px) and (max-height: 650px) {
  .setup-illustration { height: 132px; }
  .setup-stage { gap: 10px; }
  .setup-content h2 { font-size: 26px; }
  .setup-next-button { min-height: 46px; margin-top: 12px; }
  .setup-footer .ghost-button { min-height: 42px; font-size: 11px; }
  .art-device .device-body { width: 62px; height: 119px; border-radius: 15px; }
  .device-screen { border-radius: 11px; }
  .device-orbit { width: 130px; height: 60px; }
  .door-frame { width: 56px; height: 110px; }
  .gesture-label { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .art-arrival span { opacity: .35; }
  .art-arrival span:nth-child(2) { transform: scale(2); }
  .art-arrival span:nth-child(3) { transform: scale(3); }
}
