/* =========================================================
   Story player
   ========================================================= */
.player-overlay {
  position: fixed; inset: 0; z-index: 450; display: flex; flex-direction: column;
  background: #070a0f; overflow: hidden; opacity: 0; transition: opacity 0.3s ease;
  color: var(--text);
}
.player-overlay.show { opacity: 1; }
.player-ambient { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.player-ambient::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(900px 620px at 50% -12%, rgba(79, 109, 143, 0.28), transparent 66%),
    radial-gradient(800px 620px at 10% 110%, rgba(255, 170, 84, 0.055), transparent 64%),
    radial-gradient(700px 600px at 100% 100%, rgba(80, 60, 130, 0.08), transparent 65%),
    linear-gradient(180deg, #0a0f17, #070a0f 65%);
}
.player-stars {
  position: absolute; inset: 0; opacity: 0.5;
  background-image:
    radial-gradient(1px 1px at 20% 24%, rgba(255, 255, 255, 0.36), transparent),
    radial-gradient(1px 1px at 72% 17%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1.2px 1.2px at 48% 38%, rgba(255, 255, 255, 0.24), transparent),
    radial-gradient(1px 1px at 84% 46%, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(1px 1px at 12% 58%, rgba(255, 255, 255, 0.18), transparent),
    radial-gradient(1.3px 1.3px at 64% 68%, rgba(255, 255, 255, 0.16), transparent),
    radial-gradient(1px 1px at 35% 82%, rgba(255, 255, 255, 0.14), transparent);
  mask-image: radial-gradient(circle at 50% 34%, black, transparent 80%);
  animation: stars-drift 22s ease-in-out infinite alternate;
}
@keyframes stars-drift { from { transform: translateY(0); opacity: 0.4; } to { transform: translateY(-12px); opacity: 0.6; } }
.player-fog { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.15; }
.player-fog.fog-a { width: 640px; height: 300px; left: -180px; top: 40%; background: rgba(77, 121, 150, 0.4); animation: fog-a 26s ease-in-out infinite alternate; }
.player-fog.fog-b { width: 520px; height: 260px; right: -160px; bottom: 5%; background: rgba(255, 170, 90, 0.22); animation: fog-b 31s ease-in-out infinite alternate; }
@keyframes fog-a { from { transform: translate(-20px, 10px); } to { transform: translate(80px, -20px); } }
@keyframes fog-b { from { transform: translate(0, 0); } to { transform: translate(-60px, -16px); } }
.player-grain { position: absolute; inset: 0; opacity: 0.035; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); pointer-events: none; }

.player-top {
  position: relative; z-index: 5; flex: 0 0 58px; height: 58px;
  display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 0 20px;
  background: linear-gradient(180deg, rgba(8, 12, 18, 0.8), transparent);
}
.player-back, .player-tool {
  display: inline-flex; align-items: center; gap: 6px; color: #79879b; font-size: 10px;
  padding: 6px 9px; border-radius: 6px; transition: all 0.15s; letter-spacing: 0.02em;
}
.player-back:hover, .player-tool:hover { color: #e2e8f1; background: rgba(255, 255, 255, 0.045); }
.player-wordmark { display: flex; align-items: center; gap: 9px; font-size: 8px; color: #77859a; letter-spacing: 0.22em; white-space: nowrap; }
.pw-line { width: 27px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 186, 103, 0.35)); }
.pw-line:last-child { background: linear-gradient(90deg, rgba(255, 186, 103, 0.35), transparent); }
.player-tools { display: flex; align-items: center; gap: 3px; }
.player-tool { font-size: 9.5px; }
.player-tool.icon-only { width: 30px; justify-content: center; padding: 6px; }
.player-stage { position: relative; z-index: 4; flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 34px 38px 70px; }
.player-canvas { width: 100%; max-width: 790px; margin: auto; }
.player-foot {
  position: relative; z-index: 5; flex: 0 0 44px; height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 0 20px;
  border-top: 1px solid rgba(160, 183, 212, 0.055); color: #536074; font-size: 8.5px;
}
.player-foot-left, .player-foot-right { display: flex; align-items: center; gap: 9px; }
.pf-item { display: inline-flex; align-items: center; gap: 4px; }
.pf-sep { width: 1px; height: 9px; background: rgba(160, 183, 212, 0.1); }
.kbd-hint { display: inline-flex; align-items: center; gap: 3px; }

/* Cover */
.player-cover { text-align: center; max-width: 700px; margin: 0 auto; position: relative; opacity: 0; transform: translateY(14px); transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); }
.player-cover.enter { opacity: 1; transform: none; }
.cover-orbit { position: absolute; left: 50%; top: 35%; transform: translate(-50%, -50%); width: 430px; height: 430px; pointer-events: none; opacity: 0.5; }
.co-ring { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border: 1px solid rgba(255, 187, 107, 0.1); border-radius: 50%; }
.co-ring.r1 { width: 330px; height: 330px; border-style: dashed; animation: orbit-spin 60s linear infinite; }
.co-ring.r2 { width: 430px; height: 430px; border-color: rgba(160, 183, 212, 0.06); }
.co-dot { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: rgba(255, 191, 120, 0.7); box-shadow: 0 0 12px rgba(255, 180, 92, 0.7); }
.co-dot.d1 { left: 9%; top: 40%; }
.co-dot.d2 { right: 12%; top: 27%; }
.co-dot.d3 { left: 49%; bottom: 8%; }
@keyframes orbit-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.cover-eyebrow { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 8px; letter-spacing: 0.32em; color: #887a64; margin-bottom: 31px; }
.cover-eyebrow > span { width: 36px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 186, 103, 0.45)); }
.cover-eyebrow > span:last-child { background: linear-gradient(90deg, rgba(255, 186, 103, 0.45), transparent); }
.cover-title { font-family: var(--font-display); font-size: clamp(38px, 6.4vw, 62px); line-height: 1.38; letter-spacing: 0.055em; font-weight: 600; margin: 0 0 21px; color: #f0ede4; text-shadow: 0 8px 45px rgba(0, 0, 0, 0.45); }
.cover-subtitle { font-family: var(--font-display); font-size: 15px; line-height: 1.9; letter-spacing: 0.03em; color: #9ba7b7; max-width: 540px; margin: 0 auto 26px; }
.cover-meta { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 11px; font-size: 9px; letter-spacing: 0.1em; color: #69778a; margin-bottom: 35px; }
.cover-dot { width: 3px; height: 3px; border-radius: 50%; background: #4e5a6b; }
.player-start {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 46px; padding: 0 29px; border-radius: 9px;
  background: linear-gradient(135deg, #ffd191, #ffb768 58%, #eea04c); color: #211708;
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
  border: 1px solid rgba(255, 219, 163, 0.38);
  box-shadow: 0 13px 38px rgba(255, 170, 76, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: all 0.18s;
}
.player-start:hover { transform: translateY(-2px); box-shadow: 0 18px 46px rgba(255, 170, 76, 0.27); }
.player-start.secondary { background: rgba(255, 255, 255, 0.025); color: #bcc7d6; border-color: rgba(160, 183, 212, 0.18); box-shadow: none; }
.player-start.secondary:hover { background: rgba(255, 255, 255, 0.055); color: #edf1f7; }
.ps-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(30, 20, 8, 0.12); }
.cover-note { margin: 23px 0 0; font-size: 8.5px; color: #566276; letter-spacing: 0.04em; display: flex; align-items: center; justify-content: center; gap: 5px; }

/* Scene */
.player-scene { opacity: 0; transform: translateY(13px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.player-scene.enter { opacity: 1; transform: none; }
.scene-topline { display: flex; align-items: center; gap: 12px; font-size: 8px; letter-spacing: 0.2em; color: #657387; margin-bottom: 42px; }
.scene-index { color: #9a8568; }
.scene-rule { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(160, 183, 212, 0.16), transparent); }
.scene-place { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.scene-speaker { display: flex; align-items: center; gap: 9px; margin-bottom: 20px; font-size: 10px; letter-spacing: 0.17em; font-weight: 600; color: var(--speaker, #ffbb6c); }
.speaker-mark { width: 5px; height: 5px; border-radius: 50%; background: var(--speaker, #ffbb6c); box-shadow: 0 0 12px var(--speaker, rgba(255, 180, 92, 0.8)); }
.scene-text { font-family: var(--font-display); font-size: clamp(18px, 2.3vw, 21px); line-height: 2.25; letter-spacing: 0.035em; color: #dbe2ec; white-space: pre-wrap; word-break: break-word; min-height: 190px; }
.scene-text .caret { display: inline-block; width: 1px; height: 1.05em; background: var(--accent); vertical-align: -2px; margin-left: 3px; animation: blink 0.9s step-end infinite; }
.scene-text.done .caret { display: none; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.scene-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 42px; padding-top: 22px; border-top: 1px solid rgba(160, 183, 212, 0.09); opacity: 0; transform: translateY(7px); transition: all 0.5s ease; pointer-events: none; }
.scene-actions.show { opacity: 1; transform: none; pointer-events: auto; }
.player-next { display: inline-flex; align-items: center; gap: 8px; color: #ddc59e; font-size: 10.5px; letter-spacing: 0.08em; padding: 8px 12px 8px 0; transition: color 0.15s; }
.player-next:hover { color: var(--accent); }
.scene-hint { display: inline-flex; align-items: center; gap: 4px; font-size: 8px; color: #4f5b6d; }

/* Choice */
.player-choice { opacity: 0; transform: translateY(12px); transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.player-choice.enter { opacity: 1; transform: none; }
.choice-topline { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.choice-kicker { display: inline-flex; align-items: center; gap: 5px; font-size: 8px; letter-spacing: 0.18em; color: #9a8568; white-space: nowrap; }
.choice-rule { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(160, 183, 212, 0.14), transparent); }
.choice-prompt { font-family: var(--font-display); font-size: clamp(23px, 3.4vw, 30px); line-height: 1.7; font-weight: 500; letter-spacing: 0.035em; color: #edf0f5; margin: 0 0 31px; }
.choice-list { display: flex; flex-direction: column; gap: 9px; }
.story-choice {
  width: 100%; display: flex; align-items: center; gap: 15px; text-align: left;
  padding: 15px 17px; border-radius: 9px; border: 1px solid rgba(160, 183, 212, 0.13);
  background: rgba(18, 25, 36, 0.58); color: #c8d2df; font-size: 12px; line-height: 1.6;
  transition: all 0.17s; position: relative; overflow: hidden;
}
.story-choice::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: 0; transition: opacity 0.17s; }
.story-choice:hover { border-color: rgba(255, 187, 107, 0.34); background: rgba(30, 39, 53, 0.8); transform: translateX(4px); }
.story-choice:hover::before { opacity: 1; }
.choice-num { font-size: 8px; letter-spacing: 0.1em; color: #6a778a; min-width: 20px; font-variant-numeric: tabular-nums; }
.choice-text { flex: 1; }
.choice-arrow { color: #667386; transition: all 0.17s; }
.story-choice:hover .choice-arrow { color: var(--accent); transform: translateX(3px); }
.story-choice.is-broken { border-color: rgba(255, 114, 136, 0.24); }
.story-choice.is-broken .choice-arrow { color: #ff7388; }
.choice-footnote { margin-top: 18px; font-size: 8px; color: #4d596b; display: flex; align-items: center; gap: 4px; }

/* Ending */
.player-ending { text-align: center; max-width: 700px; margin: 0 auto; opacity: 0; transform: translateY(13px); transition: opacity 0.85s ease, transform 0.85s cubic-bezier(0.2, 0.7, 0.2, 1); }
.player-ending.enter { opacity: 1; transform: none; }
.ending-ornament { display: flex; align-items: center; justify-content: center; gap: 13px; color: var(--accent); margin-bottom: 25px; }
.ending-ornament span { width: 43px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 180, 92, 0.45)); }
.ending-ornament span:last-child { background: linear-gradient(90deg, rgba(255, 180, 92, 0.45), transparent); }
.ending-kicker { font-size: 8px; letter-spacing: 0.3em; color: #9a8464; margin-bottom: 17px; }
.ending-title { font-family: var(--font-display); font-size: clamp(32px, 5vw, 48px); font-weight: 600; letter-spacing: 0.055em; color: #ede8dc; margin: 0 0 16px; }
.ending-summary { font-size: 10.5px; letter-spacing: 0.06em; color: #8390a2; margin: 0 0 30px; }
.ending-text { font-family: var(--font-display); font-size: 15px; line-height: 2.12; letter-spacing: 0.03em; color: #bfc9d7; text-align: left; padding: 25px 30px; border-top: 1px solid rgba(160, 183, 212, 0.1); border-bottom: 1px solid rgba(160, 183, 212, 0.1); margin-bottom: 31px; }
.ending-actions { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; }
.ending-actions .player-start { height: 41px; font-size: 10.5px; padding: 0 20px; }
.ending-note { margin: 23px 0 0; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 8px; color: #4f5b6d; }
.tone-good .ending-kicker { color: #7fe1bb; }
.tone-bad .ending-kicker, .tone-bad .ending-ornament { color: #ff8398; }
.tone-secret .ending-kicker, .tone-secret .ending-ornament { color: #c7b5ff; }
.tone-good .ending-title { color: #e2eee6; }

/* Error */
.player-error { max-width: 540px; margin: 0 auto; text-align: center; padding: 36px 28px; border-radius: 14px; border: 1px solid rgba(255, 114, 136, 0.18); background: rgba(255, 114, 136, 0.035); }
.error-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 19px; color: #ff8fa2; background: rgba(255, 114, 136, 0.08); border: 1px solid rgba(255, 114, 136, 0.17); }
.error-kicker { font-size: 8px; letter-spacing: 0.25em; color: #ff7f94; margin-bottom: 10px; }
.player-error h2 { font-family: var(--font-display); font-size: 24px; margin: 0 0 11px; font-weight: 600; color: #e8dfe0; }
.player-error > p { font-size: 11px; line-height: 1.75; color: #9ba7b8; margin: 0 0 14px; }
.error-detail { display: flex; align-items: flex-start; gap: 5px; text-align: left; padding: 9px 10px; border-radius: 7px; background: rgba(255, 255, 255, 0.025); font-size: 8.5px; line-height: 1.6; color: #6f7b8d; margin-bottom: 19px; }
.error-detail svg { flex: 0 0 auto; margin-top: 1px; }

/* Side panels */
.player-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 326px; z-index: 12;
  background: rgba(12, 18, 27, 0.985); border-left: 1px solid rgba(160, 183, 212, 0.12);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.35);
  transform: translateX(105%); transition: transform 0.3s cubic-bezier(0.2, 0.75, 0.25, 1);
  display: flex; flex-direction: column;
}
.player-panel.open { transform: none; }
.panel-top { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 17px 16px; border-bottom: 1px solid var(--border); font-size: 10px; color: #aebac9; }
.panel-top > span { display: inline-flex; align-items: center; gap: 6px; }
.panel-close { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; color: var(--text-faint); }
.panel-close:hover { color: var(--text); background: rgba(148, 174, 210, 0.08); }
.panel-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; }
.panel-note { flex: 0 0 auto; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 8px; line-height: 1.5; color: #4f5b6d; }
.player-drawer-scrim { position: absolute; inset: 0; z-index: 11; background: rgba(3, 5, 9, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.player-drawer-scrim.show { opacity: 1; pointer-events: auto; }
.debug-node { padding: 10px; border-radius: 8px; background: rgba(148, 174, 210, 0.04); border: 1px solid var(--border); margin-bottom: 12px; }
.debug-label { display: block; font-size: 7px; letter-spacing: 0.12em; color: #5d697b; margin-bottom: 3px; }
.debug-node-name { font-size: 10px; color: #c1ccdb; }
.debug-vars { display: flex; flex-direction: column; gap: 5px; }
.debug-var { display: flex; align-items: center; gap: 7px; padding: 8px 9px; border-radius: 6px; border: 1px solid rgba(148, 174, 210, 0.08); background: rgba(148, 174, 210, 0.02); }
.debug-var-name { font-size: 9.5px; color: #b7c3d3; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.debug-var-type { font-size: 7px; color: #5f6c7e; border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; }
.debug-var-value { font-size: 10px; color: #ffc97f; font-variant-numeric: tabular-nums; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.debug-var-value.num { color: #89e4c2; }
.debug-foot { margin-top: 12px; font-size: 8px; line-height: 1.6; color: #4f5b6d; }
.debug-empty { padding: 22px 10px; text-align: center; font-size: 9px; line-height: 1.8; color: #5c687a; }
.log-entry { display: flex; gap: 8px; padding: 9px 0; border-bottom: 1px solid rgba(148, 174, 210, 0.06); }
.log-type { flex: 0 0 31px; font-size: 7px; color: #667386; padding-top: 2px; letter-spacing: 0.05em; }
.log-content { flex: 1; min-width: 0; }
.log-content strong { display: block; font-size: 9px; color: #b9c4d3; font-weight: 600; margin-bottom: 2px; }
.log-content p { margin: 0; font-size: 8.5px; line-height: 1.65; color: #6f7b8d; }
.log-entry.choice .log-type { color: #a4865e; }
.log-entry.choice .log-content p { color: #b19a7b; }
.log-entry.ending .log-type { color: #8e7a55; }

/* Player responsive */
@media (max-width: 900px) {
  .player-wordmark { display: none; }
  .player-stage { padding: 20px 22px 60px; align-items: flex-start; }
  .player-canvas { margin-top: 26px; }
  .cover-orbit { width: 320px; height: 320px; }
  .co-ring.r1 { width: 250px; height: 250px; }
  .co-ring.r2 { width: 320px; height: 320px; }
  .scene-topline { margin-bottom: 30px; }
  .scene-text { font-size: 17px; line-height: 2.05; min-height: 150px; }
  .scene-actions { margin-top: 28px; }
  .ending-text { padding: 20px 18px; }
  .player-tool span { display: none; }
  .player-foot-right { display: none; }
  .player-panel { width: min(326px, 88vw); }
}
@media (max-width: 560px) {
  .player-top { padding: 0 10px; }
  .player-back { font-size: 9px; padding-left: 2px; }
  .player-stage { padding: 10px 16px 54px; }
  .cover-title { font-size: 34px; }
  .cover-subtitle { font-size: 13px; }
  .cover-meta { gap: 7px; font-size: 8px; }
  .player-start { height: 43px; padding: 0 22px; }
  .choice-prompt { font-size: 21px; }
  .story-choice { padding: 13px 12px; font-size: 11px; }
  .player-foot { padding: 0 13px; }
  .toast-root { bottom: 32px; }
}

/* =========================================================
   Illustration page
   ========================================================= */
.player-illustration-page { width: 100%; opacity: 0; transform: translateY(13px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.player-illustration-page.enter { opacity: 1; transform: none; }
.illustration-topline { display: flex; align-items: center; gap: 12px; font-size: 8px; letter-spacing: 0.2em; color: #657387; margin-bottom: 23px; }
.illustration-index { color: #b08c76; }
.player-illustration { margin: 0; padding: 0; }
.illustration-frame {
  border-radius: 10px; overflow: hidden; background: #060a10;
  border: 1px solid rgba(255, 159, 127, 0.14);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.025);
  display: flex; justify-content: center;
}
.illustration-frame img { display: block; width: 100%; max-height: 58vh; object-fit: contain; }
.player-illustration.cover .illustration-frame { height: 54vh; }
.player-illustration.cover .illustration-frame img { height: 100%; object-fit: cover; }
.player-illustration figcaption {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px 12px 0; font-family: var(--font-display); font-size: 12px;
  line-height: 1.8; letter-spacing: 0.06em; color: #b9a891; text-align: center;
}
.player-illustration figcaption span { width: 22px; height: 1px; background: rgba(255, 190, 144, 0.25); flex: 0 0 auto; }
.illustration-missing {
  min-height: 280px; width: 100%; border-radius: 10px; border: 1px dashed rgba(255, 159, 127, 0.25);
  background: rgba(255, 159, 127, 0.03); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: #b58e7d; font-size: 11px;
}
.illustration-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 24px; padding-top: 18px; border-top: 1px solid rgba(160, 183, 212, 0.09); }
.illustration-actions .player-next { opacity: 1; }
.log-entry.image .log-type { color: #d49a7e; }
.log-entry.image .log-content p { color: #9e8b80; }
@media (max-width: 900px) {
  .illustration-frame img { max-height: 50vh; }
  .player-illustration.cover .illustration-frame { height: 46vh; }
}

/* =========================================================
   Character sheet page
   ========================================================= */
.player-character-page { width: 100%; opacity: 0; transform: translateY(13px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.player-character-page.enter { opacity: 1; transform: none; }
.character-topline { display: flex; align-items: center; gap: 12px; font-size: 8px; letter-spacing: 0.2em; color: #657387; margin-bottom: 22px; }
.character-index { color: #b49be0; }
.character-sheet {
  display: grid; grid-template-columns: 238px 1fr; gap: 25px;
  padding: 20px; border-radius: 13px; border: 1px solid rgba(200, 167, 255, 0.16);
  background: radial-gradient(400px 260px at 10% 0%, rgba(200, 167, 255, 0.08), transparent 65%), rgba(12, 17, 26, 0.72);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}
.character-sheet-portrait {
  position: relative; min-height: 318px; border-radius: 9px; overflow: hidden;
  border: 1px solid rgba(200, 167, 255, 0.18); background: #080c13;
}
.character-sheet-portrait img { width: 100%; height: 100%; min-height: 318px; display: block; object-fit: cover; }
.character-sheet-placeholder { min-height: 318px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; color: #77698c; font-size: 9px; background: radial-gradient(140px 150px at 50% 35%, rgba(200, 167, 255, 0.12), transparent 75%); }
.character-sheet-stamp { position: absolute; left: 9px; bottom: 9px; font-size: 7px; letter-spacing: 0.18em; color: rgba(240, 230, 255, 0.55); border: 1px solid rgba(255, 255, 255, 0.13); padding: 3px 6px; border-radius: 3px; background: rgba(8, 12, 18, 0.5); }
.character-sheet-main { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.character-role-badge { align-self: flex-start; font-size: 8px; letter-spacing: 0.12em; color: #d8c5ff; background: rgba(200, 167, 255, 0.1); border: 1px solid rgba(200, 167, 255, 0.18); border-radius: 4px; padding: 3px 7px; }
.character-name { font-family: var(--font-display); font-size: clamp(27px, 3.5vw, 36px); font-weight: 600; letter-spacing: 0.05em; color: #f1ecf7; margin: 11px 0 15px; line-height: 1.35; }
.character-core-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 16px; }
.character-stat { padding: 8px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.028); border: 1px solid rgba(200, 167, 255, 0.09); display: flex; flex-direction: column; gap: 2px; }
.character-stat-label { font-size: 8px; letter-spacing: 0.08em; color: #81758f; }
.character-stat-value { font-size: 17px; font-weight: 600; color: #e7ddf5; font-variant-numeric: tabular-nums; line-height: 1.2; }
.character-stat-value small { font-size: 9px; color: #988aab; font-weight: 400; margin-left: 3px; }
.character-section { margin-top: 10px; }
.character-section-label { display: block; font-size: 8px; letter-spacing: 0.12em; color: #8a7d9e; margin-bottom: 4px; }
.character-appearance, .character-bio { margin: 0; font-family: var(--font-display); font-size: 11.5px; line-height: 1.85; color: #b6adc2; letter-spacing: 0.02em; }
.character-attributes { margin-top: 15px; }
.character-attributes-head { display: flex; align-items: center; gap: 10px; font-size: 8px; letter-spacing: 0.14em; color: #786d8b; margin-bottom: 8px; }
.character-attributes-head .scene-rule { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(200, 167, 255, 0.2), transparent); }
.character-attribute-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.character-attribute { padding: 9px 10px; border-radius: 7px; border: 1px solid rgba(200, 167, 255, 0.09); background: rgba(200, 167, 255, 0.025); }
.character-attribute-name { display: block; font-size: 8.5px; letter-spacing: 0.06em; color: #9384a8; margin-bottom: 3px; }
.character-attribute-value { font-size: 15px; font-weight: 600; color: #e1d4f1; font-variant-numeric: tabular-nums; }
.character-attribute-value small { font-size: 8.5px; color: #9586a9; font-weight: 400; margin-left: 3px; }
.character-attribute p { margin: 4px 0 0; font-size: 9px; line-height: 1.55; color: #7f758d; }
.character-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(200, 167, 255, 0.1); }
.log-entry.character .log-type { color: #b49be0; }
@media (max-width: 760px) {
  .character-sheet { grid-template-columns: 1fr; gap: 15px; padding: 14px; }
  .character-sheet-portrait, .character-sheet-portrait img, .character-sheet-placeholder { min-height: 220px; max-height: 300px; }
  .character-name { font-size: 28px; }
  .character-core-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Gated choices */
.story-choice.is-locked { opacity: 0.64; border-style: dashed; border-color: rgba(200, 167, 255, 0.22); cursor: not-allowed; }
.story-choice.is-locked:hover { transform: none; border-color: rgba(200, 167, 255, 0.28); background: rgba(18, 25, 36, 0.58); }
.story-choice.is-locked::before { display: none; }
.story-choice.is-locked .choice-num, .story-choice.is-locked .choice-arrow { color: #a58bbd; }
.choice-text { display: flex; flex-direction: column; gap: 3px; }
.choice-requirement { display: inline-flex; align-items: center; gap: 4px; font-size: 8.5px; line-height: 1.5; color: #b99bcf; letter-spacing: 0.02em; }
.choice-empty-state {
  padding: 30px 24px; border-radius: 11px; border: 1px dashed rgba(200, 167, 255, 0.24);
  background: rgba(200, 167, 255, 0.035); text-align: center; color: #b499c9;
}
.choice-empty-state > svg { opacity: 0.8; }
.choice-empty-state strong { display: block; margin: 10px 0 5px; font-size: 14px; color: #e2d5ef; font-weight: 600; }
.choice-empty-state p { margin: 0 auto; max-width: 390px; font-size: 10.5px; line-height: 1.75; color: #8d7e9e; }

/* =========================================================
   Layout-driven game screen
   ========================================================= */
.player-canvas.layout-canvas { max-width: 1120px; }
.layout-stage {
  position: relative; width: min(100%, calc((100dvh - 205px) * var(--layout-ar)));
  aspect-ratio: 16 / 9; margin: 0 auto; overflow: hidden;
  border-radius: 16px; border: 1px solid rgba(160, 183, 212, 0.13);
  background: radial-gradient(800px 500px at 50% 0%, rgba(81, 112, 145, 0.13), transparent 70%), #070b11;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  opacity: 0; transform: translateY(10px); transition: opacity 0.6s ease, transform 0.6s ease;
}
.layout-stage.enter { opacity: 1; transform: none; }
.layout-stage-bg { position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(circle, rgba(148, 174, 210, 0.1) 1px, transparent 1.2px); background-size: 24px 24px; opacity: 0.24; }
.layout-region {
  position: absolute; display: flex; flex-direction: column; min-width: 20px; min-height: 20px;
  border-radius: 10px; border: 1px solid color-mix(in srgb, var(--rc) 18%, transparent);
  background: linear-gradient(155deg, color-mix(in srgb, var(--rc) 5%, rgba(15, 22, 34, 0.72)), rgba(9, 14, 22, 0.74));
  overflow: hidden; backdrop-filter: blur(8px);
}
.layout-region-label {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding: 6px 8px 4px;
  font-size: 7.5px; letter-spacing: 0.08em; color: color-mix(in srgb, var(--rc) 62%, #8d9bad);
  text-transform: uppercase; opacity: 0.8;
}
.layout-region-body { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 10px 10px; }
.layout-region-story .layout-region-body { padding: 4px 16px 14px; }
.layout-region-character { background: linear-gradient(160deg, color-mix(in srgb, var(--rc) 7%, rgba(16, 23, 36, 0.82)), rgba(8, 13, 20, 0.82)); }
.layout-region-choices { background: linear-gradient(160deg, rgba(255, 189, 107, 0.055), rgba(9, 14, 22, 0.72)); }
.layout-region-title { border-color: transparent; background: transparent; backdrop-filter: none; }
.layout-region-title .layout-region-label { display: none; }
.layout-region-title .layout-region-body { padding: 0; }
.layout-scene, .layout-choice-prompt, .layout-character-sheet, .layout-ending-content, .layout-image-content { height: 100%; display: flex; flex-direction: column; }
.layout-kicker { display: flex; align-items: center; gap: 5px; font-size: 8px; letter-spacing: 0.18em; color: #c3a47a; margin-bottom: 10px; }
.layout-speaker { font-size: 10px; letter-spacing: 0.16em; color: #e4bd84; margin-bottom: 10px; font-weight: 600; }
.layout-story-text { font-family: var(--font-display); font-size: clamp(14px, 1.7cqw, 20px); line-height: 2; letter-spacing: 0.02em; color: #d4dce8; white-space: normal; }
.layout-region-body { container-type: inline-size; }
.layout-choice-prompt h2, .layout-ending-content h2 { font-family: var(--font-display); font-size: clamp(18px, 2.4cqw, 27px); line-height: 1.55; font-weight: 500; color: #eef2f8; margin: 0 0 14px; letter-spacing: 0.02em; }
.layout-choice-more { font-size: 9px; color: #7d899c; margin-top: 4px; }
.layout-choice-list { display: flex; flex-direction: column; gap: 7px; }
.layout-choice-list .story-choice { padding: 10px 12px; font-size: clamp(10px, 1.1cqw, 13px); border-radius: 7px; }
.layout-actions { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 12px; }
.layout-key-hint { color: #5c697c; font-size: 8px; }
.layout-key-hint kbd { font-family: var(--font-ui); font-size: 8px; border: 1px solid rgba(148, 174, 210, 0.16); border-radius: 3px; padding: 1px 4px; }
.layout-choice-empty, .layout-character-empty, .layout-variables-empty, .layout-log-empty, .layout-error-content { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; height: 100%; min-height: 70px; color: #8d7d92; font-size: 9.5px; text-align: center; }
.layout-choice-empty .btn { margin-top: 4px; }
.layout-character { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.layout-character-portrait { width: 100%; flex: 1 1 auto; min-height: 100px; max-height: 46%; border-radius: 8px; overflow: hidden; border: 1px solid rgba(200, 167, 255, 0.16); background: radial-gradient(130px 130px at 50% 20%, rgba(200, 167, 255, 0.14), transparent 75%), #080d14; display: grid; place-items: center; }
.layout-character-portrait img { width: 100%; height: 100%; display: block; object-fit: cover; }
.layout-character-portrait > span { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #85739d; font-size: 8px; }
.layout-character-info { display: flex; flex-direction: column; gap: 5px; }
.layout-character-role { align-self: flex-start; font-size: 7.5px; color: #d7c3f2; border: 1px solid rgba(200, 167, 255, 0.18); background: rgba(200, 167, 255, 0.08); border-radius: 3px; padding: 2px 5px; }
.layout-character-name { font-family: var(--font-display); font-size: clamp(17px, 2cqw, 24px); font-weight: 600; letter-spacing: 0.04em; color: #f0eaf7; line-height: 1.3; }
.layout-character-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 8px; color: #8f819e; }
.layout-character-stats b { color: #e6d9f3; font-size: 12px; margin-left: 2px; font-variant-numeric: tabular-nums; }
.layout-character-stats small { color: #a392b4; margin-left: 1px; }
.live-mark { display: inline-block; font-style: normal; font-size: 6px; letter-spacing: 0.06em; color: #70e2bb; background: rgba(112, 226, 187, 0.09); border-radius: 2px; padding: 1px 3px; margin-left: 3px; vertical-align: middle; }
.layout-character-attrs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.layout-character-attr { padding: 5px 6px; border-radius: 5px; background: rgba(200, 167, 255, 0.04); border: 1px solid rgba(200, 167, 255, 0.08); }
.layout-character-attr > span { display: block; font-size: 7px; color: #9586a8; margin-bottom: 2px; }
.layout-character-attr strong { font-size: 11px; color: #e6d8f4; font-variant-numeric: tabular-nums; }
.layout-character-attr small { font-size: 7px; color: #a08fb4; margin-left: 2px; }
.layout-character-vars { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.layout-mini-label { font-size: 7px; color: #756983; letter-spacing: 0.06em; }
.layout-var-chip { font-size: 7.5px; color: #a08faf; background: rgba(148, 174, 210, 0.07); border: 1px solid rgba(148, 174, 210, 0.09); border-radius: 3px; padding: 2px 4px; }
.layout-var-chip b { color: #e0d3ed; margin-left: 2px; }
.layout-character-sheet { gap: 8px; }
.layout-character-sheet-head { display: flex; gap: 9px; align-items: center; }
.layout-character-sheet-head img { width: 62px; height: 76px; border-radius: 6px; object-fit: cover; border: 1px solid rgba(200, 167, 255, 0.18); }
.layout-character-sheet-head > span { width: 62px; height: 76px; border-radius: 6px; background: rgba(200, 167, 255, 0.07); display: grid; place-items: center; color: #88769e; }
.layout-character-sheet-head h2 { margin: 2px 0 0; font-family: var(--font-display); font-size: 24px; font-weight: 600; color: #efe8f6; }
.layout-character-appearance { margin: 0; font-size: 9px; line-height: 1.7; color: #a99cb8; }
.layout-ending-summary { margin: 0 0 12px; font-size: 9.5px; color: #9a8da9; }
.layout-ending-content .layout-story-text { flex: 1; overflow-y: auto; }
.layout-image-content { gap: 8px; }
.layout-image-content img { width: 100%; flex: 1; min-height: 0; object-fit: contain; border-radius: 7px; }
.layout-image-caption { font-family: var(--font-display); font-size: 11px; color: #b7a68f; text-align: center; }
.layout-image-missing { display: flex; align-items: center; justify-content: center; gap: 6px; flex: 1; color: #a3897c; font-size: 10px; border: 1px dashed rgba(255, 159, 127, 0.22); border-radius: 7px; }
.layout-variables { display: flex; flex-direction: column; gap: 5px; }
.layout-variable { display: flex; align-items: baseline; gap: 6px; padding: 6px 7px; border-radius: 5px; background: rgba(148, 174, 210, 0.04); border: 1px solid rgba(148, 174, 210, 0.07); }
.layout-variable span { flex: 1; font-size: 9px; color: #a9b6c7; }
.layout-variable b { font-size: 12px; color: #ffcf9a; font-variant-numeric: tabular-nums; }
.layout-variable small { font-size: 7px; color: #6d7a8d; }
.layout-log { display: flex; flex-direction: column; gap: 6px; }
.layout-log-entry { display: flex; gap: 6px; padding: 5px 0; border-bottom: 1px solid rgba(148, 174, 210, 0.06); }
.layout-log-entry > span { flex: 0 0 26px; font-size: 7px; color: #778395; }
.layout-log-entry p { margin: 0; font-size: 8.5px; line-height: 1.55; color: #8e9aab; }
.layout-title-content { display: flex; align-items: baseline; gap: 9px; height: 100%; padding: 4px 8px; }
.layout-title-content > span { font-size: 7px; letter-spacing: 0.18em; color: #a18660; }
.layout-title-content strong { font-family: var(--font-display); font-size: clamp(16px, 2.2cqw, 24px); letter-spacing: 0.06em; color: #e9dfcf; font-weight: 600; }
.layout-title-content small { font-size: 8px; color: #7e8999; }
@media (max-width: 900px) {
  .layout-stage { width: min(100%, calc((100dvh - 180px) * var(--layout-ar))); border-radius: 10px; }
  .layout-region-label { padding: 4px 6px 2px; font-size: 6.5px; }
  .layout-region-body { padding: 1px 7px 7px; }
  .layout-region-story .layout-region-body { padding: 2px 9px 8px; }
  .layout-actions .player-next { font-size: 9px; }
  .layout-character-attrs { grid-template-columns: 1fr; }
}
