/* ============================================================
   暖簾を継ぐ日 — 大江戸商継記
   モバイル一画面UI (基準 390×844 / 最小320)
   ============================================================ */
:root {
  --w: #f2ead8;          /* 和紙 */
  --w2: #e6dbc2;         /* 和紙・濃 */
  --w3: #fbf6ea;         /* 和紙・淡 */
  --ink: #211c16;        /* 墨 */
  --ink2: #574d40;       /* 墨・淡 */
  --ai: #22486e;         /* 藍 */
  --ai2: #16324f;
  --shu: #b4433a;        /* 朱 */
  --shu2: #8f302a;
  --gold: #c79a3c;
  --green: #4e6b45;
  --line: rgba(33,28,22,.16);
  --line2: rgba(33,28,22,.34);
  --mincho: "Shippori Mincho B1","Hiragino Mincho ProN","Yu Mincho",serif;
  --gothic: "Zen Kaku Gothic New","Hiragino Kaku Gothic ProN","Yu Gothic",sans-serif;
  --bar-h: 58px;
  --tab-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  font-family: var(--gothic);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  background: #16120e;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- 端末枠 ---------- */
#app {
  /* 親の高さに依存させない。
     配布先（Artifact など）が本文をひとつ包むと、その包みの高さは auto になり、
     height:100% が 0 に潰れて**何も表示されなくなる**。
     画面そのものに貼り付けることで、どこへ置かれても崩れない。 */
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 460px;
  height: 100vh;
  height: 100dvh;          /* 携帯のブラウザ枠を除いた実寸。効かない環境は上の 100vh に落ちる */
  margin-inline: auto;
  background: var(--w);
  background-image:
    radial-gradient(rgba(33,28,22,.030) 1px, transparent 1px),
    radial-gradient(rgba(33,28,22,.022) 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 5px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0,0,0,.5);
}

/* ============================================================
   1. 表紙（タイトル）
   ============================================================ */
#screen-title {
  position: absolute; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 2.2rem) 1.4rem calc(env(safe-area-inset-bottom) + 1.4rem);
  background:
    linear-gradient(180deg, rgba(20,26,34,.86) 0%, rgba(24,20,16,.80) 55%, rgba(24,20,16,.94) 100%),
    linear-gradient(160deg, #2a3a4c 0%, #4a4234 60%, #241d17 100%);
  color: var(--w);
  overflow-y: auto;
}
#screen-title[hidden], .scr[hidden] { display: none !important; }
.title-mark {
  align-self: center;
  font-family: var(--mincho); font-weight: 700;
  writing-mode: vertical-rl;
  font-size: clamp(2.1rem, 9vw, 2.9rem);
  letter-spacing: .28em; line-height: 1.35;
  text-shadow: 0 2px 18px rgba(0,0,0,.6);
  margin-bottom: 1rem; max-height: 8.4em;
}
.title-mark .accent { color: #e2a24c; }
.title-sub {
  text-align: center; font-family: var(--mincho);
  font-size: .92rem; letter-spacing: .3em; color: rgba(242,234,216,.75);
  margin-bottom: .3rem;
}
.title-year {
  text-align: center; font-size: .74rem; letter-spacing: .18em;
  color: rgba(242,234,216,.55); margin-bottom: 1.6rem;
}
.title-menu { display: flex; flex-direction: column; gap: .7rem; margin-top: auto; }
.tbtn {
  min-height: 52px;
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  font-family: var(--mincho); font-size: 1.06rem; letter-spacing: .18em;
  background: rgba(242,234,216,.10);
  border: 1px solid rgba(242,234,216,.34);
  border-radius: 8px; color: var(--w);
  backdrop-filter: blur(3px);
  transition: background .15s, transform .15s;
}
.tbtn:active { transform: translateY(2px); }
.tbtn.primary { background: var(--shu); border-color: var(--shu); box-shadow: 0 3px 0 var(--shu2); }
.tbtn.primary:active { box-shadow: 0 1px 0 var(--shu2); }
.tbtn:disabled { opacity: .35; }
.tbtn small { font-family: var(--gothic); font-size: .68rem; letter-spacing: .06em; opacity: .75; }
.title-foot { text-align: center; font-size: .64rem; color: rgba(242,234,216,.45); margin-top: 1.1rem; line-height: 1.8; }
.title-foot a { color: rgba(242,234,216,.7); }

/* ============================================================
   2. 汎用シート（新規作成・セーブ・遊び方）
   ============================================================ */
.scr {
  position: absolute; inset: 0; z-index: 70;
  background: var(--w); display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + .9rem) 1.1rem calc(env(safe-area-inset-bottom) + 1rem);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.scr h2 {
  font-family: var(--mincho); font-size: 1.24rem; letter-spacing: .16em;
  padding-bottom: .6rem; margin-bottom: .9rem; border-bottom: 2px solid var(--ink);
  display: flex; justify-content: space-between; align-items: center;
}
.scr .close {
  font-size: .78rem; letter-spacing: .12em; border: 1px solid var(--line2);
  border-radius: 6px; padding: .35rem .8rem; min-height: 36px;
}
.field { margin-bottom: 1.1rem; }
.field > label { display: block; font-size: .78rem; letter-spacing: .14em; color: var(--ink2); margin-bottom: .4rem; }
.field input[type=text] {
  width: 100%; min-height: 48px; font-size: 1.05rem; font-family: var(--mincho);
  padding: .5rem .8rem; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--w3); color: var(--ink);
}
.opt-row { display: grid; gap: .5rem; }
.opt {
  text-align: left; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--w3); padding: .7rem .9rem; min-height: 52px;
  transition: border-color .15s, background .15s;
}
.opt[aria-pressed="true"] { border-color: var(--shu); background: #fbf0e6; box-shadow: inset 0 0 0 1px var(--shu); }
.opt b { font-family: var(--mincho); font-size: .98rem; letter-spacing: .06em; display: block; }
.opt span { font-size: .74rem; color: var(--ink2); line-height: 1.65; }

/* セーブスロット */
.slot {
  width: 100%; text-align: left; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--w3); padding: .8rem .9rem; margin-bottom: .6rem; min-height: 76px;
}
.slot.empty { border-style: dashed; color: var(--ink2); }
.slot .s-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.slot .s-name { font-family: var(--mincho); font-size: 1.02rem; letter-spacing: .06em; }
.slot .s-date { font-size: .72rem; color: var(--ink2); font-variant-numeric: tabular-nums; }
.slot .s-meta { font-size: .74rem; color: var(--ink2); margin-top: .3rem; font-variant-numeric: tabular-nums; }
.slot-actions { display: flex; gap: .4rem; margin-top: .5rem; }
.slot-actions button {
  flex: 1; min-height: 40px; font-size: .8rem; letter-spacing: .1em;
  border: 1px solid var(--line2); border-radius: 6px; background: var(--w);
}
.slot-actions .danger { color: var(--shu2); border-color: rgba(180,67,58,.5); }

