/* 佛心の種 — スタイル（案B「和紙の帖」・書籍カバーの配色に合わせる）
 * 箱の枠線や影は使わず、余白・罫線・円相・蘇芳色の印で区切る。
 * 見出し＝しっぽり明朝B1、本文＝BIZ UDPゴシック（読みやすさ重視のUD書体）
 */
:root {
  color-scheme: light;
  --sakura: #eed3d4;      /* カバーの桜鼠 */
  --sakura-l: #f7e9e8;
  --washi: #f8f4ee;       /* 帯の生成り */
  --paper: #fffdf9;
  --sumi: #2b2326;
  --sumi2: #66585b;
  --suou: #8f4c66;        /* 蘇芳（カバーの「自分らしさ」） */
  --suou-d: #743a52;
  --suou-l: #f3e2e7;
  --kin: #c3ad82;         /* 帯の蓮の金線 */
  --rule: #e4d7d0;
  --fs: 18px;
  --fs-q: 21px;
  --tap: 56px;
  --mincho: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font: "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
}
html.large { --fs: 21px; --fs-q: 24px; --tap: 62px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sakura); color: var(--sumi); font-family: var(--font); font-size: var(--fs); line-height: 1.8;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; word-break: auto-phrase; line-break: strict;
}
h1, h2, h3, .q-text, .r-catch, .q-theme { text-wrap: balance; }
p, li { text-wrap: pretty; }
#app { height: 100vh; height: 100dvh; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; background: var(--washi); position: relative; overflow: hidden; }

/* ---- 庭（額装した一幅の絵） ---- */
#stage { position: relative; flex: 0 0 auto; height: 32vh; height: 32dvh; min-height: 160px; max-height: 320px; margin: 12px 12px 0;
  box-shadow: 0 0 0 1px var(--kin), 0 0 0 5px var(--washi), 0 0 0 6px var(--kin); transition: height .5s ease; background: #cfe3ee; }
body.result-mode #stage { height: 17vh; height: 17dvh; min-height: 110px; }
body.title-mode #stage { height: 30dvh; }
#garden { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 6px; align-items: center; padding: 6px; }
.spacer { flex: 1; }
.icon-btn { white-space: nowrap; font: 700 14px/1 var(--font); min-height: 44px; min-width: 44px; padding: 0 12px; background: rgba(248, 244, 238, .9); color: var(--sumi); border: 0; border-radius: 2px; cursor: pointer; }
.icon-btn[aria-pressed="true"] { background: var(--paper); color: var(--suou); }

/* ---- 頁 ---- */
#panel { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); background: var(--washi); position: relative; }
#panel:focus, #panel *:focus, [tabindex="-1"]:focus { outline: none !important; }
.btn:focus-visible, .icon-btn:focus-visible, .choice:focus-visible, .chip:focus-visible, .seg-btn:focus-visible, summary:focus-visible, .aff-item:focus-visible, .z-cell:focus-visible { outline: 2px solid var(--suou); outline-offset: 3px; }

h1, h2, h3 { margin: 0; line-height: 1.45; font-family: var(--mincho); font-weight: 800; }
h2 { font-size: 1.35em; margin-bottom: 12px; letter-spacing: .04em; }
h3 { font-size: 1.08em; }
p { margin: 0 0 12px; }
.note { color: var(--sumi2); font-size: .9em; line-height: 1.7; }
.small { font-size: .82em; }
.center { text-align: center; }
.label { font-weight: 700; margin: 14px 0 6px; display: block; }
.err { color: var(--suou-d); font-weight: 700; min-height: 1.2em; }

/* ボタン：塗りは蘇芳、それ以外は細い墨線 */
.btn { font: 700 var(--fs)/1.35 var(--font); min-height: var(--tap); padding: 12px 18px; border: 0; border-radius: 2px; background: transparent; color: var(--sumi);
  box-shadow: inset 0 0 0 1px var(--sumi); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--suou); color: #fff; box-shadow: none; }
.btn.primary:disabled { background: #d9cbc9; color: #8a7d7b; cursor: default; }
.btn.big { min-height: calc(var(--tap) + 6px); font-size: 1.08em; letter-spacing: .08em; }
.btn.danger { color: var(--suou-d); box-shadow: inset 0 0 0 1px var(--suou-d); }
.btn.small-btn { min-height: 46px; font-size: .9em; padding: 8px 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.row { display: flex; gap: 12px; margin-top: 20px; }
.row .btn { flex: 1; }
.row .btn:not(.primary) { flex: 0 0 auto; min-width: 6.5em; }
.nav { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); margin: 22px -20px calc(-20px - env(safe-area-inset-bottom)); padding: 14px 20px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(248,244,238,0), var(--washi) 24%); }

