/* Shared reading layout. Loaded after the six existing themes. */
:root { --panel-gap: 16px; }
html, body { font-size: 18px; -webkit-font-smoothing: antialiased; }
#app { max-width: 1080px; max-height: 820px; height: 100dvh; }
button, a, .slot, .clip, input { touch-action: manipulation; }
button, .btn.small, #menu-bar button, .slot, .reply, .clip, input { min-height: 44px; min-width: 44px; }
button { transition: transform .15s ease, opacity .15s ease; }
button:active { scale: .97; }
:focus-visible { outline: 3px solid #ffcf86; outline-offset: 3px; }
#game-screen.active {
  display: grid; grid-template-rows: auto auto minmax(110px, 1fr) minmax(190px, 29%);
  padding: 12px var(--panel-gap) max(16px, env(safe-area-inset-bottom)); gap: 10px;
}
#stats { position: static; gap: 6px; align-content: start; }
.stat { flex: 1; min-width: 90px; font-variant-numeric: tabular-nums; }
#menu-bar { position: static; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
#menu-bar button { font-size: 14px; padding: 8px 12px; }
#portrait { position: relative; left: auto; bottom: auto; transform: none; height: 100%; min-height: 0; overflow: hidden; align-items: flex-start; }
.figure { width: auto; max-width: 100%; height: 145%; object-fit: contain; object-position: top; mask-image: linear-gradient(#000 65%, transparent 98%); }
#portrait .figure.refined { height: 145%; border-radius: 16px; }
#dialog { position: relative; inset: auto; width: 100%; height: 100%; min-height: 0; padding: 24px 22px 14px; display: flex; flex-direction: column; }
#text { font-size: 20px; line-height: 1.85; overflow-y: auto; min-height: 0; flex: 1; padding-right: 6px; overscroll-behavior: contain; user-select: text; }
#speaker { font-size: 18px; top: -15px; }
#next-hint { position: static; align-self: flex-end; flex-shrink: 0; font-size: 12px; margin-top: 2px; }
#choices { top: auto; bottom: 33%; transform: translateX(-50%); width: calc(100% - 32px); max-width: 650px; max-height: 48%; overflow-y: auto; overscroll-behavior: contain; padding: 0 6px; border-radius: 8px; background: rgba(12,10,14,.92); }
#choices:empty { display: none; }
.choice { font-size: 18px; line-height: 1.55; margin: 8px 0; text-align: left; }
#chapter-card { padding: 24px; }
#chapter-card span { font-size: clamp(24px, 5vw, 40px); line-height: 1.8; letter-spacing: 4px; text-align: center; }
#ending-screen, #title-screen { overflow-y: auto; }
.title-box, .ending-box { position: relative; top: auto; left: auto; transform: none; width: min(90%, 680px); margin: 0 auto; padding: 48px 0; }
.title-box { min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.title-box h1 { font-size: clamp(38px, 8vw, 68px); letter-spacing: .12em; }
.subtitle { font-size: 18px; line-height: 1.8; letter-spacing: 1px; }
.ending-box p, .log-line, .gallery-item small, .slot { font-size: 18px; line-height: 1.8; }
.ending-box h2 { font-size: clamp(28px, 6vw, 44px); letter-spacing: 3px; overflow-wrap: anywhere; }
.ending-box p { white-space: pre-line; }
.slot { display: block; width: 100%; color: inherit; text-align: left; font-family: inherit; }
.slot small { font-size: 16px; }
.modal-box { max-height: 90%; padding: 18px; }
#modal-body { overscroll-behavior: contain; user-select: text; }
.hub-link { display: inline-flex; min-height: 44px; padding: 10px; align-items: center; color: #ead5b8; font-size: 16px; margin-top: 12px; }
#toasts { top: 104px; pointer-events: none; }
/* Reality-show panels stay usable with a keyboard or small phone. */
.panel { padding: 12px; }
.panel > div { max-width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.panel .phone-box { width: min(100%, 420px); height: 100%; max-height: 690px; }
.phone-body { min-height: 100px; flex: 1 1 30%; }
.phone-foot { max-height: 60%; overflow-y: auto; flex-shrink: 0; min-height: 44px; }
.msg p, .reply, .edit-tip, .clip b, .clip small, .lock-box p, .trend-row { font-size: 18px; line-height: 1.6; }
.reply { border-radius: 6px; padding: 10px; }
.clips { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 45dvh; }
.clip { text-align: left; font-family: inherit; transition: transform .15s ease; }
.clip em { font-size: 14px; }
.lock-btns { flex-wrap: wrap; }
.lock-box h3 { overflow-wrap: anywhere; letter-spacing: 1px; }
.timer-bar { height: auto; min-height: 32px; }
.timer-bar span { line-height: 32px; }
.timer-bar i { transform-origin: left; }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 600px) {
  :root { --panel-gap: 10px; }
  #app { top: 0; transform: none; max-height: none; }
  #game-screen.active { padding-top: max(8px, env(safe-area-inset-top)); gap: 8px; grid-template-rows: auto auto minmax(92px, 1fr) minmax(210px, 33%); }
  .stat { min-width: 86px; font-size: 12px; padding: 4px 6px; }
  #menu-bar { justify-content: space-between; gap: 4px; }
  #menu-bar button { flex: 1; padding: 6px; }
  #dialog { padding: 24px 14px 10px; }
  #text { font-size: 18px; }
  #choices { bottom: 36%; max-height: 42%; }
  .choice { padding: 12px; }
  .title-box { padding: 32px 0; }
  .title-box h1 { letter-spacing: .08em; }
  .ending-box { padding: 32px 0; }
  .clips { grid-template-columns: 1fr; }
  .edit-box, .trend-box, .lock-box { padding: 16px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  #game-screen.active { grid-template-rows: auto auto minmax(40px, 1fr) 42%; }
  #choices { bottom: 12px; max-height: 62%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .petal, .danmaku { display: none; }
}
