/* 午前零時の校正室 — 墨、紙、朱。外部フォント・通信に依存しない読書面。 */
:root {
  --paper: #f0e9da; --paper-light: #f8f2e6; --ink: #332e28; --ink-soft: #6c6155;
  --vermilion: #a34432; --rule: #b7a68c; --accent: #a34432; --accent-warm: #9b3d2d;
  --tb-bg: #f0e9da; --tb-border: #b7a68c80;
}
html, body { background: #171612; }
body { color: var(--ink); }
button { -webkit-appearance: none; }
button:focus-visible, .slot:focus-visible { outline: 2px solid var(--vermilion); outline-offset: 4px; }
#game { max-width: 1600px; max-height: 900px; background: #201d18; }

/* 表紙 */
#title-screen { align-items: flex-start; justify-content: center; color: var(--paper-light); }
#title-screen::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg,#161511ee 0%,#171510c9 31%,#201a1370 54%,#201a1310 76%),linear-gradient(0deg,#17130fc4,transparent 26%); pointer-events: none; }
#title-screen::after { content: ""; position: absolute; inset: 27px; border: 1px solid #e1cfab26; pointer-events: none; }
.title-topline { position: absolute; z-index: 1; top: 6.4%; left: 7.5%; right: 7.5%; display: flex; align-items: center; gap: 13px; color: #e8ddca; font: 10px/1.6 "Yu Gothic", "Meiryo", sans-serif; letter-spacing: .22em; }
.title-topline > span:last-child { font-size: 10px; letter-spacing: .15em; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 27px; border: 1px solid #b66a53; color: #d28f73; font: 17px/1 "Yu Mincho",serif; letter-spacing: 0; }
.brand-rule { width: 30px; height: 1px; background: #d6c39d66; }
.title-content { position: relative; z-index: 1; margin-left: 10%; width: 460px; padding-top: 15px; }
.title-kicker { margin: 0 0 20px; color: #c3b49d; font-size: 11px; line-height: 1.8; letter-spacing: .13em; }
#title-logo { margin: 0 0 15px -4px; padding: 0; font-size: clamp(40px,4.8vw,66px); font-weight: 400; line-height: 1.42; letter-spacing: .11em; white-space: pre-line; text-align: left; text-shadow: 0 2px 25px #0c080a55; }
#title-sub { margin-bottom: 30px; padding-left: 2px; color: #e5d5bb; font-size: 13px; line-height: 2; letter-spacing: .17em; text-align: left; }
.title-menu { width: 280px; gap: 9px; align-items: stretch; }
.tbtn { border-radius: 0; background: #f7f1e588; border: 1px solid var(--rule); color: var(--ink); font-size: 15px; }
.tbtn:hover:not(:disabled) { background: #fff8e8; border-color: var(--vermilion); letter-spacing: .2em; }
.title-menu .tbtn { width: 100%; border-radius: 0; font-size: 13px; letter-spacing: .18em; padding: 13px 18px; text-align: left; background: #30271d55; border-color: #c9b79677; color: #ece0cb; }
.title-menu .tbtn.primary, .title-menu .tbtn.continue { display: flex; justify-content: space-between; align-items: center; }
.title-menu .tbtn.primary { border-color: #e6d7ba; background: #e8ddc5; color: #34281e; }
.title-menu .tbtn.primary > span:last-child { color: #9b3e2a; }
.title-menu .tbtn.continue:disabled { opacity: .45; }
.title-menu .tbtn:hover:not(:disabled) { letter-spacing: .18em; background: #54422b77; border-color: #f1e0bc; }
.title-menu .tbtn.primary:hover:not(:disabled) { background: #f7ebd2; border-color: #fff1d4; }
.title-menu .tbtn:focus-visible { outline-color: #e7c791; }
.title-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; margin-top: 3px; }
.title-secondary .tbtn { padding: 10px 0; background: transparent; border: 0; border-bottom: 1px solid #d7c4a52e; font-size: 11px; color: #d2c4ad; }
.title-secondary .tbtn:hover:not(:disabled) { background: transparent; border-color: #d7c4a5; color: #fff2d7; }
.title-stamp { position: absolute; z-index: 1; right: 9%; bottom: 17%; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 87px; height: 102px; border: 2px solid #b7684b; outline: 1px solid #b7684b; outline-offset: -6px; color: #c17b5b; transform: rotate(-7deg); opacity: .88; text-shadow: 0 1px 8px #21170b; }
.title-stamp > span { font-size: 30px; line-height: 1.4; letter-spacing: .05em; }
.title-stamp > small { padding-top: 6px; border-top: 1px solid #b7684b; font-size: 9px; letter-spacing: .18em; }
.title-bottom { position: absolute; z-index: 1; left: 7.5%; right: 7.5%; bottom: 6%; display: flex; justify-content: space-between; align-items: center; color: #cbbda5; font-size: 10px; line-height: 1.7; letter-spacing: .12em; }
#title-version { right: 7.5%; bottom: 2.4%; z-index: 1; color: #a99b84; font: 9px/1.4 "Yu Gothic",sans-serif; letter-spacing: .08em; }

/* 本文 — 名前札と文章の地色を揃え、一枚の校正紙として読ませる。 */
#vignette { background: linear-gradient(0deg,#1e170f3d,transparent 55%),radial-gradient(ellipse at center,transparent 55%,#1b140f55); }
#chapter-label { position: absolute; left: 5%; top: 5%; z-index: 4; padding: 9px 15px; border-left: 2px solid #be7456; color: #f0e4cf; background: #252018cc; font-size: 11px; letter-spacing: .16em; pointer-events: none; }
#textbox { width: 88%; bottom: 5%; min-height: 26%; border-radius: 0; border: 1px solid #b8a789; border-top: 3px solid #a35540; padding: 32px 44px 33px; background: var(--paper); box-shadow: 0 12px 40px #120c0966,inset 0 0 45px #9d805a0a; backdrop-filter: none; }
#textbox::before { content: ""; position: absolute; left: 16px; top: 22px; bottom: 19px; border-left: 1px solid #b7a68c55; pointer-events: none; }
#textbox::after { content: "クリック / Enter"; position: absolute; right: 49px; bottom: 12px; color: #7d6c59; font: 8px/1.4 "Yu Gothic",sans-serif; letter-spacing: .1em; }
#namebox { top: -17px; left: 29px; padding: 5px 20px; border: 1px solid #ad9070; border-radius: 0; background: var(--paper); color: #873a2d; font-size: 14px; line-height: 1.5; letter-spacing: .13em; }
#text { font-size: 20px; line-height: 1.95; letter-spacing: .045em; color: var(--ink); text-shadow: none; overflow-wrap: anywhere; }
#advance-indicator { right: 26px; bottom: 13px; font-size: 9px; color: var(--vermilion); animation: none; }
#text ruby rt, #log-body ruby rt { color: #746758; }
.unveiled { color: var(--vermilion); text-decoration-color: #a3443277; }
#menubar { top: 5%; right: 6%; bottom: auto; z-index: 30; opacity: 1; gap: 1px; padding: 3px 5px; border: 1px solid #d1bea14d; border-radius: 0; background: #292219eb; }
.mbtn { padding: 7px 12px; border: 0; border-radius: 0; background: transparent; color: #e2d6bf; font: 10px/1.5 "Yu Gothic", "Meiryo", sans-serif; letter-spacing: .08em; }
.mbtn:hover { background: #e9d8b522; color: #fff1d6; }
.mbtn.active { color: #fff1dc; background: #8d3c2c; }
#choices { gap: 14px; padding: 38px 0 11%; background: #20180fb3; backdrop-filter: blur(4px); }
.choice-btn { width: 64%; max-width: 670px; min-height: 56px; padding: 17px 26px; border: 1px solid #ad9170; border-radius: 0; background: #f0e9daf5; box-shadow: 0 6px 20px #150e0b33; color: var(--ink); font-size: 17px; line-height: 1.65; text-align: left; overflow-wrap: anywhere; }
.choice-btn::before { content: "／"; margin-right: 18px; color: var(--vermilion); font-weight: bold; }
.choice-btn:hover { border-color: #c17652; background: #fff3db; color: #6b2d22; transform: none; }

/* 記録・設定・確認 */
.overlay { padding: 48px 64px; background: #f0e9dafc; color: var(--ink); backdrop-filter: blur(12px); }
.overlay::before { content: ""; position: absolute; inset: 18px; border: 1px solid #b7a68c55; pointer-events: none; }
.overlay h2 { color: #873a2d; font-size: 24px; font-weight: 400; border-bottom-color: #b7a68c80; }
.overlay .close-btn { border-radius: 0; border-color: #b7a68c; color: #645543; font-size: 13px; }
.overlay .close-btn:hover { color: #873a2d; border-color: #a34432; }
#log-body { min-height: 0; }
.log-entry { color: var(--ink); padding-bottom: 16px; border-bottom: 1px solid #b7a68c40; line-height: 1.95; }
.log-name { color: #873a2d; }
.log-choice { color: #873a2d; font-style: normal; }
#log-body::-webkit-scrollbar-thumb,.end-list::-webkit-scrollbar-thumb { background: #a38c6f77; }
.slot-list { min-height: 0; overflow-y: auto; padding: 2px 6px 6px 2px; }
.slot { border-radius: 0; flex-shrink: 0; border-color: #b7a68c80; background: #fffbf340; }
.slot:hover { border-color: #a34432; background: #e5d7c64d; }
.slot .slot-no { color: #8f412f; }
.slot .slot-info { min-width: 0; color: #625849; overflow-wrap: anywhere; }
.slot.empty { opacity: .65; }
.cfg-row label { color: #625849; }
.cfg-row input { accent-color: #a34432; }
.cfg-row .cfg-val { color: #873a2d; }
.cfg-toggle { border-radius: 0; color: #625849; }
.cfg-toggle.on { color: #fff1df; }
.end-item { border-radius: 0; background: #fff9ed55; color: #807263; }
.end-item.seen { border-left: 3px solid #a34432; }
.end-item .e-type { color: #78624c; font-family: "Yu Gothic",sans-serif; }
.end-item .e-desc { max-width: 50%; color: #786b5c; line-height: 1.8; }
.help-body { min-height: 0; overflow: auto; padding-right: 10px; }
.help-intro { margin-bottom: 25px; color: #783c2c; font-size: 23px; line-height: 1.8; }
.help-body dl { display: grid; grid-template-columns: 170px 1fr; gap: 14px 22px; font-size: 14px; line-height: 1.9; }
.help-body dt { color: #554536; }
.help-body dd,.help-note { color: #6c6051; }
.help-note { margin-top: 26px; font-size: 12px; line-height: 2; }
#extra-body { min-height: 0; }
#extra-body .ex-locked { color: #8b7d6c; }
#ending-screen { background: radial-gradient(ellipse at 50% 30%,#f9f2e2,#e2d3ba); color: var(--ink); padding: 25px; }
#ending-screen::before { content: ""; position: absolute; inset: 26px; border: 1px solid #b7997180; pointer-events: none; }
#ending-name { color: #733b2a; font-size: 38px; line-height: 1.6; text-shadow: none; }
#ending-type { color: #8c6d52; font-size: 13px; }
.ebtn-row .tbtn { font-size: 14px; }
#notice-overlay,#confirm-overlay { background: #211c15f5; }
#notice-overlay .n-text,#confirm-overlay .n-text { color: #e8dcc7; }
#notice-overlay .tbtn,#confirm-overlay .tbtn { background: #e8ddc5; border-color: #d5bd97; }
.n-text { white-space: pre-line; }

@media (min-width: 1450px) {
  .title-content { width: 520px; }
  .title-menu { width: 305px; }
  .title-kicker { font-size: 13px; }
  #title-sub { font-size: 15px; }
}

/* 縦持ち。画面上部の操作と下部の校正紙に十分な間隔を確保する。 */
@media (max-width: 900px) and (orientation: portrait) {
  #game { width: 100%; height: 100%; max-width: none; max-height: none; }
  #title-screen { background-position: 60% center !important; }
  #title-screen::before { background: linear-gradient(90deg,#191610e6,#211b13a8 60%,#201a1366),linear-gradient(0deg,#19150ed9,transparent 45%); }
  #title-screen::after { inset: 14px; }
  .title-topline { top: calc(5% + env(safe-area-inset-top,0px)); left: 8%; right: 8%; font-size: 8px; gap: 9px; letter-spacing: .16em; }
  .title-topline > span:last-child { font-size: 8px; letter-spacing: .06em; }
  .brand-mark { width: 21px; height: 24px; font-size: 15px; }
  .brand-rule { width: 16px; }
  .title-content { margin-left: 10%; width: 80%; padding-top: 0; }
  .title-kicker { margin-bottom: 22px; font-size: 10px; letter-spacing: .06em; }
  #title-logo { margin: 0 0 18px -2px; font-size: clamp(38px,10.6vw,66px); letter-spacing: .1em; line-height: 1.5; }
  #title-sub { max-width: 100%; margin-bottom: 30px; font-size: 12px; letter-spacing: .12em; }
  .title-menu { width: min(280px,100%); }
  .title-menu .tbtn { min-height: 44px; }
  .title-secondary { column-gap: 20px; }
  .title-stamp { display: none; }
  .title-stamp > span { font-size: 21px; }
  .title-stamp > small { font-size: 6px; padding-top: 3px; }
  .title-bottom { left: 8%; right: 8%; bottom: calc(5% + env(safe-area-inset-bottom,0px)); font-size: 8px; letter-spacing: .03em; }
  #title-version { right: 8%; bottom: calc(2% + env(safe-area-inset-bottom,0px)); font-size: 8px; }
  #chapter-label { top: calc(75px + env(safe-area-inset-top,0px)); left: 5%; max-width: 90%; font-size: 10px; }
  #menubar { top: calc(12px + env(safe-area-inset-top,0px)); bottom: auto; left: 3%; right: 3%; justify-content: space-around; flex-wrap: nowrap; padding: 2px; gap: 0; }
  .mbtn { min-height: 42px; padding: 8px 5px; font-size: 10px; letter-spacing: 0; }
  #textbox { width: 94%; min-height: 29%; bottom: calc(14px + env(safe-area-inset-bottom,0px)); padding: 28px 22px 31px; }
  #textbox::before { left: 10px; top: 20px; bottom: 17px; }
  #textbox::after { content: "タップして進む"; right: 36px; bottom: 10px; }
  #text { max-height: 50dvh; overflow-y: auto; font-size: 17px; line-height: 1.95; letter-spacing: .025em; }
  #namebox { left: 16px; font-size: 13px; padding: 5px 16px; }
  #advance-indicator { right: 19px; bottom: 11px; }
  #choices { padding: 82px 0 14%; gap: 13px; }
  .choice-btn { width: 88%; font-size: 15px; padding: 17px 16px; }
  .choice-btn::before { margin-right: 10px; }
  .overlay { padding: 26px 22px calc(24px + env(safe-area-inset-bottom,0px)); }
  .overlay::before { inset: 10px; }
  .overlay h2 { margin-bottom: 23px; padding-right: 75px; font-size: 20px; }
  .overlay .close-btn { top: 22px; right: 20px; padding: 8px 12px; }
  .help-intro { font-size: 20px; }
  .help-body dl { display: block; font-size: 14px; }
  .help-body dt { margin: 18px 0 4px; }
  .help-note { font-size: 11px; }
  .end-item .e-desc { max-width: 100%; }
  #ending-name { font-size: 28px; }
  #ending-screen::before { inset: 15px; }
  .ebtn-row { width: 100%; }
}

/* 横持ちの小画面。高さ600px以下または幅1000px以下で表紙の余白を確保し、本文は17pxを維持する。 */
@media (max-height: 600px) and (orientation: landscape), (max-width: 1000px) and (orientation: landscape) {
  #title-screen::after { inset: 12px; }
  .title-topline { top: 5%; left: 7%; font-size: 8px; gap: 9px; }
  .title-topline > span:last-child { font-size: 8px; }
  .brand-mark { width: 20px; height: 22px; font-size: 14px; }
  .title-content { margin-left: 8%; padding-top: 15px; width: 84%; display: grid; grid-template-columns: minmax(0,1fr) minmax(180px,.8fr); column-gap: 25px; }
  .title-kicker { grid-column: 1; margin: 0 0 11px; font-size: 9px; letter-spacing: .03em; }
  #title-logo { grid-column: 1; margin: 0; font-size: clamp(27px,4.8vw,38px); line-height: 1.45; letter-spacing: .1em; }
  #title-sub { grid-column: 1; margin: 12px 0 0; font-size: 10px; letter-spacing: .1em; }
  .title-menu { grid-column: 2; grid-row: 1 / 4; width: 100%; max-width: 245px; flex-direction: column; flex-wrap: nowrap; gap: 7px; align-self: center; }
  .title-menu .tbtn { min-height: 38px; padding: 9px 14px; font-size: 12px; }
  .title-secondary { margin-top: 0; column-gap: 16px; }
  .title-secondary .tbtn { min-height: 33px; padding: 8px 0; font-size: 10px; }
  .title-stamp { display: none; }
  .title-bottom { left: 7%; right: 7%; bottom: 6%; font-size: 8px; }
  #title-version { right: 7%; bottom: 2%; font-size: 7px; }
  #chapter-label { top: 7%; left: 5%; max-width: 30%; padding: 7px 9px; font-size: 9px; }
  #textbox { bottom: 5%; width: 90%; min-height: 33%; padding: 23px 29px 25px; }
  #textbox::before { left: 12px; top: 16px; bottom: 15px; }
  #textbox::after { bottom: 9px; }
  #text { max-height: 45dvh; overflow-y: auto; min-height: 3.5em; font-size: 17px; line-height: 1.75; letter-spacing: .025em; }
  #namebox { top: -14px; padding: 3px 15px; font-size: 12px; }
  #advance-indicator { bottom: 10px; }
  #menubar { top: 5%; bottom: auto; left: auto; right: 5%; flex-wrap: nowrap; gap: 0; padding: 2px; }
  .mbtn { padding: 8px 8px; font-size: 9px; letter-spacing: 0; }
  #choices { padding: 55px 0 20px; gap: 10px; }
  .choice-btn { width: 78%; min-height: 42px; padding: 10px 18px; font-size: 14px; }
  .overlay { padding: 22px 30px; }
  .overlay::before { inset: 9px; }
  .overlay h2 { margin-bottom: 16px; font-size: 18px; }
  .overlay .close-btn { top: 16px; right: 24px; }
  .help-intro { font-size: 17px; }
  .help-body dl { grid-template-columns: 140px 1fr; font-size: 12px; gap: 10px; }
  .ebtn-row .tbtn { width: 220px; }
}
@media (max-height: 650px) and (orientation: portrait) {
  .title-kicker { margin-bottom: 12px; }
  #title-logo { font-size: 36px; line-height: 1.4; margin-bottom: 10px; }
  #title-sub { margin-bottom: 19px; }
  .title-menu { gap: 6px; }
  .title-menu .tbtn { padding-top: 10px; padding-bottom: 10px; min-height: 40px; }
  .title-stamp { display: none; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation: none !important; transition: none !important; } }