/* ============================================================
   3. 遊技画面
   ============================================================ */
#screen-game { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* 上部状況帯 */
#statusbar {
  flex: none; background: var(--ink); color: var(--w);
  padding: calc(env(safe-area-inset-top) + .4rem) .7rem .4rem;
}
.sb-r1 { display: flex; align-items: baseline; gap: .5rem; font-size: .74rem; }
.sb-date { font-family: var(--mincho); font-size: .95rem; letter-spacing: .04em; }
.sb-koku { color: var(--gold); font-family: var(--mincho); }
.sb-wx { margin-left: auto; font-size: .78rem; }
.sb-r2 { display: flex; align-items: center; gap: .8rem; margin-top: .2rem; font-size: .72rem; }
.sb-r2 b { font-family: var(--mincho); font-size: .98rem; color: var(--gold); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.sb-warn {
  margin-left: auto; background: var(--shu); color: #fff; border-radius: 999px;
  font-size: .68rem; padding: .1rem .55rem; letter-spacing: .06em;
}
.sb-warn[hidden] { display: none; }

/* 中央 */
#view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 5.5rem; }
.pane { padding: .8rem .8rem 0; }
.pane[hidden] { display: none; }

.card {
  background: var(--w3); border: 1px solid var(--line); border-radius: 10px;
  padding: .85rem .9rem; margin-bottom: .7rem;
}
.card > h3 {
  font-family: var(--mincho); font-size: .95rem; letter-spacing: .14em;
  margin-bottom: .55rem; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
}
.card > h3 .hint { font-family: var(--gothic); font-size: .66rem; font-weight: 400; color: var(--ink2); letter-spacing: .02em; }
.muted { font-size: .76rem; color: var(--ink2); line-height: 1.8; }

/* 町canvas */
#town-wrap { position: relative; margin: 0 .8rem .7rem; border-radius: 10px; overflow: hidden; border: 1px solid var(--line2); }
#town { display: block; width: 100%; height: auto; image-rendering: pixelated; background: #9fb8c4; cursor: pointer; }
.deco-shop { display: flex; gap: .4rem; flex-wrap: wrap; }
.deco-btn {
  flex: 1 1 auto; min-width: 88px; min-height: 56px; text-align: left;
  border: 1px solid var(--line2); border-radius: 7px; background: var(--w3);
  padding: .45rem .6rem; font-size: .7rem; line-height: 1.5;
}
.deco-btn b { display: block; font-family: var(--mincho); font-size: .88rem; letter-spacing: .04em; }
.deco-btn i { font-style: normal; color: var(--karashi); font-size: .7rem; }
.deco-btn span { display: block; color: var(--ink2); font-size: .64rem; margin-top: .1rem; }
.deco-btn[aria-pressed="true"] { border-color: var(--shu); background: #fbf0e6; box-shadow: inset 0 0 0 1px var(--shu); }
.deco-btn:disabled { opacity: .4; }
.town-tag {
  position: absolute; right: .5rem; top: .5rem;
  background: rgba(33,28,22,.72); color: var(--w); font-size: .66rem;
  padding: .18rem .5rem; border-radius: 4px; letter-spacing: .08em;
}

/* 行動ボタン列 */
.act-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.act {
  min-height: 62px; text-align: left; border: 1px solid var(--line2); border-radius: 9px;
  background: var(--w3); padding: .55rem .7rem;
}
.act:disabled { opacity: .42; }
.act b { display: block; font-family: var(--mincho); font-size: .92rem; letter-spacing: .06em; }
.act span { font-size: .68rem; color: var(--ink2); line-height: 1.55; }
.act.accent { background: var(--ai); border-color: var(--ai); color: var(--w); }
.act.accent span { color: rgba(242,234,216,.8); }

/* 相場行 */
.mkt { width: 100%; border-collapse: collapse; font-size: .8rem; }
.mkt th { font-size: .64rem; letter-spacing: .1em; color: var(--ink2); text-align: left; padding: .25rem .3rem; border-bottom: 1px solid var(--line2); font-weight: 400; }
.mkt td { padding: .45rem .3rem; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; vertical-align: middle; }
.mkt .g-n { font-family: var(--mincho); font-size: .88rem; white-space: nowrap; }
.mkt .g-n i { font-style: normal; font-size: .62rem; color: var(--ink2); display: block; letter-spacing: .04em; }
.up { color: var(--shu2); } .down { color: var(--ai); }
.mkt .tbtn2 { border: 1px solid var(--line2); border-radius: 5px; min-width: 40px; min-height: 36px; font-size: .76rem; background: var(--w); }
.mkt .tbtn2.buy { background: var(--ai); color: var(--w); border-color: var(--ai); }
.mkt .tbtn2.sell { color: var(--shu2); border-color: rgba(180,67,58,.5); }
.mkt .tbtn2:disabled { opacity: .3; }

.qty-bar { display: flex; align-items: center; gap: .4rem; margin-bottom: .6rem; font-size: .76rem; flex-wrap: wrap; }
.qty-bar button { min-width: 44px; min-height: 40px; border: 1px solid var(--line2); border-radius: 6px; background: var(--w); font-size: .8rem; }
.qty-bar button[aria-pressed="true"] { background: var(--ink); color: var(--w); border-color: var(--ink); }

/* 帳面 */
.ledger { width: 100%; font-size: .82rem; border-collapse: collapse; }
.ledger td { padding: .4rem .2rem; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.ledger td:last-child { text-align: right; font-family: var(--mincho); }
.gauge { height: 7px; background: var(--w2); border-radius: 4px; overflow: hidden; margin-top: .3rem; }
.gauge i { display: block; height: 100%; border-radius: 4px; background: var(--ai); transition: width .4s; }
.gauge.g-shu i { background: var(--shu); }
.gauge.g-green i { background: var(--green); }
.g-row { margin-bottom: .6rem; }
.g-row .g-lab { display: flex; justify-content: space-between; font-size: .76rem; }
.g-row .g-lab b { font-family: var(--mincho); font-variant-numeric: tabular-nums; }

/* 人々 */
.person { display: flex; gap: .65rem; padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.face {
  flex: none; width: 44px; height: 44px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mincho); font-size: 1.15rem; color: var(--w);
}
.person .p-b { flex: 1; min-width: 0; }
.person .p-n { font-family: var(--mincho); font-size: .95rem; letter-spacing: .04em; }
.person .p-r { font-size: .68rem; color: var(--ink2); }
.person .p-bars { display: flex; gap: .5rem; margin-top: .25rem; font-size: .64rem; color: var(--ink2); }
.person .p-bars span { display: flex; align-items: center; gap: .2rem; }
.dot { width: 32px; height: 5px; border-radius: 3px; background: var(--w2); overflow: hidden; }
.dot i { display: block; height: 100%; background: var(--ai); }

/* 物語 */
.chapter-head { font-family: var(--mincho); font-size: 1.1rem; letter-spacing: .1em; margin-bottom: .3rem; }
.hist-note {
  border-left: 3px solid var(--ai); background: #eef2f6; padding: .5rem .7rem;
  font-size: .74rem; line-height: 1.8; border-radius: 0 6px 6px 0; margin-top: .5rem;
}
.hist-note b { color: var(--ai2); font-family: var(--mincho); }
.timeline-item { display: flex; gap: .6rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); font-size: .8rem; }
.timeline-item .t-d { flex: none; width: 5.2em; font-family: var(--mincho); font-size: .72rem; color: var(--gold); }

/* 通知箱 */
.notice { display: flex; gap: .5rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); font-size: .78rem; line-height: 1.7; }
.notice .n-k { flex: none; font-size: .62rem; letter-spacing: .08em; padding: .1rem .4rem; border-radius: 4px; height: fit-content; margin-top: .2rem; }
.n-k.info { background: var(--w2); color: var(--ink2); }
.n-k.good { background: #dfe9df; color: var(--green); }
.n-k.bad { background: #f4e0dd; color: var(--shu2); }
.n-k.hist { background: #e3ebf2; color: var(--ai2); }

/* 下部タブ */
#tabs {
  flex: none; display: flex; background: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid rgba(242,234,216,.15);
}
#tabs button {
  flex: 1; min-height: var(--tab-h); color: rgba(242,234,216,.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  font-family: var(--mincho); font-size: .9rem; letter-spacing: .1em;
  border-top: 3px solid transparent;
}
#tabs button .ti { font-size: 1.02rem; line-height: 1; }
#tabs button[aria-selected="true"] { color: var(--w); border-top-color: var(--shu); background: rgba(242,234,216,.06); }
#tabs button .badge {
  position: absolute; transform: translate(16px,-14px);
  background: var(--shu); color: #fff; font-family: var(--gothic);
  font-size: .58rem; min-width: 15px; height: 15px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* 状況行動ボタン（右下フロート） */
#fab {
  position: absolute; right: .8rem;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + .7rem);
  z-index: 20;
  min-height: 52px; padding: 0 1.2rem; border-radius: 26px;
  background: var(--shu); color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  font-family: var(--mincho); font-size: 1rem; letter-spacing: .12em;
  display: flex; align-items: center; gap: .4rem;
}
#fab:active { transform: translateY(2px); }
#fab.wait { background: var(--ai); }

/* ============================================================
   4. 物語モーダル（会話）
   ============================================================ */
#story {
  position: absolute; inset: 0; z-index: 80;
  background: rgba(18,15,12,.55);
  display: flex; flex-direction: column; justify-content: flex-end;
}
#story[hidden] { display: none; }
.story-art {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
}
#story-canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.story-box {
  flex: none; background: var(--w3); border-top: 3px solid var(--ink);
  padding: .9rem .95rem calc(env(safe-area-inset-bottom) + .9rem);
  max-height: 74%; overflow-y: auto;
}
.story-who {
  display: inline-block; font-family: var(--mincho); font-size: .82rem; letter-spacing: .14em;
  background: var(--ink); color: var(--w); padding: .15rem .7rem; border-radius: 4px; margin-bottom: .5rem;
}
.story-text { font-size: .95rem; line-height: 2; margin-bottom: .8rem; }
.story-text em { font-style: normal; color: var(--shu2); font-weight: 700; }
.choices { display: grid; gap: .5rem; }
.choice {
  text-align: left; min-height: 54px; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--w); padding: .6rem .8rem;
}
.choice:active { background: var(--w2); }
.choice b { display: block; font-family: var(--mincho); font-size: .95rem; letter-spacing: .04em; }
.choice span { font-size: .7rem; color: var(--ink2); line-height: 1.6; }
.choice .cost { color: var(--shu2); }
.story-next {
  width: 100%; min-height: 50px; border-radius: 8px; background: var(--ink); color: var(--w);
  font-family: var(--mincho); font-size: .95rem; letter-spacing: .2em;
}

