/* 柴犬の一生 — 草はらの薄緑、柴の赤茶、首輪の藍。古い犬の手帳のような落ち着き */
:root {
  --field: #E9EEE4;
  --paper: #FFFEF9;
  --ink: #3B2F28;
  --ink-2: #6B5A4E;
  --ink-3: #A89A8C;
  --shiba: #C8742F;
  --collar: #3D5A80;
  --grass: #6E9B5A;
  --line: #E4DDD0;
  --serif: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--field); color: var(--ink);
  font: 500 16px/1.8 var(--sans); letter-spacing: .02em;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--collar); outline-offset: 2px; }
[hidden] { display: none !important; }

.screen {
  max-width: 480px; margin: 0 auto; min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}

/* ---------- ボタン ---------- */
.btn {
  appearance: none; border: 1.5px solid var(--ink); background: var(--paper);
  border-radius: 14px; padding: 12px 18px; font-weight: 700; cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--collar); border-color: var(--collar); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 4px; color: var(--ink-2); }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 10px; border-width: 1px; }

/* ---------- タイトル ---------- */
.title { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.title-hero { display: flex; align-items: flex-start; width: 100%; margin-top: -4vh; }
.title h1 {
  font: 800 clamp(54px, 17vw, 88px)/1.04 var(--serif); margin: 0; letter-spacing: .06em;
  writing-mode: vertical-rl; flex: none;
}
.title-dog { flex: 1; min-width: 0; aspect-ratio: 1; margin: 4vh -36px 0 -28px; }
.title-dog img, .title-dog svg { width: 100%; height: 100%; object-fit: contain; }
.lede { color: var(--ink-2); margin: 8px 0 24px; }
.title-actions { display: grid; gap: 10px; width: 100%; max-width: 320px; }
.title-actions .btn.primary { padding: 16px; font-size: 18px; }

/* ---------- 生まれ ---------- */
.kicker { color: var(--ink-2); margin: 8px 0 0; }
.birth-dog { width: 220px; aspect-ratio: 1; margin: 0 auto; }
.birth-dog img, .birth-dog svg, .life-dog img, .life-dog svg, .end-dog img, .end-dog svg { width: 100%; height: 100%; object-fit: contain; }
.facts { margin: 8px 0 16px; background: var(--paper); border-radius: 18px; padding: 6px 16px; }
.facts div { display: grid; grid-template-columns: 6.5em 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--ink-3); font-size: 14px; }
.facts dd { margin: 0; }
.name-field { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; background: var(--paper); border-radius: 18px; padding: 10px 12px 10px 16px; }
.name-field span { color: var(--ink-3); font-size: 14px; }
.name-field input { font: 800 26px/1.2 var(--serif); border: 0; border-bottom: 2px solid var(--shiba); background: transparent; color: var(--ink); width: 100%; padding: 4px 2px; }
.name-field input:focus { outline: none; border-bottom-color: var(--collar); }
.birth-actions { display: grid; gap: 8px; margin-top: 18px; }
.birth-actions .btn.primary { padding: 15px; font-size: 18px; }

/* ---------- 一生 ---------- */
.life-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.life-head h1 { font: 800 30px/1.2 var(--serif); margin: 0; }
.life-head p { margin: 0; color: var(--ink-2); font-weight: 700; }
.life-head nav { display: flex; gap: 6px; }

/* 一生のリボン：このゲームの顔 */
.ribbon { margin: 14px 0 0; }
.ribbon-track { position: relative; height: 22px; background: #E2DACB; border-radius: 11px; overflow: hidden; }
.ribbon-track i { position: absolute; top: 4px; bottom: 4px; width: 4px; margin-left: -2px; border-radius: 2px; }
.ribbon-track u { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--ink); }
.ribbon-ticks { position: relative; height: 18px; font-size: 11px; color: var(--ink-3); }
.ribbon-ticks em { position: absolute; font-style: normal; transform: translateX(-2px); }