/* タイトル：円相の中に縦書きの題 */
body.title-mode #panel { background: radial-gradient(circle at 50% 150px, #fff 0, var(--sakura-l) 120px, var(--sakura) 260px); }
.title-wrap { text-align: center; }
.kicker { font-family: var(--mincho); font-weight: 800; color: var(--suou); letter-spacing: .12em; margin: 0 0 4px; font-size: 1.05em; }
.enso { position: relative; width: 232px; height: 232px; margin: 10px auto 8px; display: grid; place-items: center; }
.enso::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 16px solid rgba(255,255,255,.95); border-left-color: rgba(255,255,255,.55); transform: rotate(-30deg); }
.logo { position: relative; writing-mode: vertical-rl; white-space: nowrap; font-family: var(--mincho); font-weight: 800; font-size: 44px; letter-spacing: .08em; line-height: 1; color: var(--sumi); }
.lead { text-align: left; margin-top: 8px; }
.meta { font-size: .85em; color: var(--sumi2); }
.book { margin-top: 22px; font-size: .85em; color: var(--sumi2); font-family: var(--mincho); }
.title-wrap .btn:not(.primary) { background: rgba(255,253,249,.6); }

/* こけまるの語り：吹き出しではなく、金線を添えた語り */
.bubble { display: flex; gap: 12px; align-items: flex-start; margin: 2px 0 16px; }
.koke-face { width: 40px; height: 40px; image-rendering: pixelated; flex: 0 0 auto; margin-top: 2px; }
.bubble-body { flex: 1; border-left: 2px solid var(--kin); padding-left: 12px; }
.bubble-name { font-family: var(--mincho); font-weight: 800; font-size: .78em; color: #9a8556; display: block; line-height: 1.4; letter-spacing: .1em; }
.bubble-body p { margin: 0 0 4px; }
.intro .bubble { margin-top: 6px; }

/* 問い */
.q-head { display: grid; grid-template-columns: 1fr auto; column-gap: 14px; align-items: start; margin-bottom: 8px; }
.stones { display: flex; gap: 6px; margin: 2px 0 8px; grid-column: 1; }
.stone { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--sumi2); }
.stone.done { background: var(--sumi2); }
.stone.now { background: var(--suou); box-shadow: none; }
.q-num { grid-column: 2; grid-row: 1 / 3; writing-mode: vertical-rl; margin: 0; font-family: var(--mincho); font-weight: 800; font-size: 15px; letter-spacing: .25em; color: var(--suou); box-shadow: inset 0 0 0 1.5px var(--suou); padding: 8px 4px; line-height: 1.2; }
.q-theme { grid-column: 1; font-size: 1.22em; letter-spacing: .04em; }
.scene-tag { font-family: var(--mincho); font-weight: 600; color: #8c7b6c; margin: 0 0 6px; font-size: .92em; }
.scene-tag::before { content: "― "; }
.q-text { font-family: var(--mincho); font-weight: 800; font-size: var(--fs-q); line-height: 1.65; margin-bottom: 14px; }

.choices { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.choice { font: 400 var(--fs)/1.55 var(--font); text-align: left; min-height: var(--tap); padding: 14px 6px; display: flex; gap: 14px; align-items: center;
  background: none; color: var(--sumi); border: 0; border-bottom: 1px solid var(--rule); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.choice .dot { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px #a08f8a; }
.choice[aria-checked="true"] { background: linear-gradient(90deg, var(--suou-l), rgba(243,226,231,0)); font-weight: 700; }
.choice[aria-checked="true"] .dot { background: var(--suou); box-shadow: inset 0 0 0 4px var(--suou-l), 0 0 0 1.5px var(--suou); }
.skips { display: flex; gap: 8px 20px; margin-top: 14px; flex-wrap: wrap; }
.chip { font: 400 .92em/1.3 var(--font); min-height: 46px; padding: 8px 2px; background: none; color: var(--sumi2); border: 0; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: #c9bbb6; cursor: pointer; }
.chip[aria-pressed="true"] { color: var(--suou); text-decoration-color: var(--suou); font-weight: 700; }
.chip[aria-pressed="true"]::before { content: "● "; font-size: .7em; vertical-align: 2px; }

.free { margin-top: 14px; border-top: 1px dashed var(--rule); padding: 4px 0; }
.free summary { cursor: pointer; min-height: 46px; display: flex; align-items: center; color: var(--suou); font-weight: 700; }
.free textarea, input[type="text"] { width: 100%; font: 400 18px/1.6 var(--font); padding: 10px 12px; border: 0; box-shadow: inset 0 0 0 1px #b9aaa5; background: var(--paper); color: var(--sumi); border-radius: 2px; resize: vertical; }
.free textarea:focus, input[type="text"]:focus { outline: 2px solid var(--suou); outline-offset: 1px; }
.count { font-variant-numeric: tabular-nums; }

/* 設定 */
.setting { border-top: 1px solid var(--rule); padding: 14px 0 6px; }
.setting h3 { margin-bottom: 4px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px; }
.seg-btn { flex: 1 1 6em; font: 700 .95em/1.3 var(--font); min-height: 50px; padding: 8px 10px; background: none; color: var(--sumi); border: 0; border-radius: 2px; box-shadow: inset 0 0 0 1px #b9aaa5; cursor: pointer; }
.seg-btn[aria-checked="true"] { background: var(--suou); color: #fff; box-shadow: none; }
.setting .btn { width: 100%; margin-bottom: 12px; }

/* 振り返り */
.reflect { list-style: none; padding: 0; margin: 0 0 14px; border-top: 1px solid var(--rule); }
.reflect li { padding: 10px 0; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; }
.r-theme { font-size: .78em; color: var(--sumi2); line-height: 1.45; }
.r-ans { font-weight: 700; }
.r-text { color: var(--suou); }
.powers { background: var(--paper); padding: 8px 16px 14px; box-shadow: inset 0 0 0 1px var(--kin); }
.power { display: flex; flex-direction: column; margin-top: 6px; }
.power strong { font-family: var(--mincho); color: var(--suou); font-size: 1.12em; }
.power span { font-size: .92em; }

/* 結果 */
.result { padding-bottom: 8px; }
.r-kicker { text-align: center; font-family: var(--mincho); font-weight: 800; color: var(--suou); margin: 0 0 6px; letter-spacing: .12em; }
.card-frame { display: flex; justify-content: center; margin-bottom: 6px; }
.plant-card { image-rendering: pixelated; max-width: 100%; height: auto !important; }
.r-name { text-align: center; font-size: 2.4em; letter-spacing: .14em; line-height: 1.3; }
.r-name small { display: block; font-family: var(--font); font-size: .34em; letter-spacing: .25em; color: var(--sumi2); font-weight: 400; }
.r-catch { text-align: center; font-family: var(--mincho); font-weight: 800; color: var(--suou); font-size: 1.08em; }
.r-sec { border-top: 1px solid var(--rule); padding: 16px 0 4px; margin-top: 14px; }
.r-sec h3 { color: var(--suou); margin-bottom: 8px; letter-spacing: .06em; }
.r-sec ul { margin: 0 0 10px; padding-left: 1.2em; }
.r-sec li { margin-bottom: 4px; }
.why summary { cursor: pointer; color: var(--suou); font-weight: 700; min-height: 42px; }
.why ul { font-size: .92em; }
.hl { font-weight: 700; background: linear-gradient(transparent 62%, var(--suou-l) 62%); display: inline; }
.step { font-family: var(--mincho); font-weight: 800; font-size: 1.1em; }
.words { list-style: none; padding: 0 !important; }
.words li { display: flex; flex-direction: column; border-left: 2px solid var(--kin); padding-left: 12px; margin-bottom: 10px; }
.disclaimer { margin-top: 20px; font-size: .85em; color: var(--sumi2); border-top: 1px solid var(--rule); padding-top: 12px; }

/* 購入者特典（帯のような生成りの欄） */
.deep { margin-top: 22px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--kin); padding: 18px 18px 10px; }
.deep .deep-tag { font-family: var(--mincho); font-weight: 800; color: #9a8556; letter-spacing: .12em; font-size: .85em; margin-bottom: 2px; }
.deep h3 { color: var(--sumi); font-size: 1.2em; margin-bottom: 8px; }
.deep h4 { font-family: var(--mincho); font-weight: 800; color: var(--suou); margin: 14px 0 4px; font-size: 1em; }
.deep .ask { margin-top: 10px; }
.deep .ask label { display: block; font-weight: 700; margin-bottom: 6px; line-height: 1.6; }
.deep textarea { width: 100%; font: 400 18px/1.6 var(--font); padding: 10px 12px; border: 0; box-shadow: inset 0 0 0 1px #b9aaa5; background: #fff; border-radius: 2px; resize: vertical; }
.deep .unlock { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.deep .unlock input { flex: 1 1 10em; }

/* 図鑑・履歴 */
.zukan { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.z-cell { background: none; border: 0; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 10px 4px 6px; display: flex; flex-direction: column; align-items: center; font: 700 .9em/1.4 var(--mincho); color: var(--sumi); cursor: pointer; min-height: 124px; }
.z-cell small { font: 400 15px/1.3 var(--font); color: var(--sumi2); }
.z-img { width: 84px; height: 96px; image-rendering: pixelated; }
.hist { list-style: none; padding: 0; border-top: 1px solid var(--rule); }
.hist-btn { width: 100%; min-height: var(--tap); display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; font: 400 var(--fs)/1.4 var(--font); background: none; border: 0; border-bottom: 1px solid var(--rule); color: var(--sumi); cursor: pointer; }
.hist-btn strong { font-family: var(--mincho); }

/* 相性 */
.aff { display: flex; flex-direction: column; margin-bottom: 10px; }
.aff-item { display: flex; gap: 12px; align-items: flex-start; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--rule); padding: 12px 0; font: inherit; color: var(--sumi); cursor: pointer; }
.aff-item:last-child { border-bottom: 0; }
.aff-img { width: 56px; height: 64px; image-rendering: pixelated; flex: 0 0 auto; background: var(--sakura-l); border-radius: 50%; }
.aff-body { display: flex; flex-direction: column; min-width: 0; }
.aff-kind { font-size: .8em; color: var(--suou); font-weight: 700; line-height: 1.4; }
.aff-body strong { font-family: var(--mincho); font-size: 1.12em; }
.aff-text { font-size: .92em; line-height: 1.7; }
.aff-mini { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 4px; }
.aff-mini .aff-kind { display: inline-block; min-width: 5em; margin-right: 8px; }

/* 佛性とは何か？ */
.about-page { text-align: center; }
.about-page h2 { font-size: 1.5em; margin: 4px 0 6px; }
.about-enso { position: relative; width: 120px; height: 120px; margin: 6px auto 10px; display: grid; place-items: center; }
.about-enso::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 9px solid #fff; border-left-color: rgba(255,255,255,.5); transform: rotate(-30deg); }
.about-enso img { position: relative; width: 40px; height: 48px; image-rendering: pixelated; }
.about-body { word-break: normal; text-wrap: wrap; text-align: justify; margin: 14px 0 0; font-family: var(--mincho); font-weight: 600; font-size: 1.08em; line-height: 2.05; letter-spacing: .02em; }
.about-body em { font-style: normal; color: var(--suou); font-weight: 800; }

/* モーダル */
dialog#modal { border: 0; padding: 0; width: min(92vw, 560px); max-height: 88dvh; background: var(--washi); color: var(--sumi); box-shadow: 0 0 0 1px var(--kin), 0 20px 50px rgba(43,35,38,.35); }
dialog#modal::backdrop { background: rgba(43, 35, 38, .5); }
.sheet { padding: 22px 20px; overflow-y: auto; max-height: 86dvh; }
.about-head { margin: -22px -20px 0; padding: 22px 20px 16px; background: radial-gradient(circle at 50% 80px, #fff 0, var(--sakura-l) 60px, var(--sakura) 150px); }
.sheet > .btn { width: 100%; margin-top: 16px; }
.share-img { width: 100%; margin: 8px 0; box-shadow: 0 0 0 1px var(--rule); }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--sumi); color: #fff; padding: 12px 18px; font-size: 16px; border-radius: 2px; opacity: 0; pointer-events: none; transition: .3s; max-width: 90vw; z-index: 50; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) { #panel { padding-left: 16px; padding-right: 16px; } .nav { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; } .icon-btn { padding: 0 9px; } .logo { font-size: 40px; } .enso { width: 210px; height: 210px; } }
@media (max-height: 640px) { #stage { height: 26dvh; min-height: 140px; } body.title-mode #stage { height: 22dvh; } .enso { width: 190px; height: 190px; } .logo { font-size: 36px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* シェア */
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.share-grid > :nth-child(n+4) { grid-column: 1 / -1; }
.btn.share { color: #fff; box-shadow: none; font-size: .95em; padding: 10px 6px; }
.btn.share.line { background: #06a74a; }
.btn.share.x { background: #1f1a1c; }
.btn.share.fb { background: #1a63d6; }
.from-friend { font-family: var(--mincho); font-weight: 800; color: var(--suou); background: rgba(255,253,249,.7); padding: 10px 12px; margin: 4px 0 0; }