/* ============================================================
   5. トースト / 結末
   ============================================================ */
#toasts {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 4.4rem);
  z-index: 90; display: flex; flex-direction: column; gap: .35rem; align-items: center;
  width: max-content; max-width: 92%; pointer-events: none;
}
.toast {
  background: rgba(33,28,22,.92); color: var(--w);
  font-family: var(--mincho); font-size: .85rem; letter-spacing: .04em;
  padding: .45rem .95rem; border-radius: 20px; animation: tin 2.6s forwards;
  font-variant-numeric: tabular-nums; text-align: center;
}
.toast.good { background: rgba(46,74,52,.94); }
.toast.bad { background: rgba(143,48,42,.94); }
@keyframes tin { 0%{opacity:0;transform:translateY(8px)} 10%,78%{opacity:1;transform:none} 100%{opacity:0;transform:translateY(-6px)} }

#ending {
  position: absolute; inset: 0; z-index: 95; overflow-y: auto;
  background: linear-gradient(180deg,#1c1712 0%,#2a2318 100%); color: var(--w);
  padding: calc(env(safe-area-inset-top) + 2rem) 1.2rem calc(env(safe-area-inset-bottom) + 1.4rem);
}
#ending[hidden] { display: none; }
.end-title {
  font-family: var(--mincho); font-size: 1.5rem; letter-spacing: .2em;
  text-align: center; color: var(--gold); margin-bottom: .3rem;
}
.end-sub { text-align: center; font-size: .74rem; letter-spacing: .16em; color: rgba(242,234,216,.6); margin-bottom: 1.4rem; }
.end-mod {
  border: 1px solid rgba(242,234,216,.22); border-radius: 9px;
  padding: .8rem .9rem; margin-bottom: .7rem; background: rgba(242,234,216,.05);
}
.end-mod h4 { font-family: var(--mincho); font-size: .78rem; letter-spacing: .2em; color: var(--gold); margin-bottom: .35rem; }
.end-mod p { font-size: .86rem; line-height: 1.95; }
.end-axes { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .9rem; margin: 1rem 0; font-size: .74rem; }
.end-axes .ax { }
.end-axes .ax .g-lab { display: flex; justify-content: space-between; }
.end-axes .gauge { background: rgba(242,234,216,.15); }