.life-dog { position: relative; width: clamp(120px, 21dvh, 190px); aspect-ratio: 1; margin: 2px auto -4px; }
.life-dog::before { content: ""; position: absolute; inset: 12% 6% 2%; border-radius: 50%; background: var(--season, #EEF2E8); z-index: -1; transition: background .6s; }
.life-dog[data-season="春"] { --season: #F4E8E4; }
.life-dog[data-season="夏"] { --season: #E1ECEE; }
.life-dog[data-season="秋"] { --season: #F1E6D4; }
.life-dog[data-season="冬"] { --season: #E8EBF0; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; background: var(--paper); border-radius: 18px; padding: 12px 16px; }
.meter { display: grid; grid-template-columns: 4.2em 1fr 2em; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.meter i { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--grass) var(--v), #EDE6D8 var(--v)); }
.meter.low i { background: linear-gradient(90deg, #B5473A var(--v), #EDE6D8 var(--v)); }
.meter b { text-align: right; font-weight: 700; color: var(--ink); }
.weight { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; font-size: 13px; color: var(--ink-2); border-top: 1px dashed var(--line); padding-top: 6px; }
.weight b { font-size: 18px; color: var(--ink); }
.weight small { font-size: 12px; margin-left: 2px; }
.weight em { font-style: normal; color: var(--shiba); font-weight: 700; }
.conds { margin: 6px 4px 0; font-size: 13px; color: #B5473A; min-height: 0; }
.conds:empty { display: none; }

.event { background: var(--paper); border-radius: 22px; padding: 18px 18px 20px; margin-top: 12px; }
.ev-head { display: flex; flex-direction: column; gap: 2px; }
.ev-tag { font-size: 12px; font-weight: 700; color: var(--c); display: inline-flex; align-items: center; gap: 6px; }
.ev-tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.ev-head h2 { font: 800 22px/1.4 var(--serif); margin: 0; }
.ev-text { margin: 10px 0 0; }
.choices { display: grid; gap: 8px; margin-top: 16px; }
.choice { text-align: left; border: 1.5px solid var(--line); background: #FBF8F1; border-radius: 14px; padding: 12px 14px; font-weight: 700; cursor: pointer; }
.choice:hover { border-color: var(--ink-2); }
.ev-chose { margin: 14px 0 0; padding-left: 12px; border-left: 3px solid var(--shiba); font-weight: 700; color: var(--ink-2); font-size: 14px; }
.ev-result { margin: 8px 0 0; }
.next { margin-top: 18px; width: 100%; appearance: none; border: 0; border-radius: 14px; background: var(--collar); color: #fff; font-weight: 700; padding: 14px; cursor: pointer; }
.life-foot { text-align: center; margin-top: 10px; }
.life-foot .btn[aria-pressed="true"] { color: var(--collar); }

/* ---------- シート（プロフィール・日記・アルバム） ---------- */
.sheet { border: 0; padding: 0; width: min(480px, 100vw); max-height: 86dvh; margin: auto auto 0; border-radius: 24px 24px 0 0; background: var(--paper); color: var(--ink); }
.sheet::backdrop { background: rgba(40, 32, 26, .45); }
.sheet-body { padding: 22px 20px 8px; overflow: auto; max-height: calc(86dvh - 64px); }
.sheet-body h3 { font: 800 24px/1.3 var(--serif); margin: 0 0 8px; }
.sheet-body h4 { margin: 16px 0 8px; font-size: 15px; color: var(--ink-2); }
.sheet .facts { padding: 0; }
.traits { display: grid; gap: 6px; }
.sheet-close { position: sticky; bottom: 0; display: block; margin: 8px auto 16px; }
.diary { list-style: none; margin: 0; padding: 0; }
.diary li { padding: 12px 0 12px 16px; border-left: 3px solid var(--c); margin-bottom: 4px; }
.diary time { display: block; font-size: 12px; color: var(--ink-3); }
.diary b { font-family: var(--serif); font-size: 17px; }
.diary p { margin: 4px 0 0; font-size: 14px; }
.diary .d-choice { color: var(--ink-2); font-weight: 700; }
.album { list-style: none; margin: 0; padding: 0; }
.album li { display: grid; grid-template-columns: 14px 1fr; column-gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.album .sw { width: 14px; height: 14px; border-radius: 50%; grid-row: span 3; margin-top: 6px; }
.album b { font: 800 18px var(--serif); }
.album span:not(.sw) { color: var(--ink-2); }

/* ---------- 最期 ---------- */
.end { text-align: center; }
.end h1 { font: 800 40px/1.2 var(--serif); margin: 4px 0 0; }
.end-age { margin: 0; font-weight: 700; color: var(--ink-2); }
.end-dog { width: 220px; aspect-ratio: 1; margin: 0 auto; }
.end-text { text-align: left; background: var(--paper); border-radius: 18px; padding: 14px 16px; }
.end-title-wrap { color: var(--ink-2); }
.end-title-wrap b { color: var(--collar); font-size: 20px; }
.end h2 { font: 800 20px var(--serif); margin: 20px 0 6px; }
.mem { list-style: none; padding: 0; margin: 0; text-align: left; background: var(--paper); border-radius: 18px; padding: 6px 16px; }
.mem li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-weight: 700; }
.mem li:last-child { border-bottom: 0; }
.mem time { display: inline-block; width: 7.5em; color: var(--ink-3); font-weight: 500; font-size: 14px; }
.end-stats { font-size: 13px; color: var(--ink-3); }
.card-canvas { width: 100%; height: auto; border-radius: 16px; margin: 8px 0 12px; box-shadow: 0 1px 0 var(--line); }
.share { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.share .btn { padding: 12px 6px; font-size: 14px; }
.end-actions { display: grid; gap: 6px; margin-top: 18px; }

/* ---------- v2：リアルタイム画面 ---------- */
.life-date { margin: 2px 0 0; font-weight: 700; }
.life-age { margin: 0; color: var(--ink-2); font-size: 14px; }
.speed { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 12px; background: #DFE5D8; padding: 4px; border-radius: 12px; }
.speed button { appearance: none; border: 0; background: transparent; border-radius: 9px; padding: 8px 4px; font-weight: 700; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.speed button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 var(--line); }
.dog-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin: 4px 0 6px; }
.dog-row .life-dog { width: clamp(110px, 17dvh, 160px); margin: 0; }
.thought { position: relative; margin: 0; background: var(--paper); border-radius: 18px; padding: 12px 14px; font-family: var(--serif); font-weight: 600; font-size: 15px; line-height: 1.7; }
.thought::before { content: ""; position: absolute; left: -7px; top: 50%; margin-top: -7px; border: 7px solid transparent; border-right-color: var(--paper); border-left: 0; }
.stats { grid-template-columns: 1fr; }
.panel { background: var(--paper); border-radius: 18px; padding: 10px 16px 12px; margin-top: 10px; }
.panel h2 { font-size: 13px; color: var(--ink-3); margin: 0 0 6px; font-weight: 700; }
.family { display: grid; gap: 4px; }
.meter.rel i { background: linear-gradient(90deg, var(--shiba) var(--v), #EDE6D8 var(--v)); }
.meter.rel { grid-template-columns: 6.5em 1fr 2em; }
.pre-fam { margin: 0; font-size: 14px; color: var(--ink-2); }
.weight .cond { color: #B5473A; font-size: 12px; }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.counts div { background: var(--paper); border-radius: 14px; padding: 8px 4px; text-align: center; }
.counts b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.counts span { font-size: 11px; color: var(--ink-3); }
.feed { list-style: none; margin: 0; padding: 0; max-height: 34dvh; overflow: auto; }
.feed li { display: grid; grid-template-columns: 3.2em 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 14px; animation: feed-in .4s ease; }
.feed li time { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.feed li.big span { font-weight: 700; font-family: var(--serif); }
@keyframes feed-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.event-dlg { border: 0; padding: 0; width: min(460px, calc(100vw - 24px)); max-height: 90dvh; border-radius: 24px; background: var(--paper); color: var(--ink); }
.event-dlg::backdrop { background: rgba(40, 32, 26, .5); }
.event-dlg .event { margin: 0; max-height: 90dvh; overflow: auto; }
.ev-when { margin: 0 0 6px; font-size: 12px; color: var(--ink-3); }
.ev-q { margin: 14px 0 0; font-family: var(--serif); font-weight: 600; color: var(--ink-2); }
.ev-q:empty { display: none; }
.hint { font-size: 13px; color: var(--ink-3); margin: 6px 4px 0; }
.title-links { display: flex; gap: 16px; justify-content: center; margin-top: 28px; font-size: 13px; }
.title-links a, .doc a { color: var(--ink-2); }
.end h2 { margin-top: 24px; }

/* ---------- 説明ページ ---------- */
.doc { max-width: 640px; margin: 0 auto; padding: 24px 20px 64px; }
.doc h1 { font: 800 32px/1.3 var(--serif); margin: 8px 0 20px; }
.doc h2 { font: 800 22px/1.4 var(--serif); margin: 36px 0 8px; }
.doc h3 { font-size: 17px; margin: 24px 0 4px; }
.doc p, .doc li { line-height: 1.9; }
.doc-back { margin: 0; font-size: 14px; }
.doc-steps { padding-left: 1.4em; }
.doc-date { color: var(--ink-3); font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ヘッダーのボタンを折り返さない */
.life-head { gap: 8px; }
.life-head nav { display: flex; gap: 6px; flex-shrink: 0; }
.life-head nav .btn { white-space: nowrap; padding: 6px 10px; }
.speed button { white-space: nowrap; font-size: 12px; }
