/*! 人別帳 © 2026 烏蜃工房 (Ushin Kobo) 無断転載・複製・再配布を禁じます。 */

:root {
  --desk: #1c2631;        
  --desk-raised: #253241;
  --on-desk: #d8d0bf;     
  --on-desk-dim: #9a9384;
  --paper: #e4d9c1;       
  --paper-edge: #cbbd9c;
  --ink: #23201b;         
  --ink-faded: #7a7062;   
  --shu: #a6342a;         
  --focus: #e7b75f;
  --font: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --radius: 2px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--desk);
  transition: background-color 1.6s ease;
  
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.05) 0 1px, transparent 1px 4px);
  color: var(--on-desk);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.8;
  overflow-wrap: break-word;
}
[hidden] { display: none !important; }
.screen { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.paper, .title-sheet, .ledger, .event, .kakocho, .about {
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,0.35), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(120,95,50,0.12), transparent 60%),
    repeating-linear-gradient(97deg, rgba(120,95,50,0.035) 0 1px, transparent 1px 7px);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--paper-edge), 0 14px 30px -18px rgba(0,0,0,0.7);
  border-radius: var(--radius);
}
.btn {
  font: inherit;
  cursor: pointer;
  min-height: 44px;
  padding: 0.5rem 1.4rem;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  letter-spacing: 0.08em;
}
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { background: #3a352d; }
.btn-quiet { border-color: transparent; text-decoration: underline; text-underline-offset: 0.3em; }
.btn:focus-visible, .ledger:focus-visible, .choice:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
#screen-title {
  display: grid;
  gap: 2rem;
  align-items: center;
  min-height: 92vh;
}
.title-sheet {
  writing-mode: vertical-rl;
  justify-self: center;
  padding: 2.5rem 1.75rem;
  min-height: 24rem;
  display: flex;
  gap: 1rem;
}
.title-main {
  margin: 0;
  font-size: clamp(3.5rem, 12vw, 5.5rem);
  font-weight: 800;
  letter-spacing: 0.35em;
  line-height: 1.1;
}
.title-sub { margin: 0; padding-top: 4.5rem; font-size: var(--step-1); letter-spacing: 0.25em; color: var(--ink-faded); }
.title-side { max-width: 34em; }
.lead, .caution { word-break: auto-phrase; }
.title-side .lead { font-size: var(--step-1); line-height: 2; margin: 0 0 1.25rem; }
.caution { font-size: var(--step--1); color: var(--on-desk-dim); border-left: 2px solid var(--on-desk-dim); padding-left: 0.9rem; margin: 0 0 1.75rem; }
.title-side .btn-primary { background: var(--paper); color: var(--ink); border-color: var(--paper); font-size: var(--step-1); padding: 0.6rem 2.4rem; }
.title-side .btn-primary:hover { background: #fff6e2; }
.title-side .btn-quiet { margin-left: 0.5rem; color: var(--on-desk); }
.credit { margin-top: 2.5rem; font-size: var(--step--1); color: var(--on-desk-dim); letter-spacing: 0.2em; }
@media (min-width: 768px) {
  #screen-title { grid-template-columns: auto 1fr; gap: 4rem; padding-left: 3rem; }
}
.status { display: flex; gap: 0.9rem; align-items: center; padding: 0.25rem 0.25rem 0.9rem; }
.crest-box { flex: none; width: 3rem; color: var(--paper); opacity: 0.85; }
.crest { display: block; width: 100%; height: auto; }
.status-main p { margin: 0; line-height: 1.65; }
.st-line1, .st-line2 { display: flex; flex-wrap: wrap; gap: 0 1em; align-items: baseline; }
.st-when { font-size: var(--step-1); letter-spacing: 0.06em; }
.status small { font-size: var(--step--1); color: var(--on-desk-dim); margin-left: 0.2em; }
.st-cond { font-size: var(--step--1); color: var(--on-desk-dim); display: inline-flex; flex-wrap: wrap; gap: 0 1em; }
.st-cond > span, .status small { white-space: nowrap; }
@media (max-width: 480px) { .crest-box { width: 2.4rem; } .st-when { font-size: var(--step-0); } }
.st-cond b { color: var(--on-desk); font-weight: 400; }
.ledger-wrap { position: relative; min-width: 0; }
.legend { margin: 0.6rem 0.25rem 0; font-size: var(--step--1); color: var(--on-desk-dim); max-width: 52em; }
.legend summary { cursor: pointer; color: var(--on-desk); width: max-content; }
.legend summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.legend p { margin: 0.3rem 0 0; }
.legend strong { color: var(--on-desk); font-weight: 700; }
.seal-mini {
  display: inline-block; width: 1.5em; height: 1.5em; line-height: 1.35em; text-align: center;
  margin: 0 0.25em 0 0.6em; font-size: 0.85em; font-weight: 800;
  color: #e58b7f; border: 1.5px solid #e58b7f; border-radius: 2px;
}
.ledger {
  writing-mode: vertical-rl;
  
  width: 100%;
  max-width: 100%;
  height: clamp(17rem, 44vh, 27rem);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1.5rem 1.25rem;
  font-size: 0.95rem;
  line-height: 1.6;
  scrollbar-color: var(--paper-edge) transparent;
}
.entry {
  margin: 0;
  padding: 0 0.55rem;
  
  padding-inline-start: 1.6em;
  text-indent: -1.6em;
  border-left: 1px solid rgba(35,32,27,0.14);
  letter-spacing: 0.06em;
  position: relative;
}
.entry .yr, .entry .seal { text-indent: 0; }
.entry .yr { font-weight: 700; margin-block-end: 0.8em; display: inline-block; }
.entry .part + .part::before { content: "　"; }
.entry.old { color: var(--ink-faded); }
.entry.birth .yr, .entry.death .yr { color: var(--ink); }
.seal {
  display: inline-block;
  writing-mode: horizontal-tb;
  width: 1.7em; height: 1.7em;
  line-height: 1.55em;
  margin-block-start: 0.6em;
  text-align: center;
  font-size: 0.85em;
  font-weight: 800;
  color: var(--shu);
  border: 2px solid var(--shu);
  border-radius: 3px;
  transform: rotate(-4deg);
  opacity: 0.88;
}
.seal.new { animation: stamp 420ms cubic-bezier(.2,.9,.3,1.2) both; animation-delay: calc(var(--i, 0) * 32ms + 150ms); }
.entry.writing .ch { display: inline; opacity: 0; animation: ink 300ms ease-out forwards; animation-delay: calc(var(--i) * 32ms); }
@keyframes ink {
  0% { opacity: 0; filter: blur(2px); }
  60% { opacity: 0.85; }
  100% { opacity: 1; filter: blur(0); }
}
@keyframes stamp {
  0% { transform: scale(1.9) rotate(-12deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: scale(1) rotate(-4deg); opacity: 0.88; }
}
.play-lower { display: grid; gap: 1rem; margin-top: 1rem; align-items: start; }
@media (min-width: 900px) { .play-lower { grid-template-columns: minmax(0, 46em) 15rem; } }
.event { position: relative; padding: 1.4rem 1.5rem 1.25rem; overflow: hidden; }
.event > *:not(.season-mark) { position: relative; }
.season-mark { position: absolute; right: -0.5rem; top: -0.5rem; width: 8.5rem; color: var(--ink); opacity: 0.14; pointer-events: none; }
.season-art { display: block; width: 100%; height: auto; }
.family { background: rgba(255,255,255,0.04); border-left: 2px solid rgba(216,208,191,0.25); padding: 0.75rem 1rem; }
.family-title { margin: 0 0 0.4rem; font-size: var(--step-0); font-weight: 700; letter-spacing: 0.3em; }
.family-list { list-style: none; margin: 0; padding: 0; font-size: 0.95rem; }
.family-list li { display: grid; grid-template-columns: 3.2em 1fr auto; gap: 0.5em; padding: 0.15rem 0; border-bottom: 1px dotted rgba(216,208,191,0.15); }
.family-list .rel { color: var(--on-desk-dim); }
.family-list .age { font-size: var(--step--1); color: var(--on-desk-dim); }
.family-list li.gone { color: var(--on-desk-dim); opacity: 0.8; }
.family-gone { margin-top: 0.5rem; font-size: var(--step--1); color: var(--on-desk-dim); }
.family-gone summary { cursor: pointer; }
.family-gone summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.chronicle { width: 100%; border-collapse: collapse; font-size: var(--step--1); line-height: 1.6; }
.chronicle th, .chronicle td { text-align: left; vertical-align: top; padding: 0.3rem 0.4rem; border-bottom: 1px solid rgba(35,32,27,0.15); }
.chronicle th { font-weight: 700; }
.chronicle td:first-child { white-space: nowrap; }
.chronicle a { color: var(--ink); }
.event-notes p { margin: 0 0 0.6rem; }
.event-question { margin: 0.9rem 0 0.75rem; font-weight: 700; }
.event-choices { display: grid; gap: 0.5rem; }
.choice {
  font: inherit; text-align: left; cursor: pointer;
  min-height: 44px;
  padding: 0.55rem 1rem;
  background: rgba(255,255,255,0.28);
  color: var(--ink);
  border: 1px solid rgba(35,32,27,0.45);
  border-radius: var(--radius);
}
.choice:hover:not(:disabled) { background: rgba(255,255,255,0.55); border-color: var(--ink); }
.choice:disabled { opacity: 0.45; cursor: not-allowed; }
.choice .why { font-size: var(--step--1); color: var(--ink-faded); margin-left: 0.5rem; }
.event-result { margin: 0.9rem 0 0; padding-left: 0.9rem; border-left: 2px solid var(--ink-faded); }
.controls { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 1.25rem; }
#screen-end { display: grid; gap: 2rem; align-items: start; padding-top: 2.5rem; }
.kakocho {
  writing-mode: vertical-rl;
  justify-self: center;
  width: max-content;
  padding: 2rem 1.75rem;
  min-height: 22rem;
  line-height: 2;
  letter-spacing: 0.12em;
}
.kakocho h2 { margin: 0 0 0 1rem; font-size: var(--step-1); color: var(--ink-faded); font-weight: 400; }
.kakocho .k-name { font-size: var(--step-2); font-weight: 800; margin: 0 0 0 0.6rem; }
.kakocho p { margin: 0 0 0 0.5rem; }
.kakocho .seal { margin-block-start: 1.2em; }
.end-side { max-width: 34em; }
.end-summary p { margin: 0 0 0.6rem; }
.end-facts { margin: 1.5rem 0; padding: 1rem 1.25rem; background: var(--desk-raised); border-radius: var(--radius); font-size: 0.97rem; }
.end-facts h3 { margin: 0 0 0.5rem; font-size: var(--step-0); }
.end-facts ul { margin: 0; padding-left: 1.2em; }
.end-facts li { margin-bottom: 0.4rem; }
.end-facts .src { font-size: var(--step--1); color: var(--on-desk-dim); }
.end-facts a { color: var(--on-desk); }
.end-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.end-actions .btn-primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.end-actions .btn-quiet { color: var(--on-desk); }
@media (min-width: 768px) { #screen-end { grid-template-columns: auto 1fr; gap: 3.5rem; } }
body.review #screen-play .event .controls #btn-next,
body.review #screen-play .event .controls #btn-skip { display: none; }
.about { max-width: 42em; width: calc(100% - 2rem); padding: 1.75rem 2rem; border: none; line-height: 1.9; }
.about::backdrop { background: rgba(10,14,19,0.7); }
.about h2 { margin-top: 0; font-size: var(--step-2); }
.about h3 { font-size: var(--step-1); margin: 1.5rem 0 0.4rem; }
.about .sources { font-size: var(--step--1); padding-left: 1.4em; }
.about .sources a { color: var(--ink); }
body[data-mood="joy"] { --desk: #262a3a; }
body[data-mood="famine"] { --desk: #2b2a27; }
body[data-mood="plague"] { --desk: #1b2826; }
body[data-mood="death"] { --desk: #10151b; }
.ledger, .event { transition: filter 1.6s ease; }
body[data-mood="famine"] .ledger, body[data-mood="famine"] .event { filter: saturate(0.55) brightness(0.93); }
body[data-mood="plague"] .ledger, body[data-mood="plague"] .event { filter: hue-rotate(-12deg) saturate(0.75); }
.k-crest { writing-mode: horizontal-tb; width: 3.4rem; margin-inline-start: auto; color: var(--ink-faded); align-self: end; }
.site-footer { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; font-size: var(--step--1); color: var(--on-desk-dim); letter-spacing: 0.06em; }
.site-footer p { margin: 0.2rem 0; }
.site-footer a { color: var(--on-desk); }
#screen-title { min-height: 82vh; }
.choose-form { display: grid; gap: 0.9rem; }
.choose-form label { display: grid; gap: 0.25rem; font-weight: 700; }
.choose-form select { font: inherit; font-weight: 400; min-height: 44px; padding: 0.3rem 0.5rem; background: rgba(255,255,255,0.5); color: var(--ink); border: 1px solid rgba(35,32,27,0.45); border-radius: var(--radius); }
.choose-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.4rem; }
.about .note { font-size: var(--step--1); color: var(--ink-faded); }
@media (prefers-reduced-motion: reduce) {
  .seal.new { animation: none; }
  .entry.writing .ch { animation: none; opacity: 1; }
  body, .ledger, .event { transition: none; }
  * { scroll-behavior: auto !important; }
}
.terms { padding-top: 2rem; }
.terms-sheet { margin: 0 auto; max-width: 44em; }
.terms-sheet h1 { font-size: var(--step-2); margin: 0.5rem 0 1rem; }
.terms-sheet h2 { font-size: var(--step-1); margin: 1.8rem 0 0.5rem; }
.terms-sheet ul { padding-left: 1.3em; }
.terms-sheet a { color: var(--ink); }
.terms-back { margin: 0; font-size: var(--step--1); }
.terms-date { margin-top: 2rem; font-size: var(--step--1); color: var(--ink-faded); }
