:root {
  color-scheme: dark;
  --ink: #4b3769;
  --cream: #fff2e9;
  --pink: #f4b8d4;
  --soft-white: #fff9ff;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button { font: inherit; }

body {
  min-height: 100svh;
  overflow: hidden;
  background: #6d58aa;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  cursor: url("../assets/cursor-heart.png") 8 5, auto;
}

.game-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
  color: var(--soft-white);
}

.room, .night-glow { position: absolute; inset: 0; }
.room {
  z-index: -5;
  background: url("../assets/bedroom-night.png") center / cover no-repeat;
  transform: scale(1.015);
}
.night-glow {
  z-index: -4;
  background:
    linear-gradient(180deg, rgba(64, 42, 117, .08), transparent 42%),
    radial-gradient(circle at 50% 72%, rgba(240, 196, 255, .22), transparent 34%),
    linear-gradient(90deg, rgba(45, 30, 80, .12), transparent 25% 75%, rgba(45, 30, 80, .12));
  pointer-events: none;
}

.stars { position: absolute; inset: 0; z-index: -3; pointer-events: none; }
.star {
  position: absolute;
  width: var(--size);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff4d7;
  box-shadow: 0 0 8px 2px rgba(255, 225, 183, .76);
  animation: twinkle var(--speed) ease-in-out var(--delay) infinite;
}
.star::before, .star::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 320%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent);
  transform: translate(-50%, -50%);
}
.star::after { transform: translate(-50%, -50%) rotate(90deg); }