@media (max-height: 700px) {
  .story-text { font-size: .9rem; line-height: 1.85; }
  .title-mark { font-size: 2rem; max-height: 7em; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 語り手の顔 ---------- */
.story-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .35rem; }
.story-face {
  width: 44px; height: 44px; flex: 0 0 44px;
  image-rendering: pixelated;
  border-radius: 50%;
  border: 2px solid rgba(233,222,200,.35);
  background: rgba(24,20,16,.55);
}

/* ---------- 開始時の選択（立場→生まれ→難易度→名） ---------- */
.step-lead { margin-bottom: .9rem; line-height: 1.85; }
.pick { display: grid; gap: .6rem; }
.pick-card {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--line2); border-radius: 10px;
  background: var(--w3); padding: .8rem .9rem;
  min-height: 44px; position: relative;
}
.pick-card[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset; }
.pick-card .pc-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .3rem; }
.pick-card .pc-seal {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mincho); font-weight: 700; font-size: .95rem; color: #fff;
}
.pick-card .pc-name { font-family: var(--mincho); font-weight: 700; font-size: 1.05rem; letter-spacing: .06em; }
.pick-card .pc-lead { font-size: .74rem; color: var(--ink3); letter-spacing: .1em; margin-left: auto; }
.pick-card .pc-desc { font-size: .82rem; line-height: 1.8; color: var(--ink2); }
.pick-card .pc-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.pick-card .pc-chip {
  font-size: .7rem; padding: .12rem .5rem; border-radius: 999px;
  background: rgba(34,28,22,.07); color: var(--ink2);
}
.step-nav { display: flex; gap: .6rem; margin-top: auto; padding-top: .9rem; }
.step-nav .tbtn { flex: 1; }
.preset { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.preset button {
  min-height: 40px; padding: 0 .8rem; border: 1px solid var(--line2);
  border-radius: 6px; background: var(--w3); font-family: var(--mincho);
}

/* ---------- 場所と行動 ---------- */
.place-head { margin-bottom: .7rem; }
.place-name { display: flex; align-items: baseline; gap: .5rem; }
.place-name b { font-family: var(--mincho); font-size: 1.25rem; letter-spacing: .1em; }
.hands { font-size: .74rem; color: var(--ink3); letter-spacing: .08em; margin-left: auto; }
.hands b { color: var(--shu2); font-size: .95rem; }
.sec-h {
  font-family: var(--mincho); font-size: .8rem; letter-spacing: .16em;
  color: var(--ink3); margin: .9rem 0 .45rem;
  border-bottom: 1px solid var(--line); padding-bottom: .2rem;
}
.acts, .goes { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .45rem; }
.act, .go {
  min-height: 52px; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--w3); padding: .45rem .5rem; text-align: left;
  display: flex; flex-direction: column; justify-content: center; gap: .12rem;
}
.act:disabled, .go:disabled { opacity: .42; }
.act .a-n, .go .g-n { font-family: var(--mincho); font-size: .92rem; letter-spacing: .04em; }
.act .a-c, .go .g-c { font-size: .68rem; color: var(--ink3); }
.go { background: #eef1f5; border-color: rgba(34,72,110,.24); }
/* 畑の区画 */
.plots { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-bottom: .5rem; }
.plot {
  aspect-ratio: 1; border: 1px solid var(--line2); border-radius: 7px;
  background: #cbbe98; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .1rem; font-size: .7rem;
  padding: .2rem;
}
.plot.tilled { background: #a98f68; }
.plot.grown  { background: #8faa63; }
.plot.ready  { background: #cfa93a; box-shadow: 0 0 0 2px var(--shu) inset; }
.plot.ruin   { background: #9a8172; }
.plot b { font-family: var(--mincho); font-size: .88rem; }
.plot small { font-size: .62rem; color: rgba(34,28,22,.7); }
/* 台所・蔵の品 */
.stock { display: grid; gap: .35rem; margin-bottom: .5rem; }
.stock-row {
  display: flex; align-items: center; gap: .5rem;
  border: 1px solid var(--line); border-radius: 7px; background: var(--w3); padding: .4rem .55rem;
}
.stock-row .s-n { font-family: var(--mincho); font-size: .9rem; }
.stock-row .s-q { font-size: .78rem; color: var(--ink3); }
.stock-row .s-b { margin-left: auto; display: flex; gap: .3rem; }
.stock-row button {
  min-height: 36px; padding: 0 .6rem; border: 1px solid var(--line2);
  border-radius: 6px; background: var(--w); font-size: .78rem;
}

/* ---------- 人との関わり ---------- */
.deals { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.deals .deal {
  min-height: 40px; padding: .2rem .55rem;
  border: 1px solid var(--line2); border-radius: 6px; background: var(--w3);
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.3;
}
.deals .deal b { font-family: var(--mincho); font-size: .82rem; font-weight: 600; }
.deals .deal i { font-style: normal; font-size: .64rem; color: var(--ink3); }
.deals .deal:disabled { opacity: .4; }

/* ---------- 鉢の金魚（あと何度倒れられるか） ---------- */
/* 状況帯の三段目。手数と金魚だけを置き、上段の銭勘定と混ぜない。
   五つ並べると縦長の端末で折り返して読めなくなる。 */
.sb-r3 {
  display: flex; align-items: center; gap: .7rem;
  margin-top: .18rem; font-size: .72rem; white-space: nowrap;
}
.sb-r3 b {
  font-family: var(--mincho); font-size: .92rem; color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.sb-hands-w { flex: 0 0 auto; }
.sb-kingyo { display: inline-flex; align-items: center; gap: .35rem; flex: 0 1 auto; min-width: 0; }
.sb-kingyo canvas {
  height: 15px; width: auto; max-width: 46vw;
  image-rendering: pixelated; vertical-align: middle;
}
.sb-kingyo b { font-size: .8rem; color: rgba(242,234,216,.8); }
.sb-r3 .sb-warn { margin-left: auto; }

/* ============================================================
   人物帳 — 和紙の二枚組
   いただいた意匠（ロマサガの能力値画面を江戸に翻案したもの）に倣い、
   左に家の者、右にその詳細を、和紙の見開きとして置く。
   ============================================================ */
.hito-switch { display: flex; gap: .4rem; margin-bottom: .7rem; }
.hito-switch button {
  flex: 1; min-height: 40px; border: 1px solid var(--line2);
  border-radius: 7px; background: var(--w3);
  font-family: var(--mincho); font-size: .92rem; letter-spacing: .1em;
}
.hito-switch button[aria-selected="true"] {
  background: var(--ink); color: var(--w); border-color: var(--ink);
}

.sheet { display: grid; gap: .55rem; }
.sheet-l, .sheet-r {
  background:
    /* 和紙の繊維感。細かな点を二層重ねる */
    radial-gradient(rgba(90,72,48,.045) 1px, transparent 1px) 0 0/7px 7px,
    radial-gradient(rgba(90,72,48,.03) 1px, transparent 1px) 3px 5px/11px 11px,
    linear-gradient(180deg, #efe6d0, #e6dcc2);
  border: 1px solid rgba(122,96,58,.4);
  border-radius: 4px;
  padding: .6rem .65rem;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,250,238,.5), 0 1px 3px rgba(34,28,22,.12);
}
/* 見開きの縁を金で締める */
.sheet-l::before, .sheet-r::before {
  content: ''; position: absolute; inset: 3px;
  border: 1px solid rgba(168,132,44,.34); border-radius: 2px; pointer-events: none;
}

/* 左：家の者の列 */
.ros {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  background: none; border: 0; border-bottom: 1px solid rgba(122,96,58,.22);
  padding: .45rem .2rem; min-height: 48px; text-align: left;
}
.ros:last-child { border-bottom: 0; }
.ros[aria-selected="true"] { background: rgba(181,68,60,.09); border-radius: 4px; }
.ros-f {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 4px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mincho); font-weight: 700; font-size: .95rem;
}
.ros-b { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.ros-n { font-family: var(--mincho); font-size: 1.02rem; letter-spacing: .06em; }
.ros-s { font-size: .72rem; color: var(--ink3); }
.ros-s b { color: var(--ai2); font-size: .82rem; font-variant-numeric: tabular-nums; }

/* 右：詳細 */
.d-head { border-bottom: 2px solid rgba(34,28,22,.5); padding-bottom: .3rem; margin-bottom: .5rem; }
.d-title { display: block; font-family: var(--mincho); font-size: 1.15rem; letter-spacing: .08em; }
.d-sub { display: block; font-size: .74rem; color: var(--ink3); letter-spacing: .06em; }
.d-line {
  display: flex; justify-content: space-between; gap: .6rem;
  font-size: .76rem; color: var(--ink2); padding: .2rem 0;
}
.d-line b { font-family: var(--mincho); font-size: .98rem; color: var(--ai2); font-variant-numeric: tabular-nums; }
.d-rank {
  margin: .4rem 0; padding: .25rem .5rem; border-radius: 4px;
  background: rgba(34,72,110,.09); font-size: .78rem;
}
.d-rank b { font-family: var(--mincho); font-size: .95rem; color: var(--shu2); }
.d-bar { height: 6px; background: rgba(34,28,22,.12); border-radius: 999px; overflow: hidden; margin: .2rem 0 .5rem; }
.d-bar i { display: block; height: 100%; background: var(--ai2); }
.d-note { font-size: .7rem; margin-top: .6rem; line-height: 1.7; }

.d-cols { display: grid; grid-template-columns: minmax(0, 88px) minmax(0, 1fr); gap: .7rem; margin-top: .5rem; }
.st-row { display: flex; justify-content: space-between; align-items: baseline; padding: .12rem 0; }
.st-n { font-size: .74rem; color: var(--ink2); }
.st-v { font-family: var(--mincho); font-size: 1rem; font-variant-numeric: tabular-nums; }

/* 技。ロマサガの武器レベル欄に倣った並び */
.sk-row { display: flex; align-items: center; gap: .35rem; padding: .14rem 0; }
.sk-off { opacity: .42; }
.sk-i {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 3px;
  background: #6b7a5a; color: #f2ece0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mincho); font-size: .7rem;
}
.sk-n { font-family: var(--mincho); font-size: .8rem; flex: 0 0 3.4em; }
.sk-bar { flex: 1 1 auto; height: 5px; background: rgba(34,28,22,.12); border-radius: 999px; overflow: hidden; min-width: 20px; }
.sk-bar i { display: block; height: 100%; background: var(--karashi, #a8842c); }
.sk-lv {
  flex: 0 0 1.6em; text-align: right;
  font-family: var(--mincho); font-size: .95rem; font-variant-numeric: tabular-nums;
}

/* 横幅に余裕があれば、本物の見開きのように左右へ並べる */
@media (min-width: 560px) {
  .sheet { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
}

/* ============================================================
   道中の難所
   いただいた戦闘画面の構図に倣い、和紙の地に相手を大きく置き、
   その下に手を並べる。剣戟ではなく、四つの選択で切り抜ける。
   ============================================================ */
#enc {
  position: absolute; inset: 0; z-index: 85;
  background: rgba(18,15,12,.6);
  display: flex; flex-direction: column; justify-content: flex-end;
}
#enc[hidden] { display: none; }
.enc-art { flex: 1; min-height: 0; position: relative; }
#enc-canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.enc-box {
  flex: none; background: var(--w3); border-top: 3px solid var(--ink);
  padding: .8rem .9rem calc(env(safe-area-inset-bottom) + .9rem);
  max-height: 62%; overflow-y: auto;
}
.enc-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.enc-name {
  font-family: var(--mincho); font-size: 1.06rem; letter-spacing: .1em;
  background: var(--ink); color: var(--w); padding: .12rem .65rem; border-radius: 4px;
}
.enc-ki {
  flex: 1 1 auto; height: 8px; min-width: 40px;
  background: rgba(34,28,22,.14); border-radius: 999px; overflow: hidden;
}
.enc-ki i { display: block; height: 100%; background: var(--shu); transition: width .25s ease-out; }
.enc-kin { font-size: .7rem; color: var(--ink3); font-variant-numeric: tabular-nums; }
.enc-lead { font-size: .92rem; line-height: 1.9; margin-bottom: .5rem; }
.enc-log {
  font-size: .76rem; color: var(--ink2); line-height: 1.8;
  max-height: 4.4em; overflow-y: auto; margin-bottom: .6rem;
  border-left: 2px solid var(--line2); padding-left: .5rem;
}
.enc-moves { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.enc-moves button {
  min-height: 56px; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--w); padding: .45rem .6rem; text-align: left;
  display: flex; flex-direction: column; gap: .1rem;
}
.enc-moves button:disabled { opacity: .45; }
.enc-moves .m-n { font-family: var(--mincho); font-size: .95rem; letter-spacing: .04em; }
.enc-moves .m-d { font-size: .66rem; color: var(--ink3); line-height: 1.5; }

/* 連れの誘い */
.pt-btn {
  width: 100%; min-height: 44px; margin-top: .4rem;
  border: 1px solid var(--line2); border-radius: 7px; background: var(--w);
  font-family: var(--mincho); font-size: .92rem; letter-spacing: .06em;
}
.pt-btn.go { background: var(--ink); color: var(--w); border-color: var(--ink); }

/* 名簿が長くなるので、左だけ縦に送れるようにする */
.sheet-l { max-height: 46vh; overflow-y: auto; }
@media (min-width: 560px) { .sheet-l { max-height: none; } }

/* ============================================================
   代替わり — 暖簾を渡す
   ============================================================ */
#succ {
  position: absolute; inset: 0; z-index: 90;
  background:
    radial-gradient(rgba(90,72,48,.05) 1px, transparent 1px) 0 0/7px 7px,
    linear-gradient(180deg, #efe6d0, #e2d6ba);
  overflow-y: auto;
  padding: 1.1rem .95rem calc(env(safe-area-inset-bottom) + 1.1rem);
}
#succ[hidden] { display: none; }
.succ-inner { max-width: 34rem; margin: 0 auto; }
.succ-h {
  font-family: var(--mincho); font-size: 1.5rem; letter-spacing: .18em;
  text-align: center; margin-bottom: .3rem;
  border-bottom: 2px solid rgba(34,28,22,.5); padding-bottom: .5rem;
}
.succ-lead { font-size: .92rem; line-height: 2; margin: .8rem 0; }
.succ-keep {
  border: 1px solid rgba(122,96,58,.4); border-radius: 5px;
  background: rgba(255,252,244,.6); padding: .6rem .7rem; margin-bottom: .9rem;
  font-size: .78rem; line-height: 1.9;
}
.succ-keep h4 {
  font-family: var(--mincho); font-size: .82rem; letter-spacing: .14em;
  color: var(--ink3); margin-bottom: .3rem;
}
.succ-keep .k-row { display: flex; gap: .5rem; padding: .1rem 0; }
.succ-keep .k-l { flex: 0 0 5.2em; color: var(--ink3); }
#succ-pick .pick-card:disabled { opacity: .45; }
.sb-gen {
  font-size: .68rem; letter-spacing: .08em; margin-left: .5rem;
  color: rgba(242,234,216,.72); font-variant-numeric: tabular-nums;
}

/* ============================================================
   手ほどき
   遊んでいる最中に、いま必要なことだけを一つずつ出す。
   操作は奪わない——指し示すだけで、押すのは遊ぶ人である。
   ============================================================ */
#tut-ring {
  position: absolute; z-index: 98; pointer-events: none;
  border: 2px solid var(--shu); border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(18,15,12,.5), 0 0 12px rgba(181,68,60,.6);
  transition: top .22s ease-out, left .22s ease-out, width .22s ease-out, height .22s ease-out;
}
#tut-ring[hidden] { display: none; }

#tut {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 99;
  padding: .5rem .5rem calc(env(safe-area-inset-bottom) + .5rem);
  pointer-events: none;
}
#tut[hidden] { display: none; }
.tut-box {
  pointer-events: auto;
  background: var(--w3);
  border: 2px solid var(--ink); border-radius: 10px;
  padding: .7rem .8rem .6rem;
  box-shadow: 0 6px 22px rgba(18,15,12,.4);
  max-width: 34rem; margin: 0 auto;
}
.tut-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.tut-n {
  flex: 0 0 auto; font-family: var(--mincho); font-size: .68rem; letter-spacing: .1em;
  background: var(--shu); color: #fff; border-radius: 999px; padding: .1rem .55rem;
}
.tut-t { font-family: var(--mincho); font-size: 1rem; letter-spacing: .06em; }
.tut-x {
  margin-left: auto; flex: 0 0 auto;
  font-size: .7rem; color: var(--ink3); background: none;
  border: 1px solid var(--line2); border-radius: 5px;
  min-height: 32px; padding: 0 .6rem;
}
.tut-b { font-size: .84rem; line-height: 1.95; color: var(--ink2); }
.tut-b b { color: var(--ink); }
.tut-nav { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }
.tut-wait { font-size: .74rem; color: var(--shu2); font-family: var(--mincho); }
.tut-go {
  margin-left: auto; min-height: 42px; padding: 0 1.4rem;
  background: var(--ink); color: var(--w); border: 0; border-radius: 7px;
  font-family: var(--mincho); font-size: .92rem; letter-spacing: .12em;
}
.tut-go[hidden] { display: none; }

/* ============ 版の線引き（試し版の鍵と切れ目） ============ */
/* 鍵のかかった選択肢も画面には出す。隠せば、何かがあることすら伝わらない。 */
.pick-card.locked { opacity: .62; cursor: default; border-style: dashed; }
.pick-card.locked:hover { transform: none; }
.pc-lock {
  display: inline-block; margin-inline-start: .5em; padding: .05em .5em;
  font-size: .68em; letter-spacing: .08em; border-radius: 999px;
  background: var(--shu2, #b5443c); color: #fff; vertical-align: .12em;
}
.pc-locknote {
  display: block; margin-top: .5rem; padding-top: .5rem;
  border-top: 1px dashed currentColor; font-size: .82em; line-height: 1.7; opacity: .85;
}

#gate {
  position: fixed; inset: 0; z-index: 96; display: grid; place-items: center;
  padding: 1.2rem; background: rgba(12, 14, 20, .93); overflow-y: auto;
}
/* id 選択子の display は [hidden] の display:none を押し負かす。
   覆いを作るたびにこれを書き忘れて、最初から出っぱなしになる。 */
#gate[hidden] { display: none; }
.gate-box {
  max-width: 34rem; width: 100%; padding: 1.6rem 1.4rem 1.3rem;
  background: var(--ji, #16181f); border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px;
}
.gate-eyebrow {
  margin: 0; font-size: .74rem; letter-spacing: .22em; text-transform: none;
  color: var(--shu2, #b5443c);
}
.gate-title {
  margin: .35rem 0 .7rem; font-family: var(--mincho, serif);
  font-size: clamp(1.3rem, 4.6vw, 1.75rem); line-height: 1.4;
}
.gate-lead { margin: 0 0 1rem; line-height: 1.9; opacity: .9; }
.gate-list { display: grid; gap: .55rem; margin-bottom: 1.1rem; }
.gate-item {
  display: grid; gap: .18rem; padding: .6rem .75rem;
  background: rgba(255, 255, 255, .045); border-radius: 8px;
  border-inline-start: 2px solid var(--shu2, #b5443c);
}
.gate-item b { font-family: var(--mincho, serif); font-size: 1rem; }
.gate-item span { font-size: .84rem; line-height: 1.75; opacity: .82; }
.gate-acts { display: grid; gap: .5rem; }
.gate-b1, .gate-b2 {
  width: 100%; padding: .8rem 1rem; border-radius: 8px; font-size: .95rem;
  font-family: inherit; cursor: pointer; border: 1px solid rgba(255, 255, 255, .18);
}
.gate-b1 { background: var(--shu2, #b5443c); color: #fff; border-color: transparent; }
.gate-b2 { background: transparent; color: inherit; }
.gate-b1:hover, .gate-b2:hover { filter: brightness(1.12); }
.gate-note {
  margin: 1rem 0 0; font-size: .8rem; line-height: 1.8; opacity: .62; text-align: center;
}
