:root {
  color-scheme: dark;
  --ink: #fff0f6;
  --muted: #d5becd;
  --pink: #ffc1db;
  --line: #74566c;
  --panel: #221928;
  background: #15111d;
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #ffc1db; outline-offset: 3px; }
.game {
  min-height: 100dvh;
  padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 5%, #33203c 0, #191321 55%, #14101b 100%);
}
.game:fullscreen, .game.immersive { width: 100%; height: 100%; overflow: auto; }
.game.immersive { position: fixed; inset: 0; z-index: 10000; }
body:has(.game.immersive) { overflow: hidden; }
.game-frame { width: min(100%, 1240px, max(660px, calc(177.78dvh - 520px))); margin-inline: auto; }
.game:fullscreen .game-frame, .game.immersive .game-frame { width: min(100%, 1536px, max(660px, calc(177.78dvh - 520px))); }
.toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; min-height:44px; }
.brand { display:inline-flex; align-items:center; gap:9px; color:var(--ink); text-decoration:none; font-weight:750; letter-spacing:.06em; }
.brand span:first-child { color:var(--pink); font-size:1.6rem; line-height:1; }
.tools { display:flex; gap:8px; }
.tool { padding:7px 11px; min-height:42px; border:1px solid var(--line); border-radius:9px; background:#2d2033; color:var(--ink); white-space:nowrap; }
.tool[aria-pressed="true"] { background:#553449; border-color:#d58ead; }
.stage {
  position:relative;
  aspect-ratio:16 / 9;
  overflow:hidden;
  border:1px solid #73536a;
  border-radius:16px 16px 0 0;
  background:#100d16;
}
.stage img, .stage video { display:block; width:100%; height:100%; position:absolute; inset:0; object-fit:contain; }
.stage-caption {
  position:absolute; top:12px; left:12px; right:12px;
  display:flex; justify-content:space-between; align-items:center; gap:6px;
  font-size:.82rem; letter-spacing:.04em; pointer-events:none;
}
.stage-caption span, .clues span { padding:5px 10px; border:1px solid #a17b93; border-radius:100px; background:#201624ed; }
#relation { color:var(--pink); }
.clues { position:absolute; bottom:12px; left:12px; right:12px; display:flex; gap:6px; flex-wrap:wrap; justify-content:center; font-size:clamp(.69rem,2.6vw,.88rem); }
.clues span { color:#ffe2ee; }
.dialog {
  position:relative;
  display:grid; gap:8px;
  background:linear-gradient(145deg,#2c2033,var(--panel) 65%);
  border:1px solid #73536a;
  border-top:0;
  border-radius:0 0 16px 16px;
  padding:14px clamp(14px,3vw,32px) 18px;
}
.dialog-top { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.speaker, .beat-number, .line, .notice, #story-title { margin:0; }
.speaker { color:var(--pink); font-weight:780; letter-spacing:.055em; }
.beat-number { margin-left:auto; color:var(--muted); font-size:.72rem; letter-spacing:.1em; white-space:nowrap; }
#story-title { font-family:"Songti SC","Noto Serif CJK SC",serif; font-size:clamp(1.65rem,4vw,2.6rem); letter-spacing:.055em; line-height:1.2; }
.line { max-width:66ch; color:var(--ink); font-size:clamp(1.02rem,2vw,1.17rem); line-height:1.65; overflow-wrap:anywhere; }
.game[data-voice="narration"] .line { color:var(--pink); }
.notice { justify-self:start; max-width:100%; color:#ffe0eb; font-size:.9rem; background:#57374d; border:1px solid #976884; border-radius:7px; padding:4px 9px; }
.choices { display:flex; gap:8px; flex-wrap:wrap; margin-top:3px; }
.choices button, .chat-form button {
  border:1px solid transparent; border-radius:8px; min-height:44px; padding:8px 15px;
  font-weight:730; text-align:center;
}
.choice, .chat-form button { color:#341629; background:#ffbfd8; }
.choice:hover, .chat-form button:hover { background:#ffd3e4; }
.choices .quiet { color:var(--ink); background:#35243d; border-color:var(--line); }
.quiet:hover, .tool:hover { background:#51364d; }
.timer { display:flex; align-items:center; gap:12px; }
.timer progress { flex:1; max-width:420px; height:8px; accent-color:#ffa8cd; }
.timer span { min-width:4.5em; color:var(--pink); font-variant-numeric:tabular-nums; }
.transcript { max-height:100px; overflow:auto; list-style:none; padding:6px 10px; margin:0 0 7px; background:#160f1bcc; border-radius:8px; font-size:.92rem; }
.transcript li { padding:2px 0; overflow-wrap:anywhere; }
.transcript li[data-role="luoluo"] { color:var(--pink); }
.chat-form { display:flex; max-width:650px; gap:6px; }
.chat-form input { min-width:0; flex:1; min-height:44px; padding:8px 12px; color:var(--ink); background:#19111f; border:1px solid var(--line); border-radius:8px; }
.chat-form input::placeholder { color:#c5aebf; }
.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
@media (max-width:600px) {
  .game { padding-inline:max(8px,env(safe-area-inset-left)) max(8px,env(safe-area-inset-right)); }
  .stage { max-height:none; border-radius:11px 11px 0 0; }
  .stage-caption { top:6px; left:6px; right:6px; font-size:.7rem; }
  .stage-caption span, .clues span { padding:3px 7px; }
  .clues { bottom:5px; left:5px; right:5px; gap:3px; }
  .dialog { border-radius:0 0 11px 11px; padding:11px 12px 13px; }
  .choices button { flex:1 1 auto; }
}
@media (orientation:landscape) and (max-height:530px) {
  .game { padding-block:max(5px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-bottom)); }
  .game .game-frame { width:100%; display:grid; grid-template-columns:minmax(0,1.45fr) minmax(240px,1fr); gap:0 8px; }
  .toolbar { grid-column:1/-1; margin-bottom:4px; min-height:38px; }
  .tool { min-height:38px; }
  .stage { align-self:start; border-radius:10px; max-height:calc(100dvh - 58px); }
  .dialog { border:1px solid #73536a; border-radius:10px; max-height:calc(100dvh - 58px); overflow:auto; padding:10px; }
  .choices button { min-height:42px; }
}
