:root {
  --ink: #e8e7e1;
  --muted: #aaa9a2;
  --dim: #737570;
  --red: #8f292d;
  --red-hi: #b84245;
  --green: #8ca69a;
  --paper: #c9c0a8;
  --panel: rgba(12, 14, 15, .86);
  --line: rgba(232, 231, 225, .16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --topbar-base: 76px;
  --app-height: 100vh;
  --scene-mobile-height: clamp(180px, 56.25vw, 360px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; min-height: var(--app-height, 100vh); background: #090a0b; color: var(--ink); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-family: "Noto Serif SC", "Songti SC", "Microsoft YaHei", serif; overflow-x: hidden; overflow-y: auto; overscroll-behavior-x: none; -webkit-overflow-scrolling: touch; }
button { font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: rgba(184,66,69,.18); }
.is-hidden { display: none !important; }

.app { min-height: var(--app-height, 100vh); position: relative; isolation: isolate; overflow-x: hidden; }
.scene-bg { position: fixed; inset: 0; z-index: -4; background: #111; background-position: center; background-size: cover; transition: opacity .45s ease, filter .45s ease; }
.scene-bg.is-loading { opacity: .55; }
.scene-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(4,5,6,.9), rgba(4,5,6,.54) 50%, rgba(4,5,6,.8)), linear-gradient(0deg, rgba(4,5,6,.74), transparent 50%); }
.scene-vignette { position: fixed; inset: 0; z-index: -3; pointer-events: none; box-shadow: inset 0 0 180px 40px #020303; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.015) 4px); }
.character-layer { position: fixed; z-index: -2; right: 4vw; bottom: 0; width: min(34vw, 420px); height: 80vh; background: center bottom/contain no-repeat; opacity: 0; filter: grayscale(.2) brightness(.7); mix-blend-mode: screen; transition: opacity .7s; }
.character-layer.visible { opacity: .45; }

/* Scene-specific grading: reveal the title art, keep events readable, and let
   dawn reports land as a darker pause. The rule page is intentionally untouched. */
.app[data-scene="title"] .scene-bg { filter: brightness(1.08); }
.app[data-scene="title"] .scene-bg::after {
  background: linear-gradient(90deg, rgba(4,5,6,.78), rgba(4,5,6,.43) 50%, rgba(4,5,6,.7)), linear-gradient(0deg, rgba(4,5,6,.64), transparent 54%);
}
.app[data-scene="title"] .scene-vignette { box-shadow: inset 0 0 150px 28px rgba(2,3,3,.92); }
/* Ordinary event cards already provide a dark reading surface, so the scene
   behind them can remain visible instead of being crushed by two black layers. */
.app[data-scene="guard"] .scene-bg { filter: brightness(1.28) contrast(1.03); }
.app[data-scene="corridor"] .scene-bg { filter: brightness(1.22) contrast(1.03); }
.app[data-scene="stairwell"] .scene-bg { filter: brightness(1.2) contrast(1.03); }
.app[data-scene="guard"] .scene-bg::after,
.app[data-scene="corridor"] .scene-bg::after,
.app[data-scene="stairwell"] .scene-bg::after {
  background: linear-gradient(90deg, rgba(4,5,6,.52), rgba(4,5,6,.2) 50%, rgba(4,5,6,.4)), linear-gradient(0deg, rgba(4,5,6,.42), transparent 58%);
}
.app[data-scene="guard"] .scene-vignette,
.app[data-scene="corridor"] .scene-vignette,
.app[data-scene="stairwell"] .scene-vignette {
  box-shadow: inset 0 0 125px 12px rgba(2,3,3,.62);
}
.app[data-scene="summary"] .scene-bg { filter: brightness(.72) saturate(.75); }
.app[data-scene="summary"] .scene-bg::after {
  background: linear-gradient(90deg, rgba(4,5,6,.9), rgba(4,5,6,.72) 50%, rgba(4,5,6,.88)), linear-gradient(0deg, rgba(4,5,6,.84), rgba(4,5,6,.25));
}
.app[data-scene="cctv"] .scene-bg { filter: brightness(.9) contrast(1.08) saturate(.72); }
.app[data-scene="cctv"] .scene-vignette {
  background: repeating-linear-gradient(0deg, rgba(102,140,121,.045) 0 1px, transparent 1px 4px);
  box-shadow: inset 0 0 180px 40px rgba(0,8,5,.95);
}

.topbar {
  height: calc(var(--topbar-base) + var(--safe-top));
  padding: calc(16px + var(--safe-top)) calc(clamp(18px, 4vw, 52px) + var(--safe-right)) 16px calc(clamp(18px, 4vw, 52px) + var(--safe-left));
  display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 5;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 58px; height: 48px; border: 1px solid rgba(255,255,255,.25); display: grid; grid-template-columns: 28px 1fr; align-items: center; padding: 5px; background: rgba(5,6,7,.52); backdrop-filter: blur(8px); }
.brand-mark span { font-size: 23px; color: #d0cfc9; border-right: 1px solid var(--red); }
.brand-mark small { writing-mode: vertical-rl; font: 7px/1 sans-serif; letter-spacing: .08em; color: var(--dim); }
.icon-btn { width: 42px; height: 42px; color: var(--muted); border: 1px solid var(--line); background: rgba(8,9,10,.55); cursor: pointer; transition: .2s; }
.icon-btn:hover { color: white; border-color: rgba(255,255,255,.4); background: rgba(143,41,45,.35); }
.icon-btn.is-muted { color: #777a76; }
.archive-quick { min-height: 42px; padding: 0 16px; color: #d1d0ca; border: 1px solid rgba(184,66,69,.35); background: rgba(8,9,10,.72); letter-spacing: .14em; cursor: pointer; transition: .2s; }
.archive-quick:hover { border-color: var(--red-hi); background: rgba(83,28,31,.7); }

.screen {
  min-height: calc(var(--app-height, 100vh) - var(--topbar-base) - var(--safe-top));
  padding: clamp(20px, 4vw, 56px) calc(clamp(20px, 4vw, 56px) + var(--safe-right)) calc(clamp(20px, 4vw, 56px) + var(--safe-bottom)) calc(clamp(20px, 4vw, 56px) + var(--safe-left));
  display: flex; align-items: center;
}
.panel { width: min(720px, 100%); padding: clamp(24px, 5vw, 54px); border: 1px solid var(--line); background: var(--panel); box-shadow: 0 28px 80px rgba(0,0,0,.45); backdrop-filter: blur(14px); animation: panelIn .45s ease both; }
.panel.wide { width: min(960px, 100%); }
.panel.center { margin-inline: auto; text-align: center; }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px); } }

.eyebrow { margin: 0 0 14px; color: var(--red-hi); font: 600 11px/1.4 "Microsoft YaHei", sans-serif; letter-spacing: .28em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.game-title { margin-bottom: 14px; font-weight: 500; font-size: clamp(42px, 8vw, 82px); line-height: 1.08; letter-spacing: .12em; text-shadow: 0 4px 28px #000; }
.game-title .seven { color: var(--red-hi); }
.subtitle { max-width: 600px; color: #c8c7c0; font-size: clamp(14px, 2vw, 18px); line-height: 1.9; letter-spacing: .08em; }
.quote-line { width: 72px; height: 1px; background: var(--red); margin: 28px 0; }
.title-panel { position: relative; top: -26px; }
.build-version { position: absolute; right: 20px; bottom: 12px; margin: 0; color: #686a66; font: 9px/1.4 sans-serif; letter-spacing: .16em; }

.actions { display: grid; gap: 12px; margin-top: 30px; }
.actions.inline { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.btn { min-height: 52px; padding: 14px 20px; border: 1px solid rgba(232,231,225,.24); color: var(--ink); background: rgba(20,22,23,.76); text-align: left; letter-spacing: .04em; cursor: pointer; transition: transform .18s, background .18s, border-color .18s; position: relative; overflow: hidden; }
.btn::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--red); transform: scaleY(0); transition: .18s; }
.btn:hover:not(:disabled) { transform: translateX(4px); border-color: rgba(184,66,69,.72); background: rgba(56,25,27,.82); }
.btn:hover::before { transform: scaleY(1); }
.btn.primary { text-align: center; background: rgba(111,29,33,.82); border-color: rgba(184,66,69,.72); }
.btn.ghost { text-align: center; color: var(--muted); background: transparent; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.menu-btn small { display: block; color: var(--dim); font: 10px/1.5 sans-serif; letter-spacing: .14em; margin-top: 4px; }

.manual-panel { margin-inline: auto; }
.manual-lead { max-width: 760px; color: #cfcec8; font-size: 16px; line-height: 1.9; }
.manual-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 26px; }
.manual-grid-bottom { margin-top: 12px; }
.manual-section { padding: 20px; border: 1px solid var(--line); background: rgba(8,10,11,.58); }
.manual-section h3, .manual-heading, .manual-warning h3 { margin: 0 0 10px; color: var(--red-hi); font: 600 11px/1.5 sans-serif; letter-spacing: .16em; }
.manual-section p, .manual-warning p { margin: 0; color: #b9b8b2; font-size: 14px; line-height: 1.8; }
.manual-heading { margin-top: 28px; }
.manual-stats { display: grid; grid-template-columns: repeat(2, 1fr); margin: 0; border: 1px solid var(--line); }
.manual-stats > div { padding: 18px 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.manual-stats > div:nth-child(2n) { border-right: 0; }
.manual-stats > div:nth-last-child(-n+2) { border-bottom: 0; }
.manual-stats dt { margin-bottom: 8px; color: var(--ink); font-size: 18px; }
.manual-stats dd { margin: 0; color: #a9a8a2; font-size: 13px; line-height: 1.75; }
.manual-warning { margin-top: 12px; padding: 18px 20px; border-left: 2px solid var(--red-hi); background: rgba(111,29,33,.12); }
.manual-tip { margin: 22px 0 0; color: #d4c190; font-size: 13px; line-height: 1.7; }

.rules-panel { color: #292724; background-color: var(--paper); background-size: cover; background-position: center; border: none; box-shadow: 0 25px 80px #000; position: relative; }
.rules-panel::after { content: "值班室存档 · 请勿带离"; position: absolute; right: 26px; bottom: 18px; color: rgba(62,35,32,.45); font: 10px sans-serif; letter-spacing: .15em; }
.rules-panel .eyebrow { color: #6e2929; }
.rules-panel h2 { font-size: clamp(25px, 4vw, 36px); letter-spacing: .08em; }
.rules-list { padding: 0; margin: 24px 0 0; list-style: none; counter-reset: rule; }
.rules-list li { counter-increment: rule; display: grid; grid-template-columns: 35px 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid rgba(41,39,36,.16); line-height: 1.72; }
.rules-list li::before { content: counter(rule, decimal-leading-zero); font: 600 12px/1.8 monospace; color: #742c2c; }
.rules-list .corrupt { text-decoration: line-through; text-decoration-color: #7b2929; filter: blur(.25px); }

.event-shell { width: min(1050px, 100%); min-width: 0; margin: auto; display: grid; grid-template-columns: minmax(185px, 260px) minmax(0, 1fr); gap: clamp(18px, 3vw, 34px); align-items: start; }
.hud { padding: 22px; border: 1px solid var(--line); background: rgba(8,10,11,.8); backdrop-filter: blur(12px); }
.night-index { font-size: 30px; margin: 4px 0 0; }
.time { color: var(--green); font: 22px/1.4 ui-monospace, monospace; letter-spacing: .12em; }
.stats { margin-top: 24px; display: grid; gap: 15px; }
.stat-row { display: grid; grid-template-columns: 42px 1fr 30px; gap: 9px; align-items: center; color: var(--muted); font: 12px sans-serif; }
.stat-track { height: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.stat-fill { height: 100%; background: #a5aaa5; transition: width .5s, background .3s; }
.stat-row.danger { color: #d66c6e; }.stat-row.danger .stat-fill { background: var(--red-hi); }
.event-card { min-height: 480px; padding: clamp(26px, 5vw, 52px); border: 1px solid var(--line); background: rgba(11,13,14,.88); box-shadow: 0 25px 80px rgba(0,0,0,.48); backdrop-filter: blur(16px); }
.event-card.cctv { border-color: rgba(103,144,125,.32); }
.event-card.cctv .event-text { color: #b5c9bd; text-shadow: 0 0 10px rgba(78,137,107,.25); }
.event-title { overflow-wrap: anywhere; font-size: clamp(28px, 4vw, 42px); font-weight: 500; letter-spacing: .08em; margin-bottom: 24px; }
.event-text, .result-text { white-space: pre-line; line-height: 2; font-size: clamp(15px, 2vw, 18px); color: #cfcec8; }
.choice-label { color: var(--dim); font: 10px sans-serif; letter-spacing: .2em; margin-top: 30px; }
.choice-btn { padding-left: 52px; }
.choice-btn .key { position: absolute; left: 18px; top: 16px; color: var(--red-hi); font: 12px monospace; }
.choice-btn .requirement { display: block; margin-top: 5px; color: #8c8982; font: 10px sans-serif; }
.choice-btn .clue-requirement { display: block; margin-top: 6px; color: #d4c190; font: 10px/1.5 sans-serif; letter-spacing: .04em; }
.result-box { border-left: 2px solid var(--red); padding-left: 20px; margin: 28px 0; }
.effects { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.effect-chip { padding: 7px 10px; border: 1px solid var(--line); color: var(--muted); font: 11px sans-serif; }
.effect-chip.bad { color: #dc7779; border-color: rgba(184,66,69,.35); }
.effect-chip.good { color: #9cc3ae; border-color: rgba(117,158,137,.35); }
.clue-unlock { margin-top: 16px; color: #d4c190; font-size: 14px; }

.summary-section-label { margin: 24px 0 10px; color: var(--dim); text-align: left; font: 11px/1.5 sans-serif; letter-spacing: .16em; }
.summary-grid { margin: 0 0 26px; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); }
.summary-item { padding: 16px 10px; text-align: center; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: none; }
.summary-item strong { display: block; font-size: 24px; margin-top: 8px; }
.summary-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 28px; text-align: left; }
.summary-lists h3 { color: var(--dim); font: 11px sans-serif; letter-spacing: .16em; }
.summary-lists ul { margin: 0; padding-left: 18px; color: #c5c4bd; line-height: 1.8; }

.ending-no { color: var(--red-hi); font: 11px sans-serif; letter-spacing: .25em; }
.ending-title { font-size: clamp(38px, 6vw, 64px); font-weight: 400; letter-spacing: .12em; }
.ending-copy { max-width: 620px; margin: 20px auto; line-height: 2; color: #c4c3bd; }
.ending-analysis { max-width: 620px; margin: 28px auto 0; padding: 18px 22px; border-left: 2px solid var(--red); background: rgba(255,255,255,.03); text-align: left; }
.ending-analysis h3, .route-progress summary { color: var(--dim); font: 11px/1.5 sans-serif; letter-spacing: .16em; }
.ending-analysis ul, .route-progress ul { margin: 10px 0 0; padding-left: 20px; color: #c5c4bd; line-height: 1.8; }
.route-progress { max-width: 620px; margin: 20px auto 0; padding: 14px 18px; border: 1px solid var(--line); text-align: left; }
.route-progress summary { cursor: pointer; }
.archive-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 24px; }
.archive-card { min-height: 145px; padding: 20px; border: 1px solid var(--line); background: rgba(9,10,11,.78); text-align: left; }
.archive-card.locked { color: #5c5e5b; background: rgba(9,10,11,.5); }
.archive-card small { color: var(--red-hi); font: 10px sans-serif; letter-spacing: .14em; }
.archive-card h3 { margin: 14px 0 8px; font-weight: 500; }
.archive-card p { color: var(--dim); font-size: 12px; line-height: 1.6; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line); }
.switch { min-width: 78px; padding: 9px; color: var(--muted); border: 1px solid var(--line); background: transparent; cursor: pointer; }
.save-meta { margin-top: 20px; color: var(--dim); font: 11px/1.7 sans-serif; }
.danger-text { color: #d36769; }
.corruption { animation: jitter 2.2s infinite; }
@keyframes jitter {
  0%,94%,100% { transform: none; text-shadow: none; }
  95% { transform: translateX(1px); }
  96% { transform: translate(-2px, .5px); }
  97% { transform: translate(2px, -.5px); text-shadow: 1px 0 rgba(184,66,69,.28); }
  98% { transform: translateX(-1px); }
  99% { transform: translateX(.5px); }
}
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: grid; gap: 8px; }
.toast { max-width: 300px; padding: 12px 16px; background: #161819; border: 1px solid rgba(212,193,144,.35); color: #d4c190; box-shadow: 0 8px 30px #000; font-size: 13px; animation: toastIn .25s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.archive-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left)); background: rgba(2,3,4,.78); backdrop-filter: blur(8px); }
.archive-window { width: min(820px, 100%); max-height: min(760px, calc(88dvh - var(--safe-top) - var(--safe-bottom))); overflow: hidden; display: flex; flex-direction: column; border: 1px solid rgba(184,66,69,.34); background: rgba(11,13,14,.97); box-shadow: 0 35px 100px #000; }
.archive-header { padding: 24px 28px 18px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.archive-header h2 { margin: 0; font-weight: 500; letter-spacing: .1em; }
.archive-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.archive-tab { min-height: 48px; border: 0; border-right: 1px solid var(--line); color: var(--dim); background: transparent; cursor: pointer; }
.archive-tab:last-child { border-right: 0; }
.archive-tab.active { color: var(--ink); background: rgba(111,29,33,.26); box-shadow: inset 0 -2px var(--red-hi); }
.archive-content { min-height: 280px; padding: 26px 30px 34px; overflow-y: auto; }
.dossier-section + .dossier-section { margin-top: 28px; }
.dossier-section h3 { color: var(--red-hi); font: 600 11px/1.5 sans-serif; letter-spacing: .16em; }
.dossier-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.dossier-list li { padding: 12px 14px; border-left: 2px solid rgba(184,66,69,.45); background: rgba(255,255,255,.035); color: #c9c8c2; line-height: 1.7; }
.dossier-empty { padding: 40px 0; text-align: center; color: var(--dim); }
.locked-note { color: #585b58 !important; border-left-color: rgba(255,255,255,.08) !important; }
.clue-status { display: block; margin: 5px 0 0 28px; color: #777a76; font: normal 9px/1.4 sans-serif; letter-spacing: .12em; }

@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  :root { --topbar-base: 58px; }
  .topbar {
    height: calc(var(--topbar-base) + var(--safe-top));
    padding: calc(7px + var(--safe-top)) calc(12px + var(--safe-right)) 7px calc(12px + var(--safe-left));
  }
  .brand-mark { width: 50px; height: 42px; padding: 4px; }
  .brand-mark span { font-size: 20px; }
  .icon-btn { width: 44px; height: 44px; }
  .screen {
    min-height: calc(var(--app-height, 100vh) - var(--topbar-base) - var(--safe-top));
    padding: 12px calc(12px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(12px + var(--safe-left));
    align-items: flex-start;
  }
  .panel { margin-top: clamp(8px, 5vh, 42px); padding: 24px 20px; }
  /* The title artwork stays full-screen on phones. Its lit windows remain a
     quiet visual hook underneath the UI, without taking up layout space. */
  .app[data-scene="title"] .scene-bg {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: brightness(1.34) contrast(1.07) saturate(.9);
  }
  .app[data-scene="title"] .scene-bg::after {
    background:
      linear-gradient(90deg, rgba(3,4,5,.5), rgba(3,4,5,.28) 52%, rgba(3,4,5,.44)),
      linear-gradient(0deg, rgba(3,4,5,.58), rgba(3,4,5,.12) 58%, rgba(3,4,5,.34));
  }
  .app[data-scene="title"] .scene-vignette {
    box-shadow: inset 0 0 76px 12px rgba(1,2,3,.56);
  }
  .app[data-scene="title"] .title-panel {
    top: 0;
    margin-top: 12px;
    padding-bottom: 34px;
    background: linear-gradient(90deg, rgba(8,10,11,.78), rgba(8,10,11,.66) 70%, rgba(8,10,11,.7));
    backdrop-filter: none;
  }
  .app[data-scene="title"] .title-panel .btn {
    background: rgba(14,16,17,.86);
  }
  .app[data-scene="title"] .title-panel .btn.primary {
    background: rgba(111,29,33,.9);
  }
  .app[data-scene="title"] .title-panel .btn.ghost {
    background: rgba(10,12,13,.82);
  }
  .title-panel > .actions { gap: 9px; margin-top: 21px; }
  .title-panel .btn { min-height: 56px; }
  .title-panel .actions.inline { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 9px; }
  .title-panel .actions.inline .btn { padding-inline: 6px; text-align: center; font-size: 13px; }
  .build-version { right: 16px; bottom: 10px; }
  .app[data-scene="summary"] .screen { padding-top: 8px; }
  .app[data-scene="summary"] .panel { margin-top: 0; }
  .event-shell { grid-template-columns: 1fr; gap: 12px; }
  .hud { display: grid; grid-template-columns: 1fr auto; padding: 10px 12px; }
  .hud .eyebrow { margin-bottom: 5px; }
  .hud .stats { grid-column: 1 / -1; grid-template-columns: repeat(2, 1fr); gap: 8px 12px; margin-top: 8px; }
  .night-index { margin-bottom: 0; font-size: 20px; }.time { text-align: right; font-size: 16px; }
  .stat-row { grid-template-columns: 34px 1fr 24px; gap: 6px; font-size: 11px; }
  .hud, .event-card { backdrop-filter: none; }
  .event-card { min-width: 0; min-height: 0; padding: 19px 16px 22px; }
  .event-card .eyebrow { margin-bottom: 9px; }
  .event-title { margin-bottom: 13px; font-size: 30px; }
  .event-text, .result-text { font-size: 16px; line-height: 1.7; }
  .choice-label { margin-top: 17px; margin-bottom: 8px; }
  .event-card .actions { gap: 10px; margin-top: 8px; }
  .choice-btn { min-height: 56px; padding: 11px 14px 11px 44px; font-size: 16px; line-height: 1.45; }
  .choice-btn .key { top: 50%; left: 16px; transform: translateY(-50%); }
  .rules-panel::after { display: none; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-item { padding-block: 14px; }
  .summary-item:nth-child(2) { border-right: none; }.summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .summary-lists { grid-template-columns: 1fr; }
  .character-layer { width: 70vw; right: -15vw; opacity: .25; }
  .archive-quick { position: static; min-height: 44px; padding: 0 10px; font-size: 11px; background: rgba(13,15,16,.82); box-shadow: none; }
  .screen { padding-bottom: calc(24px + var(--safe-bottom)); }

  /* Mobile event layout: show the complete 16:9 artwork as a scene header,
     then place HUD and story cards below it instead of covering the image. */
  .app[data-scene="guard"] .scene-bg,
  .app[data-scene="corridor"] .scene-bg,
  .app[data-scene="stairwell"] .scene-bg,
  .app[data-scene="cctv"] .scene-bg {
    position: absolute;
    inset: calc(var(--topbar-base) + var(--safe-top)) 0 auto;
    height: var(--scene-mobile-height);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }
  .app[data-scene="guard"] .scene-bg::after,
  .app[data-scene="corridor"] .scene-bg::after,
  .app[data-scene="stairwell"] .scene-bg::after,
  .app[data-scene="cctv"] .scene-bg::after {
    background: linear-gradient(0deg, #090a0b 0%, rgba(9,10,11,.12) 28%, rgba(4,5,6,.05) 100%);
  }
  .app[data-scene="guard"] .scene-vignette,
  .app[data-scene="corridor"] .scene-vignette,
  .app[data-scene="stairwell"] .scene-vignette,
  .app[data-scene="cctv"] .scene-vignette {
    position: absolute;
    inset: calc(var(--topbar-base) + var(--safe-top)) 0 auto;
    height: var(--scene-mobile-height);
    box-shadow: none;
  }
  .app[data-scene="guard"] .screen,
  .app[data-scene="corridor"] .screen,
  .app[data-scene="stairwell"] .screen,
  .app[data-scene="cctv"] .screen {
    padding-top: calc(var(--scene-mobile-height) + 12px);
  }
  .app[data-scene="guard"] .character-layer,
  .app[data-scene="cctv"] .character-layer {
    position: absolute;
    top: calc(var(--topbar-base) + var(--safe-top));
    right: -8vw;
    bottom: auto;
    width: 52vw;
    height: var(--scene-mobile-height);
  }
  .app[data-scene="guard"] .scene-bg { background-position: 72% center; }
  .app[data-scene="corridor"] .scene-bg { background-position: center; }
  .app[data-scene="stairwell"] .scene-bg { background-position: 58% center; }
  .app[data-scene="cctv"] .scene-bg { background-position: center; }
  .archive-modal { padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); align-items: end; }
  .archive-window { width: 100%; max-height: calc(88dvh - var(--safe-top) - var(--safe-bottom)); border-width: 1px 0 0; }
  .archive-header { padding: 20px; }
  .archive-content { padding: 22px 18px calc(30px + var(--safe-bottom)); }
  .archive-tab { font-size: 13px; }
  .toast-region { top: calc(66px + var(--safe-top)); right: calc(12px + var(--safe-right)); bottom: auto; left: auto; }
  .toast { max-width: min(220px, calc(100vw - 24px)); padding: 10px 13px; }
  .manual-panel { margin-top: 0; }
  .manual-lead { font-size: 15px; line-height: 1.75; }
  .manual-grid, .manual-stats { grid-template-columns: 1fr; }
  .manual-section { padding: 16px; }
  .manual-stats > div { padding: 15px 16px; border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .manual-stats > div:last-child { border-bottom: 0 !important; }
}

@media (hover: none) and (pointer: coarse) {
  .btn:hover:not(:disabled) { transform: none; border-color: rgba(232,231,225,.24); background: rgba(20,22,23,.76); }
  .btn:hover::before { transform: scaleY(0); }
  .btn.primary:hover:not(:disabled) { border-color: rgba(184,66,69,.72); background: rgba(111,29,33,.82); }
  .btn.ghost:hover:not(:disabled) { background: transparent; }
  .btn:active:not(:disabled) { border-color: rgba(184,66,69,.72); background: rgba(56,25,27,.82); }
  .btn:active::before { transform: scaleY(1); }
  .icon-btn:hover, .archive-quick:hover { color: inherit; background: rgba(8,9,10,.62); }
}

/* Compact landscape phones: keep controls inside side cutouts and reduce
   decorative vertical space without forcing a separate horizontal UI. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --topbar-base: 52px; --scene-mobile-height: clamp(112px, 32vh, 150px); }
  .topbar {
    height: calc(var(--topbar-base) + var(--safe-top));
    padding: calc(5px + var(--safe-top)) calc(10px + var(--safe-right)) 5px calc(10px + var(--safe-left));
  }
  .brand-mark { width: 46px; height: 38px; }
  .brand-mark span { font-size: 18px; }
  .icon-btn { width: 40px; height: 40px; }
  .screen {
    min-height: calc(var(--app-height, 100vh) - var(--topbar-base) - var(--safe-top));
    padding: 8px calc(12px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(12px + var(--safe-left));
    align-items: flex-start;
  }
  .app[data-scene="title"] .title-panel { top: 0; padding: 18px 24px 28px; }
  .app[data-scene="title"] .game-title { margin-bottom: 6px; font-size: 38px; line-height: 1.02; }
  .app[data-scene="title"] .subtitle { line-height: 1.5; }
  .app[data-scene="title"] .quote-line { margin: 12px 0; }
  .app[data-scene="title"] .title-panel > .actions { margin-top: 12px; gap: 7px; }
  .app[data-scene="title"] .title-panel .btn { min-height: 44px; padding-block: 8px; }
  .event-shell { gap: 12px; }
  .event-card { min-height: 0; padding: 22px 24px; }
}

@media (max-width: 359px) {
  :root { --topbar-base: 54px; --scene-mobile-height: 176px; }
  .topbar { padding-inline: calc(8px + var(--safe-left)) calc(8px + var(--safe-right)); }
  .brand-mark { width: 46px; height: 38px; }
  .panel { padding: 20px 15px; }
  .game-title { font-size: 38px; }
  .event-title { font-size: 26px; }
  .event-text, .result-text { font-size: 15px; }
  .choice-btn { padding-left: 40px; font-size: 15px; }
  .choice-btn .key { left: 13px; }
  .hud .stats { grid-template-columns: 1fr; }
  .archive-tab { font-size: 12px; }
}

@media (orientation: portrait) and (max-height: 700px) {
  .app[data-scene="title"] .title-panel { margin-top: 4px; padding-top: 18px; padding-bottom: 28px; }
  .app[data-scene="title"] .game-title { margin-bottom: 8px; font-size: 38px; line-height: 1.02; }
  .app[data-scene="title"] .subtitle { font-size: 14px; line-height: 1.55; }
  .app[data-scene="title"] .quote-line { margin: 12px 0; }
  .app[data-scene="title"] .title-panel > .actions { margin-top: 12px; gap: 7px; }
  .app[data-scene="title"] .title-panel .btn { min-height: 46px; padding-block: 7px; }
}

@media (min-width: 768px) {
  .app[data-scene="title"] .scene-bg { filter: brightness(1.14); }
}

@media (min-width: 768px) and (max-height: 800px) {
  .app[data-scene="title"] .screen { align-items: flex-start; padding-top: 10px; padding-bottom: 10px; }
  .app[data-scene="title"] .title-panel { top: 0; padding: 28px 42px 30px; }
  .app[data-scene="title"] .game-title { margin-bottom: 8px; font-size: 56px; }
  .app[data-scene="title"] .subtitle { line-height: 1.6; }
  .app[data-scene="title"] .quote-line { margin: 16px 0; }
  .app[data-scene="title"] .title-panel > .actions { gap: 8px; margin-top: 18px; }
  .app[data-scene="title"] .title-panel .actions.inline { gap: 8px; margin-top: 8px; }
  .app[data-scene="title"] .btn { min-height: 48px; padding-block: 10px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
