/* 漢方カードバトル — スタイル（和・薬箱イメージ） */
:root {
  --paper: #f5efe1;
  --paper-2: #efe6d2;
  --ink: #2b2620;
  --ink-soft: #6b6152;
  --accent: #7a2e2e;      /* 朱に近い漢方色 */
  --accent-2: #3f5c4a;    /* 薬草の緑 */
  --gold: #b08d3e;
  --warm: #c0483b;        /* 温 */
  --cold: #2f6690;        /* 寒 */
  --neutral: #c9a227;     /* 平 */
  --line: #d8ccb2;
  --shadow: 0 2px 8px rgba(0,0,0,.12);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}
/* 背景イラスト（漢方薬局）。固定・全面カバー */
body {
  min-height: 100vh;
  background: url("bg.png") center center / cover no-repeat fixed, var(--paper);
}
/* 読みやすさ用のうすい和紙スクリム（イラストを少し落ち着かせる） */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: rgba(245, 239, 225, .40);
}
#app { max-width: 1040px; margin: 0 auto; padding: 16px 18px 60px; }
/* テキストが背景に直接乗る画面（スタート・同意・準備）は、うすい和紙パネルで読みやすく */
.start-screen, .consent-screen {
  background: rgba(247, 241, 228, .90);
  border-radius: 16px; padding: 18px 20px 26px; margin-top: 12px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .22);
}