.utility-controls {
  position: absolute;
  z-index: 20;
  top: var(--safe-top);
  right: max(20px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
}
.sound-icon, .settings-icon {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sound-icon path:first-child { fill: currentColor; stroke: currentColor; }
.sound-icon--off { display: none; }
#sound-toggle[aria-pressed="true"] .sound-icon--on { display: none; }
#sound-toggle[aria-pressed="true"] .sound-icon--off { display: block; }
.audio-settings {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(76vw, 250px);
  padding: 16px;
  border: 2px solid rgba(255,255,255,.78);
  border-radius: 18px;
  color: white;
  background: linear-gradient(145deg, rgba(83, 57, 143, .92), rgba(119, 78, 174, .88));
  box-shadow: 0 16px 38px rgba(45, 26, 83, .32), inset 0 0 22px rgba(255,255,255,.08);
  backdrop-filter: blur(14px);
}
.audio-settings[hidden] { display: none; }
.audio-setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-items: center;
  font-size: .93rem;
}
.audio-setting-row + .audio-setting-row { margin-top: 16px; }
.audio-setting-row output { color: #f7d5e8; font-variant-numeric: tabular-nums; }
.audio-setting-row input { grid-column: 1 / -1; width: 100%; accent-color: #f1acd0; cursor: pointer; }
.icon-button {
  width: 46px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 14px;
  color: white;
  background: rgba(100, 71, 159, .34);
  box-shadow: inset 0 0 0 2px rgba(117, 76, 156, .22), 0 6px 20px rgba(57, 34, 100, .2);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.icon-button:hover { transform: translateY(-2px); background: rgba(130, 91, 188, .5); }
.icon-button:focus-visible, button:focus-visible { outline: 3px solid #fff0ae; outline-offset: 4px; }
.icon-button[aria-pressed="true"] { background: rgba(244, 184, 212, .62); }

.title-block {
  position: absolute;
  z-index: 10;
  top: clamp(58px, 8vh, 94px);
  left: 50%;
  width: min(92vw, 780px);
  transform: translateX(-50%);
  text-align: center;
  text-shadow: 0 3px 10px rgba(73, 41, 114, .6);
}
.logo {
  position: relative;
  display: inline-grid;
  place-items: center;
  margin: 0 0 13px;
  min-width: 105px;
  min-height: 48px;
  color: #fff0df;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
  letter-spacing: -.08em;
  filter: drop-shadow(0 0 9px rgba(255, 220, 221, .72));
}
.logo-orbit {
  position: absolute;
  inset: 7px -7px 5px;
  border: 2px solid rgba(255, 226, 226, .84);
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(-9deg);
}
.logo-heart {
  position: absolute;
  right: -1px;
  bottom: 6px;
  font-family: inherit;
  font-size: .35em;
  letter-spacing: 0;
  color: #f7bfd7;
}
.title-block p {
  margin: 0;
  font-family: "Kaiti SC", "STKaiti", "PingFang SC", sans-serif;
  font-size: clamp(1.2rem, 2.2vw, 2rem);
  letter-spacing: .18em;
}

.story-stage {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: clamp(160px, 23vh, 230px);
  width: min(90vw, 950px);
  height: min(50vh, 440px);
  transform: translateX(-50%);
}
.character {
  position: absolute;
  z-index: 4;
  bottom: -106px;
  width: clamp(155px, 17vw, 235px);
  aspect-ratio: 2 / 3;
  transform-origin: 50% 100%;
  will-change: transform;
}
.character img { width: 100%; height: 100%; object-fit: contain; display: block; }
.character--girl { left: 2%; animation: girlIdle 4.2s ease-in-out infinite; }
.character--boy { right: 3%; animation: boyIdle 4.6s ease-in-out -.8s infinite; }

.message-window {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 18%;
  width: min(40vw, 380px);
  aspect-ratio: 1.6;
  transform: translateX(-50%);
  border: 2px solid rgba(255,255,255,.72);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(226, 207, 255, .3), rgba(179, 148, 229, .14));
  box-shadow: inset 0 0 28px rgba(255,255,255,.15), 0 16px 45px rgba(69, 40, 119, .16);
  backdrop-filter: blur(8px);
}
.window-dots { display: flex; gap: 7px; padding: 14px 17px; }
.window-dots i { width: 8px; aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,.83); }
.bubble { position: absolute; height: 20%; border-radius: 18px; background: rgba(255,255,255,.34); display: flex; align-items: center; justify-content: center; gap: 7px; }
.bubble--left { top: 28%; left: 10%; width: 32%; }
.bubble--right { top: 44%; right: 11%; width: 29%; }
.bubble span { width: 7px; aspect-ratio: 1; border-radius: 50%; background: rgba(111, 78, 167, .58); }
.message-input { position: absolute; left: 11%; right: 11%; bottom: 12%; height: 20%; border: 2px solid rgba(255,255,255,.72); border-radius: 18px; }
.cursor-line { position: absolute; left: 12%; top: 25%; width: 2px; height: 50%; background: white; animation: cursorBlink 1.1s steps(1) infinite; }
.send-arrow { position: absolute; right: 7%; top: 50%; transform: translateY(-50%) rotate(-25deg); color: white; font-size: 1.4rem; }
.pixel-heart { position: absolute; right: -1%; bottom: -6%; color: #f6c5e0; font-size: 2rem; text-shadow: 2px 2px 0 #69498d, -2px -2px 0 white; animation: tinyHeart 1.5s ease-in-out infinite; }

.start-panel {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: var(--safe-bottom);
  width: min(86vw, 360px);
  transform: translateX(-50%);
  text-align: center;
}
.start-button {
  position: relative;
  width: 100%;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 14px 30px;
  border: 3px solid #fff8f2;
  border-radius: 25px;
  color: var(--ink);
  background: linear-gradient(180deg, #fff3ea, #ffdfe5);
  box-shadow: 0 0 0 4px rgba(127, 83, 172, .48), 0 0 0 10px rgba(255, 215, 239, .16), 0 10px 22px rgba(68, 38, 102, .28);
  cursor: pointer;
  animation: startPulse 1.55s ease-in-out infinite;
}
.start-button::before, .start-button::after {
  content: "";
  position: absolute;
  inset: -7px;
  border: 2px solid rgba(255, 224, 244, .58);
  border-radius: 31px;
  animation: pulseRing 1.55s ease-out infinite;
  pointer-events: none;
}
.start-button::after { animation-delay: .5s; }
.start-button strong { font-size: clamp(1.7rem, 3vw, 2.25rem); letter-spacing: .18em; transform: translateX(.09em); }
.start-button > span { color: #e79ac3; text-shadow: 1px 1px white; }
.start-button:hover { filter: brightness(1.05); }
.continue-button {
  margin-top: 12px;
  padding: 5px 24px 8px;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,.78);
  color: white;
  background: transparent;
  font-size: 1.12rem;
  letter-spacing: .18em;
  text-shadow: 0 2px 7px rgba(65, 38, 105, .7);
  cursor: pointer;
}
.status-message { min-height: 1.2em; margin: 5px 0 0; font-size: .82rem; color: rgba(255,255,255,.88); }

.login-screen {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 28px) 20px calc(var(--safe-bottom) + 28px);
  background: linear-gradient(180deg, rgba(56, 36, 103, .32), rgba(63, 39, 111, .56));
  backdrop-filter: blur(10px) saturate(.9);
  opacity: 0;
  transition: opacity .32s ease;
}
.login-screen[hidden] { display: none; }
.login-active .login-screen { opacity: 1; }
.login-card {
  position: relative;
  width: min(90vw, 410px);
  padding: 36px 38px 29px;
  border: 2px solid rgba(255, 248, 255, .78);
  border-radius: 30px;
  color: var(--soft-white);
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 221, 241, .22), transparent 35%),
    linear-gradient(145deg, rgba(116, 82, 177, .88), rgba(74, 54, 139, .9));
  box-shadow: 0 24px 70px rgba(42, 25, 79, .4), inset 0 0 34px rgba(255,255,255,.1);
  transform: translateY(18px) scale(.97);
  transition: transform .38s cubic-bezier(.2, .8, .2, 1);
}
.login-active .login-card { transform: translateY(0) scale(1); }
.login-back {
  position: absolute;
  top: 18px;
  left: 20px;
  padding: 6px 9px;
  border: 0;
  color: rgba(255,255,255,.84);
  background: transparent;
  font-size: .85rem;
  cursor: pointer;
}
.login-mark { position: relative; display: inline-grid; place-items: center; width: 72px; height: 44px; margin-bottom: 5px; }
.login-mark strong { z-index: 1; color: #fff0df; font: 700 2rem/1 Georgia, serif; letter-spacing: -.08em; }
.login-mark i { position: absolute; right: 3px; bottom: 6px; color: #f7bfd7; font-size: .65rem; font-style: normal; }
.login-orbit { position: absolute; inset: 6px 0 4px; border: 1.5px solid rgba(255, 231, 235, .86); border-left-color: transparent; border-radius: 50%; transform: rotate(-9deg); }
.login-kicker { margin: 5px 0 9px; color: #f3c9df; font: 600 .64rem/1.2 Georgia, serif; letter-spacing: .3em; }
.login-card h2 { margin: 0; font: 500 clamp(1.65rem, 5vw, 2.05rem)/1.3 "Kaiti SC", "STKaiti", "PingFang SC", sans-serif; letter-spacing: .08em; }
.login-copy { margin: 9px 0 21px; color: rgba(255,255,255,.72); font-size: .84rem; line-height: 1.7; }
.login-form { text-align: left; }
.login-form label { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 8px; color: rgba(255,255,255,.9); font-size: .81rem; }
.login-form label small { color: rgba(255,255,255,.46); font-size: .66rem; font-weight: 400; }
.story-id-field { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 17px; border: 1.5px solid rgba(255,255,255,.62); border-radius: 17px; background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.09)); box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 8px 18px rgba(42,25,79,.11); }
.story-id-field:focus-within { border-color: #ffe9a9; box-shadow: 0 0 0 3px rgba(255, 235, 161, .13), inset 0 1px 0 rgba(255,255,255,.14); }
.story-id-field > span { width: 27px; aspect-ratio: 1; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #61458d; background: #f3d2e3; font-weight: 800; }
.story-id-field input { appearance: none; -webkit-appearance: none; width: 100%; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 0; outline: 0; color: white; -webkit-text-fill-color: white; background: transparent !important; box-shadow: none !important; font: inherit; }
.story-id-field input::placeholder { color: rgba(255,255,255,.47); }
.login-submit { width: 100%; min-height: 50px; margin-top: 13px; display: flex; align-items: center; justify-content: center; gap: 14px; border: 2px solid #fff7f1; border-radius: 16px; color: var(--ink); background: linear-gradient(180deg, #fff3ea, #ffdce6); box-shadow: 0 7px 18px rgba(45, 28, 83, .24); font-weight: 700; letter-spacing: .08em; cursor: pointer; transition: transform .18s ease, filter .18s ease; }
.login-submit:hover { transform: translateY(-2px); filter: brightness(1.04); }
.login-submit b { font-size: 1.2rem; }
.login-status { min-height: 1.3em; margin: 9px 2px 0; color: #ffe5ae; font-size: .76rem; line-height: 1.4; text-align: center; }
.login-note { margin: 12px 0 0; color: rgba(255,255,255,.56); font-size: .69rem; line-height: 1.6; }
.login-note span { color: #f4bad5; }
body.login-active .title-block,
body.login-active .story-stage,
body.login-active .start-panel,
body.login-active .utility-controls { filter: blur(3px); pointer-events: none; }

.onboarding-screen {
  position: absolute;
  z-index: 40;
  inset: 0;
  overflow: hidden;
  color: white;
  background:
    linear-gradient(180deg, rgba(62, 43, 111, .14), rgba(69, 45, 116, .24)),
    url("../assets/bedroom-night.png") center / cover no-repeat;
  opacity: 0;
  transition: opacity .35s ease;
}
.onboarding-screen[hidden] { display: none; }
.onboarding-active .onboarding-screen { opacity: 1; }
.onboarding-topbar {
  position: absolute;
  z-index: 5;
  top: var(--safe-top);
  left: max(24px, env(safe-area-inset-left));
  right: max(24px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  color: rgba(255,255,255,.8);
  font-size: .82rem;
}
.scene-back { justify-self: start; padding: 8px; border: 0; color: inherit; background: transparent; }
.scene-logo { position: relative; color: #fff0df; font: 700 1.65rem/1 Georgia, serif; filter: drop-shadow(0 0 8px rgba(255,215,230,.55)); }
.scene-logo i { color: #f3b3d2; font-size: .5em; font-style: normal; }
.scene-step { justify-self: end; font-variant-numeric: tabular-nums; letter-spacing: .14em; }
.solo-character {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: clamp(245px, 32vh, 330px);
  width: clamp(185px, 20vw, 260px);
  aspect-ratio: 2 / 3;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  animation: soloIdle 4.3s ease-in-out infinite;
}
.solo-character img { width: 100%; height: 100%; display: block; object-fit: contain; }
.onboarding-dialogue {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(24px, var(--safe-bottom));
  width: min(90vw, 660px);
  min-height: 235px;
  padding: 30px 38px 25px;
  border: 2px solid rgba(255,255,255,.8);
  border-radius: 27px;
  background: linear-gradient(145deg, rgba(94, 65, 161, .93), rgba(65, 47, 126, .93));
  box-shadow: 0 22px 65px rgba(42, 24, 79, .36), inset 0 0 30px rgba(255,255,255,.09);
  backdrop-filter: blur(14px);
  transform: translateX(-50%);
}
.speaker-name { position: absolute; top: -19px; left: 34px; margin: 0; padding: 8px 23px; border: 2px solid rgba(255,255,255,.78); border-radius: 14px; color: #4b3769; background: linear-gradient(180deg, #fff3ea, #ffdce6); font-weight: 700; }
.onboarding-dialogue h2 { min-height: 2.8em; margin: 3px 0 17px; font: 500 clamp(1.15rem, 2.4vw, 1.48rem)/1.55 "Kaiti SC", "STKaiti", "PingFang SC", sans-serif; letter-spacing: .04em; text-align: center; }
.answer-area { min-height: 52px; }
.story-answer-input { width: 100%; height: 50px; padding: 0 17px; border: 1.5px solid rgba(255,255,255,.65); border-radius: 15px; outline: none; color: white; background: rgba(255,255,255,.12); font: inherit; }
.story-answer-input:focus { border-color: #fff1b5; box-shadow: 0 0 0 3px rgba(255,239,175,.12); }
.story-answer-input::placeholder { color: rgba(255,255,255,.48); }
.custom-choice-input { height: 43px; margin-top: 9px; }
.custom-choice-input[hidden] { display: none; }
.answer-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.answer-choice { min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1.5px solid rgba(255,255,255,.42); border-radius: 13px; background: rgba(255,255,255,.09); cursor: url("../assets/cursor-heart.png") 8 5, pointer; }
.answer-choice:has(input:checked) { border-color: #ffe7a6; background: rgba(255,224,236,.2); }
.answer-choice input { position: absolute; opacity: 0; pointer-events: none; }
.answer-choice span { width: 25px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; color: #5d4186; background: #f5d5e4; font-size: .76rem; font-weight: 800; }
.answer-choice b { font-size: .86rem; font-weight: 500; }
.dialogue-next { min-width: 118px; height: 42px; margin: 14px auto 0; display: flex; align-items: center; justify-content: center; gap: 10px; border: 2px solid white; border-radius: 14px; color: var(--ink); background: linear-gradient(180deg, #fff3ea, #ffdce6); font-weight: 700; }
.dialogue-status { min-height: 1em; margin: 7px 0 0; color: #ffe5ae; font-size: .72rem; text-align: center; }

.bedroom-game {
  position: absolute;
  z-index: 50;
  inset: 0;
  overflow: hidden;
  color: white;
  background:
    linear-gradient(180deg, rgba(58, 40, 105, .03), rgba(69, 45, 116, .08)),
    url("../assets/bedroom-game-desktop.png") center / cover no-repeat;
}
.bedroom-game[hidden] { display: none; }
body.bedroom-game-active .utility-controls { z-index: 70; }
.bedroom-game[data-scene="crossroads"] { background-image: linear-gradient(180deg, rgba(34,48,89,.04), rgba(76,53,111,.08)), url("../assets/crossroads-night.png"); }
.bedroom-game[data-scene="shop-exterior"] { background-image: linear-gradient(180deg, rgba(34,48,89,.03), rgba(76,53,111,.08)), url("../assets/replay-shop-exterior.png"); }
.bedroom-game[data-scene="shop-interior"] { background-image: linear-gradient(180deg, rgba(34,48,89,.02), rgba(76,53,111,.06)), url("../assets/replay-shop-interior.png"); }
.bedroom-game[data-scene="question-exterior"] { background-image: linear-gradient(180deg, rgba(34,48,89,.03), rgba(76,53,111,.06)), url("../assets/question-house-exterior.png"); }
.bedroom-game[data-scene="question-interior"] { background-image: linear-gradient(180deg, rgba(38,46,82,.03), rgba(66,50,93,.06)), url("../assets/question-house-interior.png"); }
.bedroom-game:not([data-scene="bedroom"]):not([data-scene="memory-bedroom"]) .room-girl,
.bedroom-game:not([data-scene="bedroom"]):not([data-scene="memory-bedroom"]) .npc-dialogue { display: none; }
.bedroom-game[data-scene="memory-bedroom"] { background-image: linear-gradient(180deg, rgba(38,46,82,.08), rgba(66,50,93,.13)), url("../assets/memory-bedroom-game-desktop.png"); }
.bedroom-game[data-scene="memory-bedroom"] .game-exit,
.bedroom-game[data-scene="memory-bedroom"] .game-save-cluster,
.bedroom-game[data-scene="memory-bedroom"] .movement-hint,
.bedroom-game[data-scene="memory-bedroom"] .affection-control { display: none; }
.game-hud { position: absolute; z-index: 8; top: var(--safe-top); left: max(20px, env(safe-area-inset-left)); right: max(20px, env(safe-area-inset-right)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; }
.game-exit { justify-self: start; padding: 9px 11px; border: 1px solid rgba(255,255,255,.5); border-radius: 12px; color: white; background: rgba(72,48,128,.34); backdrop-filter: blur(8px); }
.game-save-cluster { justify-self: center; display: flex; align-items: center; gap: 7px; }
.game-save-chip { display: flex; align-items: center; gap: 9px; padding: 8px 15px; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; background: rgba(72,48,128,.36); backdrop-filter: blur(8px); font-size: .76rem; }
.game-save-chip span { color: #f2bdd8; }
.game-save-chip strong { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-save-button { min-height: 34px; padding: 7px 13px; border: 1.5px solid rgba(255,255,255,.78); border-radius: 999px; color: #65477f; background: linear-gradient(180deg,#fff5f0,#ffdce9); box-shadow: 0 6px 15px rgba(48,31,83,.22); font-weight: 700; }
.movement-hint { position: absolute; right: 112px; top: 0; margin: 0; padding: 9px 12px; border-radius: 12px; color: rgba(255,255,255,.8); background: rgba(72,48,128,.28); font-size: .72rem; backdrop-filter: blur(8px); }
.movement-hint kbd { padding: 2px 5px; border: 1px solid rgba(255,255,255,.5); border-radius: 5px; color: white; background: rgba(255,255,255,.12); font: inherit; }
.scene-name { position: absolute; z-index: 7; top: calc(var(--safe-top) + 48px); left: 50%; margin: 0; padding: 6px 16px; border-radius: 999px; color: rgba(255,255,255,.88); background: rgba(60,45,105,.3); box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); backdrop-filter: blur(7px); transform: translateX(-50%); font-size: .72rem; letter-spacing: .12em; }
.room-player { position: absolute; z-index: 4; width: clamp(110px, 9vw, 142px); aspect-ratio: 2 / 3; transform: translate(-50%, -50%); transform-origin: 50% 100%; will-change: left, top, transform; }
.room-player::after { content: ""; position: absolute; z-index: -1; left: 21%; right: 21%; bottom: 4%; height: 7%; border-radius: 50%; background: rgba(55,31,89,.2); filter: blur(3px); }
.room-player img { width: 100%; height: 100%; display: block; object-fit: contain; opacity: 0; }
.room-player img.is-mirrored { transform: scaleX(-1); }
.room-player::before { content: ""; position: absolute; left: 50%; bottom: 1%; width: 112%; aspect-ratio: 1; background: url("../assets/boy-walk-cycle-sheet.png") 0 0 / 600% 300% no-repeat; transform: translateX(-50%); }
.room-player[data-walk-frame="1"]::before { background-position-x: 20%; }
.room-player[data-walk-frame="2"]::before { background-position-x: 40%; }
.room-player[data-walk-frame="3"]::before { background-position-x: 60%; }
.room-player[data-walk-frame="4"]::before { background-position-x: 80%; }
.room-player[data-walk-frame="5"]::before { background-position-x: 100%; }
.room-player[data-facing="back"]::before { background-position-y: 50%; }
.room-player[data-facing="left"]::before,
.room-player[data-facing="right"]::before { background-position-y: 100%; }
.room-player[data-facing="right"]::before { transform: translateX(-50%) scaleX(-1); }
.room-girl { position: absolute; z-index: 5; left: 23%; top: 68%; width: clamp(120px, 9.2vw, 150px); aspect-ratio: 3 / 4; padding: 0; border: 0; outline: 0; color: #f49ac3; background: transparent; transform: translate(-50%, -50%); cursor: url("../assets/cursor-heart.png") 8 5, pointer; }
.room-girl::after { content: ""; position: absolute; z-index: -1; left: 18%; right: 18%; bottom: 2%; height: 7%; border-radius: 50%; background: rgba(55,31,89,.2); filter: blur(3px); }
.room-girl-sprite { position: absolute; inset: 0; display: block; background-image: url("../assets/girl-bed-interaction-strip.png"); background-repeat: no-repeat; background-size: 400% 100%; background-position: 0 0; transition: filter .2s ease; }
.room-girl[data-frame="1"] .room-girl-sprite { background-position: 33.333% 0; }
.room-girl[data-frame="2"] .room-girl-sprite { background-position: 66.666% 0; }
.room-girl[data-frame="3"] .room-girl-sprite { background-position: 100% 0; }
.room-girl.is-near .room-girl-sprite { filter: drop-shadow(0 0 10px rgba(255,190,225,.54)); }
.interaction-heart { position: absolute; top: -12%; right: -2%; font-size: clamp(1.5rem, 2.3vw, 2.15rem); color: #f49ac3; text-shadow: 0 0 9px rgba(255,190,225,.9), 1px 1px white; animation: tinyHeart 1.5s ease-in-out infinite; }
.room-girl:not(.is-near) .interaction-heart { opacity: .5; transform: scale(.8); }
.npc-dialogue { position: absolute; z-index: 12; left: 50%; bottom: max(34px, calc(var(--safe-bottom) + 8px)); width: min(70vw, 520px); min-height: 112px; padding: 33px 54px 22px; border: 2px solid rgba(255,255,255,.84); border-radius: 24px; color: #4b3769; background: linear-gradient(180deg, rgba(255,246,250,.96), rgba(255,220,234,.95)); box-shadow: 0 18px 45px rgba(45,28,83,.3), inset 0 0 22px rgba(255,255,255,.55); transform: translateX(-50%); }
.npc-dialogue[hidden] { display: none; }
.npc-dialogue p { margin: 7px 0 0; font: 600 clamp(1.15rem, 2.3vw, 1.55rem)/1.5 "Kaiti SC", "STKaiti", sans-serif; letter-spacing: .08em; }
.npc-speaker { position: absolute; top: -18px; left: 28px; padding: 7px 22px; border: 2px solid white; border-radius: 13px; color: white; background: #a17ac8; font-weight: 700; }
.npc-dialogue button { position: absolute; top: 12px; right: 14px; width: 34px; aspect-ratio: 1; border: 0; border-radius: 50%; color: #765494; background: rgba(255,255,255,.5); font-size: 1.25rem; }
.affection-control { position: absolute; z-index: 15; left: max(20px, env(safe-area-inset-left)); bottom: max(20px, env(safe-area-inset-bottom)); }
.affection-button { min-width: 96px; height: 52px; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 0 17px; border: 2px solid rgba(255,255,255,.82); border-radius: 18px; color: white; background: linear-gradient(145deg, rgba(238,132,181,.88), rgba(197,101,160,.88)); box-shadow: 0 10px 25px rgba(78,44,98,.28), inset 0 0 15px rgba(255,255,255,.15); backdrop-filter: blur(9px); }
.affection-button span { color: #ffd7e9; font-size: 1.35rem; filter: drop-shadow(0 0 5px rgba(255,220,235,.7)); }
.affection-button strong { font-variant-numeric: tabular-nums; }
.affection-popup { position: absolute; left: 0; bottom: calc(100% + 10px); width: min(76vw, 250px); padding: 17px; border: 2px solid rgba(255,255,255,.82); border-radius: 19px; color: #5b3e73; background: rgba(255,239,247,.96); box-shadow: 0 18px 40px rgba(50,29,78,.28); }
.affection-popup[hidden] { display: none; }
.affection-popup > div:first-child { display: flex; justify-content: space-between; align-items: center; }
.affection-popup strong { color: #d65f9c; }
.affection-track { height: 9px; margin: 11px 0 9px; overflow: hidden; border-radius: 99px; background: #ead7e5; }
.affection-track i { display: block; width: var(--affection, 10%); height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f29ac3, #e06aa7); box-shadow: 0 0 8px rgba(224,106,167,.55); transition: width .5s ease; }
.affection-popup p { margin: 0; color: #846b94; font-size: .78rem; }
.scene-hotspot { position: absolute; z-index: 9; display: none; padding: 9px 14px; border: 1.5px solid rgba(255,255,255,.8); border-radius: 14px; color: white; background: rgba(102,73,156,.72); box-shadow: 0 8px 22px rgba(42,28,72,.24), inset 0 0 13px rgba(255,255,255,.1); backdrop-filter: blur(8px); opacity: 0; transform: translateY(5px); transition: opacity .2s ease, transform .2s ease; }
.scene-hotspot.is-near { display: block; opacity: 1; transform: translateY(0); }
.bedroom-door { right: 4%; bottom: 18%; }
.crossroad-home { left: 5%; bottom: 27%; }
.shop-door { left: 50%; top: 45%; transform: translate(-50%, 5px); }
.shop-door.is-near { transform: translate(-50%, 0); }
.shelf-hotspot { right: 7%; top: 47%; }
.question-house-door { left: 50%; top: 35%; transform: translate(-50%,5px); }
.question-house-door.is-near { transform: translate(-50%,0); }
.question-house-exit { left: 4%; bottom: 17%; }
.question-spot { left: 50%; top: 44%; transform: translate(-50%,5px); }
.question-spot.is-near { transform: translate(-50%,0); }
.bedroom-game[data-scene="shop-interior"] .shelf-hotspot { display: block; opacity: .64; transform: translateY(0); animation: shelfBeacon 1.7s ease-in-out infinite; }
.bedroom-game[data-scene="shop-interior"] .shelf-hotspot.is-near { opacity: 1; }
.replay-direction { position: absolute; z-index: 6; right: 13%; top: 39%; min-width: 145px; padding: 11px 36px 11px 17px; border: 3px solid #8a5b48; border-radius: 5px; color: #5b3d56; background: linear-gradient(180deg,#f0c89e,#d99d76); box-shadow: inset 0 0 0 2px rgba(255,235,205,.5), 0 8px 18px rgba(35,25,60,.25); font: 700 clamp(.82rem,1.5vw,1.05rem)/1.15 "Kaiti SC",sans-serif; opacity: 0; transform: translateY(8px) rotate(-2deg); transition: opacity .35s ease, transform .35s ease; pointer-events: none; }
.replay-direction b { display:block; letter-spacing:.08em; }
.replay-direction small { display:block; margin-top:3px; color:#81616e; font-size:.62em; font-weight:600; }
.replay-direction span { position:absolute; right:11px; top:50%; color:#a54470; font-size:1.35em; transform:translateY(-50%); }
.bedroom-game[data-scene="crossroads"] .replay-direction.is-visible { opacity: 1; transform: translateY(0) rotate(-2deg); }
.question-direction { position:absolute; z-index:6; left:50%; top:22%; min-width:145px; padding:11px 17px 11px 42px; border:2px solid rgba(255,255,255,.82); border-radius:16px; color:white; background:rgba(91,111,170,.78); box-shadow:0 9px 24px rgba(35,25,60,.25),inset 0 0 18px rgba(255,255,255,.1); backdrop-filter:blur(9px); transform:translate(-50%,8px); opacity:0; transition:opacity .3s ease,transform .3s ease; pointer-events:none; font:700 clamp(.82rem,1.5vw,1.05rem)/1.15 "Kaiti SC",sans-serif; }
.question-direction b,.question-direction small { display:block; }
.question-direction small { margin-top:3px; color:rgba(255,255,255,.72); font-size:.62em; }
.question-direction span { position:absolute; left:15px; top:50%; color:#d8e4ff; font-size:1.25em; transform:translateY(-50%); }
.bedroom-game[data-scene="crossroads"] .question-direction.is-visible { opacity:1; transform:translate(-50%,0); pointer-events:auto; }
.replay-shop-title { position: absolute; z-index: 6; top: 8%; left: 50%; display: none; padding: 8px 25px; color: #6b4c7e; font: 700 clamp(1.15rem,2.3vw,1.8rem)/1 "Kaiti SC",sans-serif; letter-spacing: .14em; transform: translateX(-50%); text-shadow: 0 2px 0 rgba(255,255,255,.7); }
.bedroom-game[data-scene="shop-exterior"] .replay-shop-title { display: block; }
.scene-toast { position: absolute; z-index: 18; left: 50%; bottom: 16%; margin: 0; padding: 9px 16px; border-radius: 14px; color: white; background: rgba(69,48,119,.76); backdrop-filter: blur(8px); transform: translateX(-50%); opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.scene-toast.is-visible { opacity: 1; }
.memory-shelf-modal { position: absolute; z-index: 80; inset: 0; display: grid; place-items: center; padding: max(18px,var(--safe-top)) 18px max(18px,var(--safe-bottom)); background: rgba(32,23,58,.62); backdrop-filter: blur(10px); }
.memory-shelf-modal[hidden] { display: none; }
.memory-shelf-card { position: relative; width: min(92vw,760px); aspect-ratio: 4 / 3; overflow: hidden; border: 3px solid rgba(255,248,240,.86); border-radius: 28px; background: url("../assets/memory-shelf-v2.png") center / cover no-repeat; box-shadow: 0 28px 80px rgba(23,15,45,.5), inset 0 0 30px rgba(255,255,255,.08); }
.memory-shelf-close { position: absolute; z-index: 5; top: 16px; right: 16px; width: 44px; aspect-ratio: 1; border: 2px solid rgba(255,255,255,.85); border-radius: 50%; color: white; background: rgba(81,57,126,.72); font-size: 1.4rem; }
.memory-ball { position: absolute; z-index: 4; left: 16.5%; top: 27%; width: 21%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; transform: translate(-50%,-50%); cursor: url("../assets/cursor-heart.png") 8 5, pointer; }
.memory-ball span { opacity: 0; }
.memory-complete-badge { position: absolute; right: 2%; bottom: 5%; width: 34%; aspect-ratio: 1; display: grid; place-items: center; border: 2px solid white; border-radius: 50%; color: white; background: #db74a8; box-shadow: 0 4px 14px rgba(74,42,99,.35); font: 900 clamp(.8rem,2vw,1.2rem)/1 sans-serif; }
.memory-complete-badge[hidden] { display: none; }
.memory-shelf-card > p { position: absolute; left: 50%; bottom: 3.5%; margin: 0; padding: 8px 17px; border-radius: 999px; color: white; background: rgba(78,56,119,.72); transform: translateX(-50%); font-size: .78rem; white-space: nowrap; }
.memory-confirm { position: absolute; z-index: 10; width: min(86vw,430px); padding: 28px; border: 2px solid rgba(255,255,255,.88); border-radius: 25px; color: #513a6d; background: linear-gradient(180deg,rgba(255,249,246,.98),rgba(255,224,237,.98)); box-shadow: 0 24px 70px rgba(28,18,52,.42); text-align: center; }
.memory-confirm[hidden] { display: none; }
.memory-confirm-kicker { color: #bd6c9b; font: 700 .68rem/1.2 Georgia,serif; letter-spacing: .18em; }
.memory-confirm h2 { margin: 12px 0 22px; font: 600 1.35rem/1.45 "Kaiti SC","STKaiti",sans-serif; }
.memory-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.memory-confirm-actions button { min-height: 48px; border: 1.5px solid #d9b9d1; border-radius: 15px; color: #5b4274; background: rgba(255,255,255,.7); font-weight: 700; }
.memory-confirm-actions button:first-child { color: white; background: linear-gradient(145deg,#a786d3,#d47fae); }
.question-place-panel { position:absolute; z-index:75; left:50%; top:50%; width:min(92vw,680px); max-height:min(86vh,760px); overflow:auto; padding:34px; border:2px solid rgba(255,255,255,.9); border-radius:28px; color:#503d6b; background:linear-gradient(160deg,rgba(250,247,255,.98),rgba(224,231,255,.97)); box-shadow:0 28px 85px rgba(31,29,68,.44); transform:translate(-50%,-50%); text-align:center; }
.question-place-panel[hidden] { display:none; }
.question-place-kicker { color:#788bc8; font:700 .68rem/1.2 Georgia,serif; letter-spacing:.2em; }
.question-place-panel h2 { margin:10px 0 16px; font:700 1.8rem/1.2 "Kaiti SC","STKaiti",sans-serif; }
.question-place-panel p { margin:0 0 17px; font:600 1.15rem/1.55 "Kaiti SC","STKaiti",sans-serif; }
#question-place-prompt { font-size:clamp(1.4rem,2.4vw,1.72rem); line-height:1.45; font-weight:700; }
.question-place-panel textarea { width:100%; min-height:112px; resize:vertical; padding:15px; border:1.5px solid #c8cfea; border-radius:16px; color:#4f4166; background:rgba(255,255,255,.78); font:inherit; }
.question-place-panel button { min-height:46px; border:1.5px solid #c6cdeb; border-radius:14px; color:#566ba8; background:rgba(255,255,255,.72); font-weight:700; }
.question-place-panel small { display:block; min-height:1.4em; margin-top:10px; color:#7884aa; }
.question-section-menu { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.question-section-menu button { min-height:105px; display:grid; grid-template-columns:auto 1fr; grid-template-rows:auto auto; column-gap:12px; padding:17px; text-align:left; transition:transform .2s ease,box-shadow .2s ease; }
.question-section-menu button:hover { transform:translateY(-3px); box-shadow:0 10px 25px rgba(77,69,126,.16); }
.question-section-menu button b { grid-row:1/3; align-self:center; color:#a88ccc; font:700 1.2rem/1 Georgia,serif; }
.question-section-menu button span { color:#4f4471; font:700 1.08rem/1.3 "Kaiti SC","STKaiti",sans-serif; }
.question-section-menu button small { min-height:0; margin:3px 0 0; font-size:.72rem; }
.question-section-menu button.is-complete::after { content:"✓ 已完成"; grid-column:2; color:#d0639e; font-size:.7rem; }
.question-section-menu button[data-question-section="soul"] { border:2px solid #d6a35d; background:linear-gradient(145deg,rgba(255,250,227,.92),rgba(238,226,255,.9)); box-shadow:0 0 0 4px rgba(238,188,105,.14),0 12px 28px rgba(94,67,122,.16); }
.question-section-menu button[data-question-section="soul"] b { color:#c98631; font-size:1.45rem; }
.question-section-menu button[data-question-section="soul"] span { color:#7c4f74; font-size:1.16rem; }
.question-flow[hidden],.question-section-menu[hidden] { display:none; }
.question-progress { height:8px; overflow:hidden; margin:4px 0 0; border-radius:999px; background:#dedff0; }
.question-progress i { display:block; width:0; height:100%; border-radius:inherit; background:linear-gradient(90deg,#8ea5df,#d68cb7); transition:width .35s ease; }
.question-flow-card { margin:14px 0; padding:20px; border:1.5px solid rgba(178,184,222,.7); border-radius:18px; background:rgba(255,255,255,.62); }
.question-flow-card strong { display:block; margin-bottom:8px; color:#5a4b78; font:700 1.18rem/1.45 "Kaiti SC","STKaiti",sans-serif; }
.question-flow-card p { margin:0; color:#796b91; font-size:.9rem; }
.question-issue-count { color:#b6699b; font-weight:800; }
.question-star-rating { display:flex; justify-content:center; gap:8px; margin:14px 0; }
.question-star-rating[hidden] { display:none; }
.question-star-rating button { min-width:48px; min-height:48px; padding:0; border:0; color:#c8c7d8; background:transparent; font-size:2rem; line-height:1; text-shadow:0 3px 8px rgba(74,57,108,.12); }
.question-star-rating button.is-selected { color:#f1ad48; transform:scale(1.08); text-shadow:0 0 12px rgba(241,173,72,.45); }
.question-flow-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:14px; }
.question-flow-actions button:first-child { color:white; background:linear-gradient(145deg,#7d91ce,#a988cf); }
.question-place-close { width:100%; margin-top:12px; }
.replay-lives { position: absolute; z-index: 25; left: max(20px,env(safe-area-inset-left)); top: var(--safe-top); display: flex; gap: 8px; padding: 10px 15px; border: 2px solid rgba(255,255,255,.72); border-radius: 16px; background: rgba(62,47,105,.62); backdrop-filter: blur(8px); }
.replay-lives[hidden] { display: none; }
.replay-lives span { color: #f28bb8; font-size: 1.4rem; text-shadow: 0 0 8px rgba(255,177,215,.8); animation: lifeSway 1.25s ease-in-out infinite; }
.replay-lives span:nth-child(2) { animation-delay: .12s; }
.replay-lives span:nth-child(3) { animation-delay: .24s; }
.replay-lives span.is-lost { color: rgba(255,255,255,.22); text-shadow: none; animation: none; transform: scale(.8); }
.replay-guide { position: absolute; z-index: 55; left: 50%; top: 50%; width: min(88vw,500px); padding: 28px; border: 2px solid rgba(255,255,255,.86); border-radius: 25px; color: #523d6c; background: rgba(255,241,247,.97); box-shadow: 0 25px 80px rgba(35,24,62,.42); transform: translate(-50%,-50%); text-align: center; }
.replay-guide[hidden] { display: none; }
.replay-guide strong { color: #bc6393; letter-spacing: .08em; }
.replay-guide p { margin: 12px 0 20px; line-height: 1.7; }
.guide-hearts { display: flex; justify-content: center; gap: 13px; margin: 18px 0 8px; }
.guide-hearts span { color: #ef78ac; font-size: 2rem; text-shadow: 0 0 13px rgba(239,120,172,.45); animation: lifeSway 1.25s ease-in-out infinite; }
.guide-hearts span:nth-child(2) { animation-delay: .12s; }
.guide-hearts span:nth-child(3) { animation-delay: .24s; }
.replay-guide button,.achievement-banner button { min-width: 150px; min-height: 45px; border: 0; border-radius: 15px; color: white; background: linear-gradient(145deg,#9877c6,#d67fae); font-weight: 700; }
.replay-dialogue { position: absolute; z-index: 35; left: 50%; bottom: max(24px,var(--safe-bottom)); width: min(88vw,720px); min-height: 150px; padding: 34px 32px 25px; border: 2px solid rgba(255,255,255,.9); border-radius: 24px; color: #4b3769; background: linear-gradient(180deg,rgba(255,249,250,.98),rgba(255,222,235,.98)); box-shadow: 0 22px 60px rgba(40,27,70,.34); transform: translateX(-50%); }
.replay-dialogue[hidden] { display: none; }
.replay-speaker { position: absolute; left: 25px; top: -18px; min-width: 86px; padding: 7px 18px; border: 2px solid white; border-radius: 13px; color: white; background: #9675c2; text-align: center; font-weight: 700; }
.replay-dialogue p { margin: 4px 0 16px; font: 600 clamp(1.05rem,2vw,1.35rem)/1.55 "Kaiti SC","STKaiti",sans-serif; white-space: pre-line; }
.replay-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.replay-choices:empty { display: none; }
.replay-choices button { min-height: 45px; padding: 9px 13px; border: 1.5px solid #d9b7d0; border-radius: 13px; color: #5c4374; background: rgba(255,255,255,.75); text-align: left; font-weight: 650; }
.replay-choices button:hover { background: #fff; transform: translateY(-1px); }
.replay-continue { display: block; margin-left: auto; min-width: 120px; min-height: 42px; border: 0; border-radius: 13px; color: white; background: #9b79c6; font-weight: 700; }
.replay-continue[hidden] { display: none; }
.affection-gain { position: absolute; z-index: 60; left: 50%; top: 24%; padding: 15px 26px; border: 2px solid white; border-radius: 999px; color: white; background: linear-gradient(145deg,#ef86b6,#c768a1); box-shadow: 0 12px 35px rgba(106,47,93,.36); transform: translateX(-50%); font-size: 1.2rem; font-weight: 800; animation: gainPop 1.8s ease forwards; }
.affection-gain[hidden] { display: none; }
.achievement-banner { position: absolute; z-index: 70; left: 50%; top: 50%; width: min(90vw,540px); padding: 34px; border: 3px solid #fff1d6; border-radius: 27px; color: #553b6f; background: linear-gradient(150deg,#fff8eb,#ffdbe8 58%,#ded1ff); box-shadow: 0 30px 90px rgba(37,25,66,.48); transform: translate(-50%,-50%); text-align: center; }
.achievement-banner[hidden] { display: none; }
.achievement-banner > span { color: #bd6f9a; font: 700 .68rem/1.2 Georgia,serif; letter-spacing: .2em; }
.achievement-banner strong { display: block; margin: 12px 0 7px; font: 700 1.65rem/1.3 "Kaiti SC","STKaiti",sans-serif; }
.achievement-banner p { margin: 0 0 22px; color: #8b6a91; }
.bedroom-game[data-scene="memory-bedroom"] .room-girl { left: 79%; top: 60%; width: clamp(135px,10vw,166px); aspect-ratio: 1 / 1; }
.bedroom-game[data-scene="memory-bedroom"] .room-girl-sprite { background-image: url("../assets/girl-desk-emotions-strip.png"); background-size: 300% 100%; background-position: 0 0; }
.bedroom-game[data-scene="memory-bedroom"] .room-girl[data-mood="sad"] .room-girl-sprite { background-position: 50% 0; }
.bedroom-game[data-scene="memory-bedroom"] .room-girl[data-mood="nod"] .room-girl-sprite { background-position: 100% 0; }
.bedroom-game[data-scene="memory-bedroom"] .room-girl[data-mood="nod"] { animation: girlNod .65s ease 2; }
.couple-interaction { position: absolute; z-index: 30; left: 79%; top: 61%; width: clamp(145px,12vw,202px); aspect-ratio: 1 / 1; background: url("../assets/couple-interaction-strip.png") 0 50% / 200% 100% no-repeat; transform: translate(-50%,-50%); filter: drop-shadow(0 7px 5px rgba(45,29,72,.2)); animation: coupleMoment 1.5s ease both; }
.couple-interaction[hidden] { display: none; }
.couple-interaction[data-action="kiss"] { background-position: 100% 50%; }
.bed-sit-interaction { position:absolute; z-index:31; left:22%; top:68%; width:clamp(165px,15vw,235px); aspect-ratio:1 / 1; padding:0; border:0; background:transparent url("../assets/couple-bed-sit.png") center / contain no-repeat; transform:translate(-50%,-50%); filter:drop-shadow(0 7px 5px rgba(45,29,72,.18)); animation:coupleMoment .7s ease both; cursor:pointer; }
.bed-sit-interaction[hidden] { display:none; }
.bedroom-game.is-couple-moment .room-player,
.bedroom-game.is-couple-moment .room-girl { visibility: hidden; }
.bedroom-game.memory-complete .bedroom-door { display: block; opacity: 1; transform: translateY(0); }
.touch-controls { position: absolute; z-index: 8; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 150px; height: 112px; display: none; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); gap: 6px; }
.touch-controls button { border: 1.5px solid rgba(255,255,255,.68); border-radius: 14px; color: white; background: rgba(85,58,146,.58); box-shadow: inset 0 0 14px rgba(255,255,255,.08); backdrop-filter: blur(8px); touch-action: none; user-select: none; }
.touch-controls [data-direction="up"] { grid-column: 2; grid-row: 1; }
.touch-controls [data-direction="left"] { grid-column: 1; grid-row: 2; }
.touch-controls [data-direction="down"] { grid-column: 2; grid-row: 2; }
.touch-controls [data-direction="right"] { grid-column: 3; grid-row: 2; }

button,
input,
.icon-button,
.audio-setting-row input,
.start-button,
.continue-button,
.login-back,
.login-submit {
  cursor: url("../assets/cursor-heart.png") 8 5, pointer;
}

@keyframes soloIdle { 0%,100% { transform: translateX(-50%) translateY(0) rotate(.25deg); } 50% { transform: translateX(-50%) translateY(-5px) rotate(-.3deg); } }
@keyframes playerWalk { 0%,100% { transform: translate(-50%, -50%) translateY(0) rotate(-.6deg); } 50% { transform: translate(-50%, -50%) translateY(-4px) rotate(.6deg); } }

@keyframes twinkle { 0%, 100% { opacity: .2; transform: scale(.65) rotate(0); } 48% { opacity: 1; transform: scale(1.18) rotate(18deg); } }
@keyframes girlIdle { 0%,100% { transform: translate(-2px, 0) rotate(-.35deg); } 50% { transform: translate(5px, -5px) rotate(.45deg) scaleY(1.005); } }
@keyframes boyIdle { 0%,100% { transform: translate(3px, 0) rotate(.35deg); } 50% { transform: translate(-5px, -4px) rotate(-.4deg) scaleY(1.004); } }
@keyframes cursorBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes tinyHeart { 0%,100% { transform: scale(.92) rotate(-4deg); } 45% { transform: scale(1.08) rotate(3deg); } }
@keyframes startPulse { 0%,100% { transform: scale(1); } 18% { transform: scale(1.025); } 35% { transform: scale(1); } 52% { transform: scale(1.014); } }
@keyframes pulseRing { 0% { opacity: .55; transform: scale(.98); } 70%,100% { opacity: 0; transform: scale(1.08, 1.24); } }
@keyframes shelfBeacon { 0%,100% { box-shadow: 0 8px 22px rgba(42,28,72,.24), 0 0 0 0 rgba(255,207,231,.28); } 50% { box-shadow: 0 8px 22px rgba(42,28,72,.24), 0 0 0 10px rgba(255,207,231,0); } }
@keyframes lifeSway { 0%,100% { transform: translateX(-1px) rotate(-5deg) scale(.96); } 50% { transform: translateX(2px) rotate(5deg) scale(1.06); } }
@keyframes gainPop { 0% { opacity: 0; transform: translate(-50%,18px) scale(.7); } 20%,70% { opacity: 1; transform: translate(-50%,0) scale(1); } 100% { opacity: 0; transform: translate(-50%,-18px) scale(.9); } }
@keyframes girlNod { 0%,100% { transform: translate(-50%,-50%) translateY(0); } 50% { transform: translate(-50%,-50%) translateY(7px) rotate(2deg); } }
@keyframes coupleMoment { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.82); } 22%,78% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.94); } }

@media (max-width: 700px) {
  .game-shell { min-height: 610px; }
  .room { background-position: 50% center; }
  .night-glow { background: linear-gradient(180deg, rgba(49, 33, 99, .08), transparent 30%, rgba(75, 48, 121, .14)); }
  .utility-controls { top: var(--safe-top); right: max(14px, env(safe-area-inset-right)); gap: 8px; }
  .icon-button { width: 40px; border-radius: 12px; }
  .title-block { top: clamp(70px, 9vh, 92px); }
  .logo { margin-bottom: 8px; min-width: 86px; min-height: 40px; font-size: 2.15rem; }
  .title-block p { font-size: clamp(1rem, 5vw, 1.35rem); letter-spacing: .1em; }
  .story-stage { top: clamp(155px, 23vh, 205px); width: 100vw; height: 45vh; min-height: 300px; }
  .character { width: clamp(135px, 39vw, 185px); }
  .character { bottom: -52px; }
  .character--girl { left: 3%; }
  .character--boy { right: 2%; }
  .message-window { top: 11%; width: min(62vw, 280px); opacity: .88; }
  .start-panel { bottom: var(--safe-bottom); width: min(86vw, 340px); }
  .start-button { min-height: 64px; border-radius: 22px; padding-inline: 26px; }
  .continue-button { margin-top: 8px; }
  .login-screen { padding-inline: 16px; }
  .login-card { width: min(92vw, 390px); padding: 40px 24px 25px; border-radius: 25px; }
  .login-copy { margin-bottom: 20px; }
  .login-note { margin-top: 9px; }
  .onboarding-topbar { left: 14px; right: 14px; }
  .solo-character { bottom: 330px; width: clamp(160px, 48vw, 205px); }
  .onboarding-dialogue { bottom: var(--safe-bottom); width: calc(100vw - 24px); min-height: 292px; padding: 29px 20px 18px; border-radius: 23px; }
  .onboarding-dialogue h2 { min-height: 3.2em; margin-bottom: 13px; font-size: 1.13rem; }
  .answer-choices { grid-template-columns: 1fr; gap: 7px; }
  .answer-choice { min-height: 39px; }
  .dialogue-next { margin-top: 11px; }
  .game-hud { left: 10px; right: 10px; grid-template-columns: 1fr auto; }
  .game-save-cluster { position: absolute; top: 52px; right: 0; gap: 5px; }
  .game-save-chip { padding: 7px 10px; }
  .game-save-chip span { display: none; }
  .game-save-chip strong { max-width: 82px; }
  .game-save-button { min-height: 32px; padding: 6px 11px; }
  .movement-hint { display: none; }
  .bedroom-game { background-image: linear-gradient(180deg, rgba(58,40,105,.02), rgba(69,45,116,.06)), url("../assets/bedroom-game-mobile.png"); background-position: center; background-size: cover; }
  .bedroom-game[data-scene="crossroads"] { background-image: linear-gradient(180deg, rgba(34,48,89,.03), rgba(76,53,111,.06)), url("../assets/crossroads-night-mobile.png"); }
  .bedroom-game[data-scene="shop-exterior"] { background-image: linear-gradient(180deg, rgba(34,48,89,.02), rgba(76,53,111,.06)), url("../assets/replay-shop-exterior-mobile.png"); }
  .bedroom-game[data-scene="shop-interior"] { background-image: linear-gradient(180deg, rgba(34,48,89,.02), rgba(76,53,111,.05)), url("../assets/replay-shop-interior-mobile.png"); }
  .bedroom-game[data-scene="question-exterior"] { background-image: linear-gradient(180deg,rgba(34,48,89,.02),rgba(76,53,111,.05)),url("../assets/question-house-exterior-mobile.png"); }
  .bedroom-game[data-scene="question-interior"] { background-image: linear-gradient(180deg,rgba(38,46,82,.02),rgba(66,50,93,.05)),url("../assets/question-house-interior-mobile.png"); }
  .bedroom-game[data-scene="memory-bedroom"] { background-image: linear-gradient(180deg,rgba(38,46,82,.06),rgba(66,50,93,.1)),url("../assets/memory-bedroom-game-mobile.png"); }
  .room-player { width: clamp(86px, 24vw, 108px); }
  .room-girl { left: 27%; top: 53%; width: clamp(84px, 24vw, 106px); }
  .npc-dialogue { bottom: max(112px, calc(var(--safe-bottom) + 90px)); width: calc(100vw - 28px); min-height: 98px; padding: 29px 45px 18px 27px; }
  .affection-control { left: max(12px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); }
  .affection-button { min-width: 82px; height: 46px; padding-inline: 13px; border-radius: 15px; }
  .scene-name { top: calc(var(--safe-top) + 91px); }
  .bedroom-door { right: 5%; bottom: 30%; }
  .crossroad-home { left: 4%; top: 42%; bottom: auto; }
  .replay-direction { right: 7%; top: 36%; }
  .replay-shop-title { top: 16%; }
  .shop-door { top: 34%; }
  .shelf-hotspot { right: 6%; top: 31%; }
  .memory-shelf-card { width: min(94vw,620px); aspect-ratio: 3 / 4; background-size: cover; }
  .memory-ball { top: 53%; width: 30%; }
  .memory-ball { left: 19%; top: 26%; width: 30%; }
  .replay-lives { left: max(12px,env(safe-area-inset-left)); }
  .replay-dialogue { bottom: max(115px,calc(var(--safe-bottom) + 90px)); width: calc(100vw - 22px); padding: 31px 18px 18px; }
  .replay-choices { grid-template-columns: 1fr; max-height: 33vh; overflow-y: auto; }
  .bedroom-game[data-scene="memory-bedroom"] .room-girl { left: 73%; top: 46%; width: clamp(92px,27vw,118px); }
  .couple-interaction { left: 72%; top: 48%; width: clamp(108px,31vw,145px); }
  .bed-sit-interaction { left:27%; top:53%; width:clamp(122px,35vw,162px); }
  .question-direction { top:28%; }
  .question-place-panel { top:50%; width:calc(100vw - 14px); max-height:calc(100dvh - 92px); padding:20px 13px 15px; border-radius:21px; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
  .question-place-panel h2 { margin:7px 0 9px; font-size:1.5rem; }
  .question-place-panel p { margin-bottom:11px; font-size:1rem; }
  #question-place-prompt { font-size:1.24rem; line-height:1.45; }
  .question-section-menu { grid-template-columns:1fr 1fr; gap:8px; }
  .question-section-menu button { min-height:88px; padding:11px 9px; column-gap:7px; }
  .question-section-menu button b { font-size:.9rem; }
  .question-section-menu button span { font-size:.93rem; }
  .question-flow-card { margin:9px 0; padding:14px 11px; }
  .question-place-panel textarea { min-height:88px; padding:12px; }
  .question-star-rating { gap:2px; margin:8px 0; }
  .question-star-rating button { min-width:40px; min-height:40px; font-size:1.72rem; }
  .question-flow-actions { grid-template-columns:1fr; gap:7px; margin-top:9px; }
  .question-place-close { margin-top:8px; }
  .touch-controls { display: grid; }
}

@media (hover: none), (pointer: coarse) {
  .touch-controls { display: grid; }
}

@media (max-height: 650px) {
  .login-screen { align-items: center; padding-block: 12px; }
  .login-card { padding-top: 32px; padding-bottom: 20px; transform: scale(.9); }
  .login-active .login-card { transform: scale(.94); }
  .login-copy { margin-block: 6px 12px; }
}

@media (max-height: 680px) and (min-width: 701px) {
  .title-block { top: 40px; }
  .story-stage { top: 125px; height: 48vh; }
  .character { width: min(15vw, 185px); }
  .character { bottom: -82px; }
  .start-button { min-height: 58px; }
  .start-panel { width: 310px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-play-state: paused !important; }