/* ---- トップバー ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 14px;
  background: linear-gradient(180deg, #fff9ec, var(--paper-2));
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.brand { font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.brand span { color: var(--ink); }
.edition-badge {
  display: inline-block; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--warm); border-radius: 999px; padding: 1px 9px; margin-left: 8px;
  vertical-align: middle; letter-spacing: .04em;
}
.start-screen h1 .edition-badge { font-size: 14px; padding: 2px 12px; }
.stats { display: flex; gap: 14px; }
.stat { font-size: 13px; color: var(--ink-soft); }
.stat b { font-size: 17px; color: var(--ink); margin-left: 2px; }

/* ---- 症状カード ---- */
.symptom-card {
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow); position: relative;
}
.symptom-label {
  position: absolute; top: -11px; left: 16px;
  background: var(--accent); color: #fff; font-size: 12px;
  padding: 2px 10px; border-radius: 20px; letter-spacing: .04em;
}
.symptom-text { font-size: 18px; line-height: 1.7; margin: 8px 0 10px; font-weight: 600; }
.symptom-actions { text-align: right; }
.symptom-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bonus-chip {
  font-size: 13px; color: #2e6b4c; background: #e7f1e9;
  border: 1px solid #bcd9c4; border-radius: 20px; padding: 3px 12px;
}
.bonus-chip b { font-size: 15px; }
.bonus-chip.zero { color: var(--ink-soft); background: #efe9db; border-color: var(--line); }
.hint-box {
  margin-top: 10px; padding: 10px 14px; background: #fbf4dd;
  border: 1px dashed var(--gold); border-radius: 10px; font-size: 14px; line-height: 1.6;
}
.hint-box p { margin: 4px 0; }
.hint-answer { color: var(--accent-2); }

/* ---- 調合エリア ---- */
.mixing-area {
  background: var(--paper-2);
  border: 2px dashed var(--gold); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 16px;
}
.mixing-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: .04em; }
.mixing-content { min-height: 30px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mixing-formula { font-size: 17px; font-weight: 700; color: var(--accent-2); }
.mixing-count { font-size: 13px; color: var(--ink-soft); }
.mixing-empty { color: var(--ink-soft); font-size: 14px; }
.mixing-buttons { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* 調合エリアのチップ・判定表示 */
.pot-piece {
  font-size: 14px; font-weight: 700; color: var(--ink);
  background: #fffdf6; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px;
}
.pot-piece.pot-bottle { color: #2e6b4c; background: #e7f1e9; border-color: #bcd9c4; }
.mixing-detect { margin-top: 10px; font-size: 15px; min-height: 22px; }
.pot-empty { color: var(--ink-soft); font-size: 14px; }
.pot-ok { color: var(--accent-2); }
.pot-ok b { font-size: 17px; }
.pot-ng { color: #a05a2c; }

/* ---- 薬瓶の棚 ---- */
.shelf-area {
  background: #f3f6ef; border: 1px solid #cfdcc9; border-radius: 14px;
  padding: 12px 16px; margin-bottom: 14px;
}
.shelf-label { font-size: 12px; color: #587a5f; margin-bottom: 8px; letter-spacing: .04em; }
.shelf-empty { color: var(--ink-soft); font-size: 13px; }
.shelf-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.bottle-card {
  position: relative; min-width: 128px; cursor: pointer;
  background: linear-gradient(180deg, #ffffff, #eef4ee);
  border: 1.5px solid #9cbfa6; border-radius: 10px; padding: 12px 12px 10px;
  box-shadow: var(--shadow); transition: transform .1s, box-shadow .1s, border-color .1s;
}
.bottle-card:hover { transform: translateY(-3px); box-shadow: 0 6px 14px rgba(0,0,0,.16); }
.bottle-card.selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px var(--accent-2), 0 6px 16px rgba(63,92,74,.35);
  transform: translateY(-5px);
}
.bottle-card.selected::after {
  content: "✓"; position: absolute; top: -10px; right: -10px;
  width: 24px; height: 24px; line-height: 24px; text-align: center;
  background: var(--accent-2); color: #fff; font-size: 14px; font-weight: 700;
  border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.25);
}
.bottle-cap {
  width: 34px; height: 8px; margin: 0 auto 6px;
  background: #b08d3e; border-radius: 3px;
}
.bottle-name { font-size: 18px; font-weight: 800; color: var(--accent-2); text-align: center; }
.bottle-kana { font-size: 10px; color: var(--ink-soft); text-align: center; }
.bottle-herbs { font-size: 10px; color: var(--ink-soft); margin-top: 6px; line-height: 1.4; text-align: center; }

/* ---- ターンバー ---- */
.turn-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.ghost-btn.danger { color: #9a4a3a; border-color: #d8b3ac; }
.ghost-btn.danger:hover { background: #fbeeeb; }

/* 確保ボタン（薬草色） */
.accent-btn {
  background: var(--accent-2); color: #fff; border: none; cursor: pointer;
  padding: 10px 20px; border-radius: 24px; font-size: 15px; font-weight: 700;
  box-shadow: var(--shadow); transition: transform .08s, background .2s;
}
.accent-btn:hover { background: #4b6d58; }
.accent-btn:active { transform: translateY(1px); }
.accent-btn:disabled { background: #c3b8a2; cursor: not-allowed; box-shadow: none; }

/* ---- ボタン ---- */
.primary-btn {
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 10px 20px; border-radius: 24px; font-size: 15px; font-weight: 700;
  box-shadow: var(--shadow); transition: transform .08s, background .2s;
}
.primary-btn:hover { background: #90403f; }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { background: #c3b8a2; cursor: not-allowed; box-shadow: none; }
.ghost-btn {
  background: rgba(255, 253, 246, .94); color: var(--ink); cursor: pointer;
  border: 1px solid var(--line); padding: 8px 16px; border-radius: 24px; font-size: 14px;
  box-shadow: var(--shadow);
}
.ghost-btn:hover { background: #fff; }
.ghost-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- 手札 ---- */
.hand-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; letter-spacing: .04em; }
/* 手札は折り返し表示（枚数が増えても2行に収まり、枠の高さは固定で動かない） */
.hand-grid {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: flex-start; align-content: flex-start;
  min-height: 428px;   /* カード約207px×2行＋隙間。8枚目で折り返しても枠が動かない。手札最大12枚=2行に収まる */
  padding-bottom: 8px;
}
.hand-grid .herb-card { flex: 0 0 128px; }
.herb-card {
  position: relative; background: #fffdf6; border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 10px 12px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .1s, box-shadow .1s, border-color .1s;
  border-top-width: 6px;
}
.herb-card:hover { transform: translateY(-3px); box-shadow: 0 6px 14px rgba(0,0,0,.16); }

/* ---- カードの裏面デザイン（山札の束・引いたカードの裏で共通） ---- */
:root {
  /* カードの裏面イラスト（五行）。読み込み失敗時は下の緑グラデにフォールバック */
  --card-back:
    url("card-back.png") center / cover no-repeat,
    linear-gradient(160deg, #4a6b52, #34503f);
}

/* ---- 山札の束（ターンバーに置く） ---- */
.deck-pile {
  position: relative; flex: 0 0 auto;
  width: 46px; height: 64px; border-radius: 8px;
  background: var(--card-back);
  border: 1.5px solid rgba(255,255,255,.28);
  box-shadow: 2px 2px 0 -1px #3a5642, 4px 4px 0 -2px #34503f,
              6px 6px 0 -3px rgba(0,0,0,.18), var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.deck-pile-count {
  color: #fff; font-weight: 700; font-size: 14px;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  background: rgba(0,0,0,.25); border-radius: 6px; padding: 1px 6px;
}
.deck-pile.empty {
  background: #ece3cf; border: 1.5px dashed var(--line); box-shadow: none;
}
.deck-pile.empty .deck-pile-count { color: var(--ink-soft); background: transparent; }
.deck-pile.deck-pulse { animation: pilePulse .5s ease; }
@keyframes pilePulse {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-4px) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}

/* 山札・捨て札のラベル付きラッパ */
.pile-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 0 0 auto; }
.pile-label { font-size: 11px; font-weight: 700; color: var(--ink-soft); }

/* ---- 捨て札の山（表向き＝山札との差別化） ---- */
.discard-pile {
  position: relative; width: 46px; height: 64px; border-radius: 8px;
  background: #fffdf6; border: 1.5px solid var(--line);
  border-top-width: 5px; border-top-color: var(--neutral);
  box-shadow: 2px 2px 0 -1px #efe7d3, 4px 4px 0 -2px #e8dfca, var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; padding: 3px; overflow: hidden; transition: transform .1s;
}
.discard-pile:hover { transform: translateY(-2px); }
.discard-pile-count { font-size: 20px; font-weight: 800; color: var(--ink); }
.discard-pile.empty { border-style: dashed; box-shadow: none; }
.discard-pile.empty .discard-pile-count { color: var(--ink-soft); }

/* 捨て札の中身モーダル */
.discard-section { margin-top: 12px; }
.discard-shead { font-size: 14px; font-weight: 800; color: var(--accent); }
.discard-shead span { font-size: 11px; font-weight: 400; color: var(--ink-soft); margin-left: 6px; }
.discard-shead.used { color: #a05a2c; }
.discard-emptynote { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.discard-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.discard-chip {
  border: 1px solid var(--line); border-top-width: 4px; border-radius: 8px;
  padding: 6px 10px; background: #fff; display: flex; align-items: center; gap: 6px;
}
.discard-chip.netsu-warm    { border-top-color: var(--warm); }
.discard-chip.netsu-cold    { border-top-color: var(--cold); }
.discard-chip.netsu-neutral { border-top-color: var(--neutral); }
.discard-chip.used-chip { border-top-color: var(--gold); background: #fbf4e4; }
.dc-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.dc-count { font-size: 12px; color: var(--ink-soft); }

/* 確認ダイアログ（補助カードを捨てるとき等） */
.confirm-modal {
  background: #fffdf6; border-radius: 16px; padding: 22px 24px; max-width: 380px; width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.35); border-top: 8px solid var(--warm); text-align: center;
}
.confirm-text { font-size: 15px; line-height: 1.6; color: var(--ink); }
.confirm-buttons { display: flex; gap: 10px; margin-top: 18px; }
.confirm-buttons button { flex: 1; }
.primary-btn.danger { background: var(--warm); border-color: var(--warm); }

/* ---- 山札から配られ、裏向きで来て、めくれて表になる ---- */
@keyframes dealFlip {
  0%   { opacity: 0; transform: translateY(-84px) scale(.9) rotate(-8deg); }
  25%  { opacity: 1; transform: translateY(0)    scale(1)  rotate(0); } /* 手札位置へ着地（まだ裏） */
  60%  { transform: translateY(0) scaleX(1); }                          /* 裏面を見せてから、めくり始め */
  78%  { transform: translateY(-2px) scaleX(.04); }                     /* エッジ（立った瞬間） */
  100% { transform: translateY(0) scaleX(1); }                          /* 表になった */
}
.herb-card.just-drawn {
  animation: dealFlip 1s cubic-bezier(.2,.8,.3,1.05) var(--dd, 0ms) backwards;
  z-index: 3;
}
/* カードの背（裏面）。めくりの中間まで見え、その後パッと消えて表が現れる */
@keyframes backHide { 0%, 78% { opacity: 1; } 79%, 100% { opacity: 0; } }
.herb-card.just-drawn::before {
  content: ""; position: absolute; inset: -1.5px; border-radius: 12px; z-index: 6;
  background: var(--card-back);
  border: 1.5px solid rgba(255,255,255,.28);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.08);
  animation: backHide 1s step-end var(--dd, 0ms) both;
  pointer-events: none; /* 裏面は見た目だけ。クリックはカード/ボタンへ透過させる（押せない不具合の修正）*/
}
/* 山札カウンタ（上部の数字）が減ったときのパルス */
@keyframes deckPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.35); color: var(--accent-2); }
  100% { transform: scale(1); }
}
.stat-deck.deck-pulse b { display: inline-block; animation: deckPulse .5s ease; }
.herb-card.selected {
  border-color: var(--accent-2);
  background: #eef4ee;
  box-shadow: 0 0 0 4px var(--accent-2), 0 6px 16px rgba(63,92,74,.35);
  transform: translateY(-5px);
}
.herb-card.netsu-warm    { border-top-color: var(--warm); }
.herb-card.netsu-cold    { border-top-color: var(--cold); }
.herb-card.netsu-neutral { border-top-color: var(--neutral); }
.herb-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-soft); }
.herb-netsu {
  font-weight: 700; color: #fff; border-radius: 4px; padding: 0 5px;
}
.netsu-warm .herb-netsu    { background: var(--warm); }
.netsu-cold .herb-netsu    { background: var(--cold); }
.netsu-neutral .herb-netsu { background: var(--neutral); }
.herb-name { font-size: 21px; font-weight: 700; margin: 6px 0 0; letter-spacing: .04em; }
.herb-kana { font-size: 11px; color: var(--ink-soft); }
.herb-copy { font-size: 11px; color: var(--ink); margin-top: 6px; line-height: 1.4; min-height: 30px; }
.redraw-btn {
  margin-top: 6px; width: 100%; font-size: 11px; color: var(--ink-soft);
  background: #f0e9d8; border: 1px solid var(--line); border-radius: 8px;
  padding: 3px 0; cursor: pointer;
}
.redraw-btn:hover { background: #e6dcc4; }

/* ---- 補助（収穫）カード ---- */
.herb-card.action-card {
  border-top-color: var(--gold); background: #fffaf0; cursor: default;
}
.herb-card.action-card:hover { transform: none; box-shadow: var(--shadow); }
.action-badge {
  font-weight: 700; color: #fff; background: var(--gold);
  border-radius: 4px; padding: 0 6px; font-size: 10px;
}
.use-action-btn {
  margin-top: 8px; width: 100%; font-size: 13px; font-weight: 700; color: #fff;
  background: var(--gold); border: none; border-radius: 8px; padding: 6px 0; cursor: pointer;
}
.use-action-btn:hover { filter: brightness(1.06); }
/* 大収穫カードは緑系で区別 */
.herb-card.action-big { border-top-color: var(--accent-2); background: #f0f5f0; }
.action-big .action-badge { background: var(--accent-2); }
.action-big .use-action-btn { background: var(--accent-2); }
/* お邪魔カード（招かれざる客）は赤系で区別。長い名前は1行に収める */
.herb-card.action-jama { border-top-color: var(--warm); background: #fbeeeb; }
.action-jama .herb-name { font-size: 16px; white-space: nowrap; }
.action-jama .action-badge { background: var(--warm); }
.action-jama .use-action-btn { background: var(--warm); }

/* ---- 薬瓶が破壊されたお知らせ（割れる演出）---- */
.broken-modal {
  background: #fffdf6; border-radius: 18px; padding: 26px 28px; text-align: center;
  max-width: 440px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.4); border-top: 8px solid var(--warm);
}
.broken-illust {
  width: min(300px, 68vw); height: min(300px, 68vw); object-fit: cover; border-radius: 20px;
  margin: 0 auto 8px; display: block; box-shadow: 0 12px 34px rgba(0,0,0,.35);
  border: 4px solid #fff;
  animation: illustPop .55s cubic-bezier(.2,1.35,.35,1) both;
}
@keyframes illustPop {
  0%  { transform: scale(.55) rotate(-4deg); opacity: 0; }
  70% { transform: scale(1.04) rotate(1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.broken-anim { position: relative; height: 72px; display: flex; align-items: center; justify-content: center; }
.broken-bottle { position: absolute; font-size: 56px; animation: bottleShake 1s ease forwards; }
.broken-burst { position: absolute; font-size: 60px; opacity: 0; animation: burstPop 1s ease forwards; }
@keyframes bottleShake {
  0% { transform: translateX(0) rotate(0); }
  8%, 24%, 40% { transform: translateX(-7px) rotate(-9deg); }
  16%, 32%, 48% { transform: translateX(7px) rotate(9deg); }
  60% { transform: translateX(0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translateY(26px) rotate(26deg) scale(.45); opacity: 0; }
}
@keyframes burstPop {
  0%, 52% { opacity: 0; transform: scale(.3); }
  64% { opacity: 1; transform: scale(1.35); }
  100% { opacity: 1; transform: scale(1); }
}
.broken-title { font-size: 20px; font-weight: 800; color: var(--warm); margin-top: 6px; }
.broken-text { font-size: 14px; line-height: 1.7; color: var(--ink); margin: 10px 0 18px; }
.broken-sub { font-size: 12px; color: var(--ink-soft); }
.broken-modal .primary-btn { width: 100%; }

/* 収穫カードを引いたときのふわっと表示（自動で消える） */
.harvest-flash {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 60; background: rgba(0,0,0,.28);
  animation: harvestFadeKf 1.9s ease forwards;
}
@keyframes harvestFadeKf { 0%,88% { background: rgba(0,0,0,.28); } 100% { background: rgba(0,0,0,0); } }
.harvest-flash-inner {
  text-align: center; animation: harvestFlashKf 1.9s ease forwards;
}
.harvest-illust {
  width: min(300px, 74vw); height: min(300px, 74vw); object-fit: cover; border-radius: 22px;
  box-shadow: 0 14px 44px rgba(0,0,0,.45); border: 5px solid #fffdf6;
}
.harvest-flash-cap {
  margin-top: 14px; display: inline-block; font-weight: 800; font-size: 19px; color: #fff;
  background: rgba(60,90,50,.92); padding: 8px 22px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
}
@keyframes harvestFlashKf {
  0%   { opacity: 0; transform: scale(.7) translateY(14px); }
  14%  { opacity: 1; transform: scale(1.04) translateY(0); }
  24%  { transform: scale(1) translateY(0); }
  78%  { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(.96) translateY(-8px); }
}

/* ---- 収穫カードの生薬えらびモーダル ---- */
.harvest-modal {
  background: #fffdf6; border-radius: 18px; padding: 22px 24px;
  max-width: 460px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.35);
  border-top: 8px solid var(--gold);
}
.harvest-title { font-size: 18px; font-weight: 800; color: var(--accent); margin-bottom: 12px; }
.harvest-chosen { font-size: 13px; color: var(--ink); margin-bottom: 12px; min-height: 26px; }
.chosen-herb {
  display: inline-block; background: #eef4ee; border: 1px solid var(--accent-2);
  color: var(--accent); border-radius: 999px; padding: 2px 10px; margin: 2px 4px 2px 0;
  font-size: 13px; cursor: pointer;
}
.pick-empty { color: var(--ink-soft); }
.harvest-pool { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.pick-herb {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: #fffdf6; border: 1.5px solid var(--line); border-top-width: 5px;
  border-radius: 10px; padding: 8px 4px; cursor: pointer; font-size: 12px;
}
.pick-herb:hover:not(:disabled) { background: #fff; box-shadow: var(--shadow); }
.pick-herb:disabled { opacity: .4; cursor: not-allowed; }
.pick-herb.netsu-warm    { border-top-color: var(--warm); }
.pick-herb.netsu-cold    { border-top-color: var(--cold); }
.pick-herb.netsu-neutral { border-top-color: var(--neutral); }
.pick-name { font-size: 15px; font-weight: 700; }
.pick-rem { font-size: 10px; color: var(--ink-soft); }
.harvest-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---- トースト ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 50; max-width: 90%;
}
.toast.warn { background: #8a5a1a; }
.toast.hidden { display: none; }

/* ---- 結果モーダル ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(30,26,20,.55);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.result-modal {
  background: #fffdf6; border-radius: 18px; padding: 26px 30px; text-align: center;
  max-width: 420px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.35);
  border-top: 8px solid var(--gold);
}
.result-modal.grade-3 { border-top-color: #2e8b57; }
.result-modal.grade-2 { border-top-color: var(--gold); }
.result-modal.grade-1 { border-top-color: #c88a3a; }
.result-modal.grade-0 { border-top-color: #999; }
.result-formula { font-size: 28px; font-weight: 800; color: var(--accent); }
.result-formula span { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 400; margin-top: 2px; }
.result-grade { font-size: 16px; margin: 12px 0 2px; color: var(--ink); }
.result-points { font-size: 46px; font-weight: 800; color: var(--accent-2); line-height: 1; }
.result-points span { font-size: 16px; margin-left: 3px; }
.result-note { font-size: 14px; color: var(--ink); line-height: 1.6; margin: 14px 0 4px; }
.result-genten { font-size: 12px; color: var(--ink-soft); margin-bottom: 18px; }

/* ---- 終了画面 ---- */
.end-screen { text-align: center; }
.end-screen h1 { color: var(--accent); font-size: 26px; }
.end-score { margin: 10px 0 22px; }
.end-total { font-size: 44px; font-weight: 800; color: var(--accent-2); }
.end-total span { font-size: 18px; color: var(--ink-soft); font-weight: 400; }
.end-rank { font-size: 18px; margin-top: 6px; }
.end-comment { color: var(--ink-soft); }
.log-table {
  width: 100%; border-collapse: collapse; margin: 0 auto 22px; font-size: 13px; text-align: left;
  background: #fffdf6; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow);
}
.log-table th, .log-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table th { background: var(--paper-2); font-size: 12px; color: var(--ink-soft); }
.log-symptom { max-width: 420px; color: var(--ink-soft); }
.log-pt { white-space: nowrap; font-weight: 700; }
.pt-3 { color: #2e8b57; } .pt-2 { color: var(--gold); } .pt-1 { color: #c88a3a; } .pt-0 { color: #999; }

@media (max-width: 560px) {
  .symptom-text { font-size: 16px; }
  .hand-grid .herb-card { flex: 0 0 108px; }
  .herb-name { font-size: 19px; }
}

/* ---- スタート画面（テーマ選択）---- */
.start-screen {
  max-width: 640px; margin: 24px auto 0; text-align: center;
}
.disclaimer {
  margin-top: 16px; font-size: 11px; line-height: 1.6; color: var(--ink-soft);
  background: #fbf4e4; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}

/* ---- 免責への同意ゲート（公開版の起動画面） ---- */
.consent-screen { max-width: 560px; margin: 0 auto; padding: 8px 4px; text-align: center; }
.consent-screen h1 { color: var(--accent); font-size: 24px; margin-bottom: 16px; }
.consent-screen h1 span { color: var(--ink); }
.consent-box {
  background: #fffdf6; border: 1px solid var(--line); border-top: 6px solid var(--warm);
  border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); text-align: left;
}
.consent-lead { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.consent-text {
  font-size: 13px; line-height: 1.7; color: var(--ink);
  background: #fbf4e4; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
}
.consent-check {
  display: flex; align-items: center; gap: 8px; margin: 16px 0;
  font-size: 14px; font-weight: 700; color: var(--ink); cursor: pointer;
}
.consent-check input { width: 18px; height: 18px; cursor: pointer; }
.consent-box .primary-btn { width: 100%; }
.consent-box .primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.mode-select { display: flex; gap: 10px; justify-content: center; margin: 6px 0 4px; }
.mode-btn {
  flex: 1; max-width: 200px; padding: 12px 10px; font-size: 15px; font-weight: 700;
  color: var(--ink-soft); background: #fffdf6; border: 1.5px solid var(--line);
  border-radius: 12px; cursor: pointer; transition: transform .08s, border-color .1s, background .1s;
}
.mode-btn:hover { transform: translateY(-2px); }
.mode-btn.selected { color: #fff; background: var(--accent); border-color: var(--accent); }
.mode-note { font-size: 12px; color: var(--ink-soft); text-align: center; margin: 0 0 12px; }
.vs-setup-hint {
  font-size: 13px; color: var(--ink); text-align: center; line-height: 1.6;
  background: #eef4ee; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 4px 0;
}
.vs-back-btn { display: inline-block; margin-bottom: 10px; font-size: 13px; }
.vs-name-row { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); margin: 4px 0 12px; }
.vs-name-input {
  flex: 1; font-size: 16px; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fffdf6; color: var(--ink);
}
.vs-name-input:focus { outline: none; border-color: var(--accent); }

/* ---- 対戦：目隠し（交代）画面 ---- */
.handoff-overlay { background: var(--accent); } /* 不透明に近い覆いで前の手札を隠す */
.handoff-modal {
  background: #fffdf6; border-radius: 18px; padding: 32px 28px; text-align: center;
  max-width: 420px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.handoff-icon { font-size: 52px; }
.handoff-lead { font-size: 15px; color: var(--ink-soft); margin-top: 6px; }
.handoff-name { font-size: 22px; font-weight: 800; color: var(--accent); margin: 8px 0; }
.handoff-note { font-size: 12px; color: var(--ink-soft); margin-bottom: 18px; }
.handoff-modal .primary-btn { width: 100%; }

/* ---- 対戦バー（両者の得点・手番）---- */
.vs-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 8px 12px; margin-bottom: 12px;
}
.vs-player { display: flex; flex-direction: column; align-items: center; min-width: 90px; padding: 4px 8px; border-radius: 10px; }
.vs-player span { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.vs-player b { font-size: 22px; color: var(--ink); }
.vs-player.active { background: var(--accent); }
.vs-player.active span, .vs-player.active b { color: #fff; }
.vs-sub { font-size: 11px; color: var(--ink-soft); margin-top: 1px; }
.vs-player.active .vs-sub { color: rgba(255,255,255,.85); }
.vs-turn { font-size: 13px; font-weight: 800; color: var(--accent); text-align: center; }

/* ---- 対戦：勝敗画面 ---- */
.vs-result { border-top-color: var(--accent) !important; }
.vs-result-title { font-size: 26px; font-weight: 800; color: var(--accent); margin-bottom: 16px; }
.vs-result-scores { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 8px; }
.vs-result-p { display: flex; flex-direction: column; align-items: center; padding: 12px 16px; border-radius: 12px; border: 1.5px solid var(--line); }
.vs-result-p span { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.vs-result-p b { font-size: 32px; color: var(--ink); }
.vs-result-p.win { border-color: var(--accent); background: #eef4ee; box-shadow: 0 0 0 3px var(--accent); }
.vs-result-mid { font-size: 16px; color: var(--ink-soft); font-weight: 700; }
.result-who { font-size: 15px; font-weight: 800; color: var(--accent); margin-bottom: 6px; }
.start-screen h1 { color: var(--accent); font-size: 26px; margin-bottom: 8px; }
.start-screen h1 span { color: var(--ink); }
.start-lead {
  color: var(--ink-soft); font-size: 14px; line-height: 1.7;
  margin: 0 auto 20px; max-width: 520px;
}
.theme-list { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.theme-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; cursor: pointer;
  background: linear-gradient(180deg, #fff9ec, var(--paper-2));
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.theme-item:hover { border-color: var(--gold); }
.theme-check { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.theme-body { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.theme-name { font-size: 17px; font-weight: 700; color: var(--ink); }
.theme-count { font-size: 12px; font-weight: 400; color: var(--accent-2); margin-left: 6px; }
.theme-desc { font-size: 13px; color: var(--ink-soft); }
.detail-btn {
  align-self: center; flex: none; font-size: 13px; color: var(--accent-2);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
}
.detail-btn:hover { border-color: var(--accent-2); background: #f0f5f0; }
.start-note { color: var(--ink-soft); font-size: 14px; margin: 18px 0; min-height: 1.2em; }
.start-screen .primary-btn { font-size: 16px; padding: 12px 28px; }

/* ---- デッキ編集（補助カードの枚数） ---- */
.deck-editor {
  margin-top: 16px; padding: 14px 16px; text-align: left;
  background: #fffaf0; border: 1px solid var(--line); border-radius: 12px;
}
.deck-editor-title { font-size: 14px; font-weight: 700; color: var(--accent); margin-bottom: 10px; }
.deck-editor-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.de-name { display: flex; flex-direction: column; font-size: 14px; font-weight: 700; color: var(--ink); }
.de-titleline { display: inline; }
.de-max { font-size: 11px; font-weight: 700; color: #a05a2c; margin-left: 4px; }
.de-desc { font-size: 11px; font-weight: 400; color: var(--ink-soft); }
.de-stepper { display: flex; align-items: center; gap: 10px; flex: none; }
.de-stepper b { min-width: 20px; text-align: center; font-size: 17px; color: var(--ink); }
.de-step {
  width: 30px; height: 30px; border-radius: 8px; font-size: 18px; line-height: 1;
  background: #fff; border: 1px solid var(--line); color: var(--accent-2); cursor: pointer;
}
.de-step:hover { border-color: var(--accent-2); background: #f0f5f0; }
.de-note { font-size: 11px; color: var(--ink-soft); margin: 8px 0 0; }
.de-section-title {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--accent-2);
  margin: 16px 0 6px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.de-presets { display: flex; gap: 6px; }
.de-preset-btn {
  font-size: 12px; padding: 5px 10px; border-radius: 8px; cursor: pointer;
  background: #fff; border: 1px solid var(--line); color: var(--ink);
}
.de-preset-btn:hover { border-color: var(--accent-2); }
.de-preset-btn.primary { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.de-preset-btn.primary:hover { filter: brightness(1.08); }
#deck-editor-herbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.de-herb {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
}
.de-herb-off { opacity: .45; background: #f3efe4; }
.de-hname { font-size: 14px; font-weight: 700; color: var(--ink); }
.de-hkana { font-size: 10px; font-weight: 400; color: var(--ink-soft); margin-left: 5px; }
.de-hstep {
  width: 26px; height: 26px; border-radius: 7px; font-size: 16px; line-height: 1;
  background: #fff; border: 1px solid var(--line); color: var(--accent-2); cursor: pointer;
}
.de-hstep:hover { border-color: var(--accent-2); background: #f0f5f0; }
.de-stepper b { min-width: 18px; text-align: center; }
.de-total { font-size: 13px; font-weight: 700; color: var(--accent); margin: 12px 0 0; }

/* ---- テーマ詳細モーダル（方剤一覧） ---- */
.detail-modal {
  background: #fffdf6; border-radius: 18px; padding: 22px 24px; text-align: left;
  max-width: 500px; width: 100%; max-height: 82vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.35); border-top: 8px solid var(--accent);
}
.detail-title { font-size: 20px; font-weight: 800; color: var(--accent); }
.detail-title span { font-size: 14px; font-weight: 400; color: var(--ink-soft); margin-left: 4px; }
.detail-lead { font-size: 12px; color: var(--ink-soft); margin: 6px 0 14px; }
.detail-list { display: flex; flex-direction: column; gap: 8px; }
.detail-formula {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
}
.detail-fhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.detail-fname { font-size: 16px; font-weight: 700; color: var(--ink); }
.detail-fkana { font-size: 11px; font-weight: 400; color: var(--ink-soft); margin-left: 6px; }
.detail-tag { font-size: 11px; font-weight: 700; color: #fff; border-radius: 999px; padding: 2px 10px; flex: none; }
.tag-asked { background: var(--accent); }
.tag-base { background: var(--accent-2); }
.detail-herbs { font-size: 13px; color: var(--ink); margin-top: 5px; line-height: 1.5; }
.detail-count { font-size: 11px; color: var(--ink-soft); }
.detail-close { margin-top: 16px; width: 100%; }
