/* カウンティング練習帳 — 画面の作り
 * 活字（印刷された問題）= --font-print ／ 手書き（答え・途中式・赤ペン）= --font-hand
 */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  font-family: var(--font-print);
  font-weight: 500;
  font-size: var(--text-md);
  line-height: 1.7;
  color: var(--color-ink);
  background-color: var(--color-desk);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--color-blue); text-underline-offset: 0.2em; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h1, h2, h3 { font-style: normal; overflow-wrap: anywhere; min-width: 0; }

:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* ノートの1ページ */
.page {
  position: relative;
  max-width: var(--page-max);
  min-height: 100dvh;
  margin-inline: auto;
  padding: max(var(--space-sm), env(safe-area-inset-top)) max(var(--space-md), env(safe-area-inset-right)) max(var(--space-xl), env(safe-area-inset-bottom)) max(var(--space-md), env(safe-area-inset-left));
  background-color: var(--color-paper);
  background-image:
    linear-gradient(var(--color-grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid-strong) 1px, transparent 1px),
    linear-gradient(var(--color-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid) 1px, transparent 1px);
  background-size: calc(var(--cell) * 5) calc(var(--cell) * 5), calc(var(--cell) * 5) calc(var(--cell) * 5), var(--cell) var(--cell), var(--cell) var(--cell);
  background-position: -1px -1px;
}
@media (min-width: 40rem) {
  body { padding-block: var(--space-lg); }
  .page {
    min-height: calc(100dvh - var(--space-lg) * 2);
    padding-inline: var(--space-xl) var(--space-lg);
    box-shadow: 0 1px 2px var(--color-shadow), 0 0 0 1px var(--color-shadow);
  }
  /* 綴じ穴 */
  .page::before {
    content: "";
    position: absolute; inset-block: 0; inset-inline-start: 0.6rem; width: 0.7rem;
    background-image: radial-gradient(circle at center, var(--color-desk) 0 0.28rem, transparent 0.3rem);
    background-size: 0.7rem calc(var(--cell) * 2);
    background-position: 0 var(--cell);
    pointer-events: none;
  }
}

/* ページ上端（柱）。指で上へ戻したときだけ画面の上に貼りつける（app.js が html に .head-pinned を付ける） */
.head-pinned .head { position: sticky; top: 0; animation: head-in var(--dur-short) var(--ease-out) both; }
@keyframes head-in { from { transform: translateY(-100%); } to { transform: none; } }
.head {
  position: relative; z-index: var(--z-sticky);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-sm);
  min-height: 2.75rem;
  border-bottom: var(--rule-ink) solid var(--color-ink);
  background: var(--color-paper);
  margin-bottom: var(--space-md);
}
.head__back, .head__tool {
  display: inline-flex; align-items: center; gap: var(--space-2xs);
  min-height: 2.75rem; padding-inline: var(--space-2xs);
  font-size: var(--text-sm); font-weight: 700; color: var(--color-ink); text-decoration: none; white-space: nowrap;
  background: none; border: 0;
}
.head__back svg, .head__tool svg { width: 1.1rem; height: 1.1rem; flex: none; }
.head__title { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-lg); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head__title small { font-family: var(--font-print); font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); margin-inline-end: var(--space-xs); }
@media (hover: hover) and (pointer: fine) {
  .head__back:hover, .head__tool:hover { color: var(--color-blue); }
}

/* 手書きと活字 */
.hand { font-family: var(--font-hand); font-weight: 600; }
.pencil { font-family: var(--font-hand); font-weight: 400; color: var(--color-pencil); }
.red { color: var(--color-red-ink); }
.blue { color: var(--color-blue); }
.muted { color: var(--color-muted); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ul-red { text-decoration: underline; text-decoration-color: var(--color-red); text-decoration-thickness: 2px; text-underline-offset: 0.22em; }

/* 印刷された問題の枠 */
.q {
  position: relative;
  border: var(--rule-ink) solid var(--color-ink);
  background: var(--color-paper);
  padding: var(--space-md) var(--space-md) var(--space-sm);
  margin-top: var(--space-sm);
}
.q__no {
  position: absolute; inset-block-start: 0; inset-inline-start: var(--space-sm); transform: translateY(-55%);
  padding-inline: var(--space-xs);
  background: var(--color-paper);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.04em; white-space: nowrap;
}
.q__text { font-size: var(--text-md); font-weight: 700; line-height: 1.6; }
.q__sub { font-size: var(--text-sm); color: var(--color-muted); }
.q__aside { font-size: var(--text-sm); font-weight: 700; color: var(--color-muted); margin-inline-start: var(--space-sm); white-space: nowrap; }

/* 条件の一覧（ラベル＋値） */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs) var(--space-md); }
.facts--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fact { min-width: 0; }
.fact__k { display: block; font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); line-height: 1.4; white-space: nowrap; }
.fact__v { display: block; font-size: var(--text-lg); font-weight: 700; line-height: 1.3; white-space: nowrap; }
.fact__v small { font-size: var(--text-xs); font-weight: 700; margin-inline-start: 1px; }
.fact--key .fact__v { font-size: var(--text-3xl); line-height: 1.05; font-family: var(--font-hand); font-weight: 600; }
.fact--wide { grid-column: 1 / -1; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: 3rem; padding: 0 var(--space-md);
  border: var(--rule-ink) solid var(--color-ink); border-radius: var(--radius-md);
  background: var(--color-paper); color: var(--color-ink);
  font-weight: 700; font-size: var(--text-md); line-height: 1.2; white-space: nowrap; text-decoration: none;
  transition: transform var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled), .btn.is-active { transform: translateY(1px); background: var(--color-paper-2); }
.btn:disabled, .btn[aria-disabled="true"] { color: var(--color-faint); border-color: var(--color-rule); cursor: not-allowed; }
.btn--primary { background: var(--color-ink); color: var(--color-paper); }
.btn--primary:active:not(:disabled) { background: var(--color-pencil); }
.btn--primary:disabled { background: var(--color-faint); border-color: var(--color-faint); color: var(--color-paper); }
.btn--wide { width: 100%; }
.btn--small { min-height: 2.5rem; font-size: var(--text-sm); padding-inline: var(--space-sm); }
.btn--ghost { border-color: transparent; background: none; text-decoration: underline; text-underline-offset: 0.25em; }
.btn[data-state="on"] { background: var(--color-blue-wash); border-color: var(--color-blue); color: var(--color-blue); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: var(--color-paper-2); }
  .btn--primary:hover:not(:disabled) { background: var(--color-pencil); }
  .btn[data-state="on"]:hover:not(:disabled) { background: var(--color-blue-wash); }
}
.row { display: flex; gap: var(--space-xs); align-items: center; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
/* 中身（折り返さない文など）に押し広げられないよう、列は箱の幅まで */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-sm); }
.stack--lg { gap: var(--space-lg); }
.grow { flex: 1 1 0; min-width: 0; }

/* 選択肢（ヒット・スタンド…）: 解答欄のマス */
.keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs); }
.keys--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.keys .btn { min-height: 3.25rem; padding-inline: var(--space-2xs); }
.btn.is-picked { background: var(--color-blue-wash); border-color: var(--color-blue); color: var(--color-blue); }
.btn.is-right { border-color: var(--color-red); color: var(--color-red-ink); background: var(--color-red-wash); }

/* テンキー */
.pad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2xs); }
.pad .btn { min-height: 2.9rem; padding: 0; font-size: var(--text-xl); font-family: var(--font-hand); font-weight: 600; }
.pad .btn--word { font-family: var(--font-print); font-size: var(--text-sm); font-weight: 700; }
.pad__ok { grid-row: span 2; }
.readout {
  display: flex; align-items: baseline; justify-content: center; gap: var(--space-2xs);
  min-height: 3.5rem;
  font-family: var(--font-hand); font-weight: 600; font-size: var(--text-3xl); line-height: 1; color: var(--color-blue);
  border-bottom: var(--rule-ink) dashed var(--color-rule);
  padding-bottom: var(--space-2xs);
}
.readout small { font-size: var(--text-md); font-family: var(--font-print); font-weight: 700; color: var(--color-muted); }
.readout--empty { color: var(--color-faint); }

/* 数直線（賭け金を選ぶ） */
.nl { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
.nl svg { display: block; width: 100%; height: auto; overflow: visible; }
.nl__axis { stroke: var(--color-ink); stroke-width: 1.5; fill: none; stroke-linecap: round; }
.nl__tick { stroke: var(--color-pencil); stroke-width: 1; }
.nl__tick--major { stroke: var(--color-ink); stroke-width: 1.5; }
.nl__label { font-family: var(--font-print); font-size: 12.5px; font-weight: 700; fill: var(--color-pencil); text-anchor: middle; }
.nl__knob { fill: var(--color-blue); }
.nl__stem { stroke: var(--color-blue); stroke-width: 2; }
.nl__right { stroke: var(--color-red); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.nl__rightlabel { font-family: var(--font-hand); font-weight: 600; font-size: 13px; fill: var(--color-red-ink); }
.nl__hit { fill: transparent; cursor: pointer; }
.betrow { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr) 3.25rem; gap: var(--space-xs); align-items: center; background: var(--color-paper); }
.nl { background: var(--color-paper); }
.betrow .btn { min-height: 3rem; padding: 0; font-size: var(--text-xl); }
.betval { text-align: center; font-family: var(--font-hand); font-weight: 600; font-size: var(--text-3xl); line-height: 1.1; color: var(--color-blue); white-space: nowrap; }
.betval small { font-size: var(--text-md); font-family: var(--font-print); font-weight: 700; color: var(--color-muted); }

/* 丸つけ */
.verdict { display: flex; align-items: center; gap: var(--space-sm); min-height: 3.25rem; }
.verdict__mark { flex: none; width: 3.25rem; height: 3.25rem; }
.verdict__mark path { fill: none; stroke: var(--color-red); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: draw var(--dur-long) var(--ease-out) backwards; }
.verdict__mark path + path { animation-delay: 160ms; }
.verdict__text { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-xl); line-height: 1.3; color: var(--color-red-ink); min-width: 0; }
.verdict__text small { display: block; font-size: var(--text-md); font-weight: 400; color: var(--color-ink); line-height: 1.5; }
@keyframes draw { from { stroke-dashoffset: 1; } }

/* 途中式（鉛筆） */
.sol { font-family: var(--font-hand); font-weight: 400; color: var(--color-pencil); font-size: var(--text-md); line-height: 2; }
.sol b { font-weight: 600; color: var(--color-ink); }
/* 文章の解説は活字で読みやすく（紙の地を敷いて方眼に埋もれないように）。計算の行だけ手書き */
.sol--box { background: var(--color-paper); color: var(--color-ink); font-family: var(--font-print); font-weight: 500; line-height: 1.8; padding: var(--space-2xs) 0; }
.sol--box b { font-weight: 700; }
.sol .ans { font-weight: 700; color: var(--color-red-ink); }
.sol__line { display: block; padding-inline-start: 1.1em; text-indent: -1.1em; }
.sol__line + .sol__line { margin-top: 0.15em; }
.sol__line--calc { font-family: var(--font-hand); font-weight: 600; color: var(--color-ink); }
/* 文章の行は、ぶら下げずにふつうに折り返す */
.sol--box .sol__line:not(.sol__line--calc) { padding-inline-start: 0; text-indent: 0; }
.note { font-size: var(--text-sm); color: var(--color-muted); line-height: 1.7; }
.note b { color: var(--color-ink); }

/* 進み具合 */
.prog { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); font-size: var(--text-sm); font-weight: 700; }
.prog__marks { display: flex; gap: 3px; }
.prog__mark { width: 0.9rem; height: 0.9rem; }
.prog__mark circle, .prog__mark path { fill: none; stroke: var(--color-rule); stroke-width: 2; stroke-linecap: round; }
.prog__mark[data-r="ok"] circle { stroke: var(--color-red); }
.prog__mark[data-r="ng"] path { stroke: var(--color-red); }
.prog__mark[data-r="near"] path { stroke: var(--color-red); }

/* 札 */
.card {
  --cw: 3.6rem;
  position: relative; flex: none;
  width: var(--cw); height: calc(var(--cw) * 1.4);
  border: 1px solid var(--color-rule); border-radius: calc(var(--cw) * 0.08);
  background: var(--color-card);
  box-shadow: 0 1px 2px var(--color-shadow);
  color: var(--color-ink);
  font-family: var(--font-print); font-weight: 700; line-height: 1;
}
.card--red { color: var(--color-red-ink); }
.card__rank { position: absolute; inset-block-start: calc(var(--cw) * 0.08); inset-inline-start: calc(var(--cw) * 0.1); font-size: calc(var(--cw) * 0.36); letter-spacing: -0.04em; }
.card__pip { position: absolute; inset-block-start: calc(var(--cw) * 0.48); inset-inline-start: calc(var(--cw) * 0.1); width: calc(var(--cw) * 0.24); height: calc(var(--cw) * 0.24); }
.card__big { position: absolute; inset-inline-end: calc(var(--cw) * 0.1); inset-block-end: calc(var(--cw) * 0.1); width: calc(var(--cw) * 0.5); height: calc(var(--cw) * 0.5); }
.card svg { display: block; width: 100%; height: 100%; fill: currentColor; }
.card--down { background-color: var(--color-paper-2); background-image: repeating-linear-gradient(45deg, var(--color-rule) 0 1px, transparent 1px 6px), repeating-linear-gradient(-45deg, var(--color-rule) 0 1px, transparent 1px 6px); }
.card--lg { --cw: 6.5rem; }
.card--md { --cw: 4.4rem; }
.card--sm { --cw: 2.6rem; }
.card--xs { --cw: 2rem; }
.card__tag { position: absolute; inset-inline: 0; inset-block-end: -1.5em; text-align: center; font-family: var(--font-hand); font-weight: 600; font-size: var(--text-sm); color: var(--color-red-ink); white-space: nowrap; }
.card.is-in { animation: card-in var(--dur-short) var(--ease-out) both; }
@keyframes card-in { from { transform: translate(0.6rem, -0.9rem) rotate(4deg); } to { transform: none; } }
.hand-cards { display: flex; align-items: flex-start; }
.hand-cards .card + .card { margin-inline-start: calc(var(--cw) * -0.52); }
.hand-cards--open .card + .card { margin-inline-start: var(--space-xs); }

/* 目次 */
.cover { padding-top: var(--space-md); }
.cover__title { font-family: var(--font-hand); font-weight: 600; font-size: clamp(1.7rem, 8vw, 2.9rem); line-height: 1.15; letter-spacing: 0.01em; }
.cover__sub { font-size: var(--text-sm); font-weight: 700; color: var(--color-muted); margin-top: var(--space-xs); }
.cover__top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-sm); align-items: start; }
/* ノートに貼った写真 */
.cover__pic { display: block; width: clamp(4.5rem, 24vw, 6.5rem); height: auto; border: 0.3rem solid var(--color-card); box-shadow: 0 1px 3px var(--color-shadow), 0 0 0 1px var(--color-rule); transform: rotate(4deg); margin-top: var(--space-2xs); margin-inline-end: var(--space-2xs); }
.cover__art { margin: var(--space-sm) 0 0; }
.cover__art svg { display: block; width: 100%; height: auto; }
.toc { margin-top: var(--space-lg); border-top: var(--rule-ink) solid var(--color-ink); }
.toc__row {
  display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; align-items: baseline; column-gap: var(--space-xs);
  padding: var(--space-sm) 0; min-height: 3.75rem;
  border-bottom: var(--rule-thin) solid var(--color-rule);
  color: var(--color-ink); text-decoration: none; background: var(--color-paper);
}
.toc__no { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); white-space: nowrap; }
.toc__name { font-family: var(--font-hand); font-weight: 600; font-size: clamp(1rem, 5.4vw, var(--text-xl)); line-height: 1.3; white-space: nowrap; }
.toc__desc { grid-column: 2 / -1; font-size: var(--text-sm); color: var(--color-muted); line-height: 1.5; }
.toc__mark { font-family: var(--font-hand); font-weight: 400; font-size: var(--text-sm); color: var(--color-pencil); white-space: nowrap; }
.toc__row:active { background: var(--color-paper-2); }
@media (hover: hover) and (pointer: fine) {
  .toc__row:hover .toc__name { color: var(--color-blue); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }
}
.toc__group { padding: var(--space-md) 0 var(--space-2xs); font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); background: var(--color-paper); border-bottom: var(--rule-thin) solid var(--color-rule); }

/* 条件の札（いまの設定） */
.cond { border: var(--rule-ink) solid var(--color-ink); background: var(--color-paper); padding: var(--space-sm) var(--space-md); }
.cond__title { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); }
.cond__line { font-weight: 700; font-size: var(--text-md); line-height: 1.6; }
.cond__line--sub { font-weight: 500; font-size: var(--text-sm); color: var(--color-pencil); }

/* 今日の練習（目次の上）: 続けた日数・今日のメニュー・この2週間 */
.todayblk { margin-top: var(--space-md); display: grid; gap: var(--space-xs); background: var(--color-paper); }
.today { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-lg); color: var(--color-red-ink); line-height: 1.5; }
.menu__title { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); margin-top: var(--space-2xs); }
.menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); }
.menu__item { display: grid; justify-items: center; gap: 2px; padding: var(--space-xs) var(--space-2xs); min-height: 5.2rem; border: var(--rule-ink) solid var(--color-ink); border-radius: var(--radius-md); background: var(--color-paper); color: var(--color-ink); text-decoration: none; text-align: center; }
.menu__item:active { background: var(--color-paper-2); }
.menu__mark { width: 1.7rem; height: 1.7rem; fill: none; stroke: var(--color-rule); stroke-width: 2; }
.menu__item.is-done .menu__mark { stroke: var(--color-red); stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 1; animation: draw var(--dur-long) var(--ease-out) backwards; }
.menu__name { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-lg); line-height: 1.2; white-space: nowrap; }
.menu__n { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); white-space: nowrap; }
.menu__item.is-done .menu__n { color: var(--color-red-ink); }
@media (hover: hover) and (pointer: fine) { .menu__item:hover .menu__name { color: var(--color-blue); } }
.menu__done a { color: var(--color-blue); font-weight: 700; }
.week__svg { display: block; width: 100%; height: auto; }
.week__base { stroke: var(--color-ink); stroke-width: 1; }
.week__bar { fill: var(--color-pencil); }
.week__bar.is-today { fill: var(--color-red); }
.week__text { font-family: var(--font-print); font-size: 12px; font-weight: 700; fill: var(--color-muted); }

/* 章のはじめの「やり方」 */
.howto__steps { display: grid; gap: var(--space-xs); margin-bottom: var(--space-sm); }
.howto__steps li { font-size: var(--text-md); line-height: 1.7; padding-inline-start: 1.2em; text-indent: -1.2em; }

/* 条件: 保存の知らせ */
.saved { margin-bottom: var(--space-sm); min-height: 1.7em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--dur-short) var(--ease-out); }
.saved.is-on { color: var(--color-blue); font-weight: 700; }

/* 文字を大きく（条件の「文字の大きさ」）。文字と部品は rem で決めてあるので、根元を上げればそろって大きくなる */
html.big-text { font-size: 112.5%; }

/* 表（賭け金表・基本戦略表） */
.tbl { width: 100%; border-collapse: collapse; background: var(--color-paper); font-size: var(--text-md); }
.tbl th, .tbl td { padding: 0.32rem 0.2rem; border-bottom: var(--rule-thin) solid var(--color-rule); text-align: right; white-space: nowrap; }
.tbl th { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); border-bottom: var(--rule-ink) solid var(--color-ink); }
.tbl td:first-child, .tbl th:first-child { text-align: left; }
.tbl .hand { font-size: var(--text-md); }
.tbl tr.is-min td { color: var(--color-pencil); }
.tbl td.tbl__note { font-size: var(--text-sm); color: var(--color-muted); white-space: normal; }
.tbl--simple td { font-size: var(--text-lg); padding-block: 0.4rem; }
.tbl--simple .bet { font-size: var(--text-lg); }
/* 表の前に置く結論 */
.leadbox { background: var(--color-paper); border-inline-start: 3px solid var(--color-red); padding: var(--space-xs) var(--space-sm); font-size: var(--text-md); font-weight: 500; line-height: 1.8; }
.leadbox b { font-weight: 700; color: var(--color-red-ink); }
.tbl tr.is-now td { background: var(--color-blue-wash); }
.tbl .bet { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-md); color: var(--color-ink); }
.bar { display: inline-block; height: 0.5rem; background: var(--color-pencil); vertical-align: middle; border-radius: 1px; }

.chart { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--color-paper); font-size: var(--text-sm); font-weight: 700; }
.chart th, .chart td { border: 1px solid var(--color-rule); text-align: center; padding: 0; height: 1.9rem; }
.chart th { color: var(--color-muted); font-size: var(--text-xs); }
.chart th:first-child { width: 2.6rem; }
.chart td[data-a="H"] { background: var(--color-paper); color: var(--color-pencil); }
.chart td[data-a="S"] { background: var(--color-ink); color: var(--color-paper); }
.chart td[data-a="D"] { background: var(--color-blue-wash); color: var(--color-blue); }
/* Ds（できなければスタンド）は斜線で D と見分ける */
.chart td[data-a="Ds"] { background: repeating-linear-gradient(135deg, var(--color-blue-wash) 0 4px, var(--color-paper) 4px 7px); color: var(--color-blue); }
.chart td[data-a="P"] { background: var(--color-blue); color: var(--color-paper); }
.chart td[data-a="R"], .chart td[data-a="Rs"], .chart td[data-a="Rp"] { background: var(--color-red-wash); color: var(--color-red-ink); }
.chart td.is-dev { box-shadow: inset 0 0 0 2px var(--color-red); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-sm); font-size: var(--text-sm); font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: var(--space-2xs); white-space: nowrap; }
.legend i { display: inline-block; width: 1rem; height: 1rem; border: 1px solid var(--color-rule); }

/* 見出し */
.sec { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-xl); line-height: 1.4; margin-top: var(--space-lg); background: var(--color-paper); display: inline-block; padding-inline-end: var(--space-xs); }
.block { background: var(--color-paper); }
.lead { font-size: var(--text-md); line-height: 1.8; background: var(--color-paper); }

/* 設定の入力 */
.field { display: grid; gap: var(--space-2xs); }
.field__label { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); }
.field__hint { font-size: var(--text-sm); color: var(--color-muted); line-height: 1.6; }
.input {
  width: 100%; min-height: 3rem; padding: 0 var(--space-sm);
  border: var(--rule-ink) solid var(--color-ink); border-radius: var(--radius-md);
  background: var(--color-paper); font-weight: 700; font-size: 1rem;
  font-family: var(--font-hand); color: var(--color-blue);
}
.input::placeholder { color: var(--color-faint); }
.input[aria-invalid="true"] { border-color: var(--color-red); }
.input:disabled { color: var(--color-faint); border-color: var(--color-rule); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; border: var(--rule-ink) solid var(--color-ink); border-radius: var(--radius-md); overflow: hidden; background: var(--color-paper); }
.seg button {
  min-height: 2.75rem; padding: 0 var(--space-2xs); border: 0; border-inline-start: var(--rule-thin) solid var(--color-rule);
  background: none; font-weight: 700; font-size: var(--text-sm); white-space: nowrap; color: var(--color-pencil);
}
.seg button:first-child { border-inline-start: 0; }
.seg button[aria-pressed="true"] { background: var(--color-ink); color: var(--color-paper); }
.seg button:disabled { color: var(--color-faint); cursor: not-allowed; }
.seg button:active:not(:disabled):not([aria-pressed="true"]) { background: var(--color-paper-2); }
@media (hover: hover) and (pointer: fine) { .seg button:hover:not(:disabled):not([aria-pressed="true"]) { background: var(--color-paper-2); } }
/* 折り返す切り替え: 最後の段も横いっぱいに伸ばして、空きマスを作らない。端の罫線は枠の外へ逃がす */
.seg--wrap { display: flex; flex-wrap: wrap; }
.seg--wrap button { flex: 1 0 4.2rem; border-block-start: var(--rule-thin) solid var(--color-rule); border-inline-start: var(--rule-thin) solid var(--color-rule); margin-block-start: -1px; margin-inline-start: -1px; }
.seg--wide { grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); }

/* 資金の推移グラフ */
.plot { background: var(--color-paper); }
.plot svg { display: block; width: 100%; height: auto; }
.plot__axis { stroke: var(--color-ink); stroke-width: 1.5; fill: none; }
.plot__grid { stroke: var(--color-rule); stroke-width: 1; stroke-dasharray: 2 3; }
.plot__path { fill: none; stroke: var(--color-pencil); stroke-width: 1; opacity: 0.25; }
.plot__path--dead { stroke: var(--color-red); opacity: 0.45; }
.plot__path--mid { stroke: var(--color-ink); stroke-width: 2.2; opacity: 1; }
.plot__text--start { font-size: 13px; fill: var(--color-blue); }
.plot__text { font-family: var(--font-print); font-size: 11.5px; font-weight: 700; fill: var(--color-muted); paint-order: stroke; stroke: var(--color-paper); stroke-width: 3px; stroke-linejoin: round; }
.plot__start { stroke: var(--color-blue); stroke-width: 1.5; stroke-dasharray: 4 3; }

/* 数字で見せる要約 */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm) var(--space-md); background: var(--color-paper); }
.stat__k { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); line-height: 1.4; }
.stat__v { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-2xl); line-height: 1.15; white-space: nowrap; }
.stat__v small { font-family: var(--font-print); font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); }
.stat--alert .stat__v { color: var(--color-red-ink); }

/* 捨て札置き場（残りデッキを目で読む） */
.tray svg { display: block; width: 100%; height: auto; }
.tray__box { fill: none; stroke: var(--color-ink); stroke-width: 1.5; stroke-linejoin: round; }
.tray__stack { fill: var(--color-card); stroke: var(--color-pencil); stroke-width: 1; }
.tray__edge { stroke: var(--color-rule); stroke-width: 0.6; }
.tray__mark { stroke: var(--color-pencil); stroke-width: 1; }
.tray__mark--whole { stroke: var(--color-ink); stroke-width: 1.5; }
.tray__text { font-family: var(--font-print); font-size: 13px; font-weight: 700; fill: var(--color-pencil); }
.tray__text--ink { fill: var(--color-red-ink); }
.tray__half { font-family: var(--font-print); font-size: 12px; font-weight: 700; fill: var(--color-muted); }
.tray__mini { font-family: var(--font-print); font-size: 12px; font-weight: 700; fill: var(--color-muted); }

/* 実戦の卓 */
.felt { position: relative; background: var(--color-paper); border: var(--rule-ink) solid var(--color-ink); padding: var(--space-sm); min-height: 19rem; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--space-xs); }
.felt__dealer { display: grid; grid-template-columns: minmax(0, 1fr) 4.2rem; gap: var(--space-sm); align-items: start; }
.felt__label { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); white-space: nowrap; }
.felt__total { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-md); color: var(--color-pencil); white-space: nowrap; min-height: 1.6em; }
.felt__seats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-xs); align-items: start; }
.seat { min-width: 0; display: grid; gap: var(--space-3xs); justify-items: start; }
.seat--bot { opacity: 0.92; }
.seat__hands { display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-md); align-items: flex-end; min-height: 3.7rem; }
.seat__hand { position: relative; display: grid; gap: 2px; justify-items: start; padding: 2px; border-radius: var(--radius-md); }
.seat__hand.is-turn { outline: 2px dashed var(--color-blue); outline-offset: 3px; }
.seat__res { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-sm); white-space: nowrap; min-height: 1.5em; }
.seat__res[data-r="win"], .seat__res[data-r="bj"] { color: var(--color-red-ink); }
.seat__bet { font-size: var(--text-sm); font-weight: 700; color: var(--color-pencil); white-space: nowrap; }
.seat--me .seat__res { font-size: var(--text-lg); }
.hud { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs) var(--space-md); background: var(--color-paper); border-bottom: var(--rule-thin) solid var(--color-rule); padding-bottom: var(--space-xs); }
.hud .fact__v { font-size: var(--text-lg); }
.hud__count { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-xs); }
.hud__cv { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-md); line-height: 1.35; color: var(--color-blue); min-width: 0; }
.hud__cv small { font-family: var(--font-print); font-weight: 700; font-size: var(--text-xs); color: var(--color-muted); margin-inline-start: 2px; white-space: nowrap; }
.hud__cv--off { font-family: var(--font-print); font-weight: 700; font-size: var(--text-sm); color: var(--color-muted); }
.log { font-family: var(--font-print); font-size: var(--text-md); color: var(--color-pencil); line-height: 1.6; background: var(--color-paper); min-height: 1.6em; margin-block: var(--space-xs); }
.log p + p { margin-top: var(--space-3xs); }
.log__res { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-xl); color: var(--color-ink); line-height: 1.3; }
.log__ok { font-weight: 700; color: var(--color-red-ink); }
.log__miss { font-weight: 700; color: var(--color-red-ink); padding-inline-start: 1em; text-indent: -1em; }
.log__miss::before { content: "× "; }
.log__note { color: var(--color-ink); font-weight: 700; }

/* 下から出る紙（問い合わせ・確認） */
.sheet-wrap { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; align-items: end; justify-items: center; background: var(--color-shade); padding: var(--space-md); padding-bottom: max(var(--space-md), env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet { width: 100%; max-width: 30rem; background: var(--color-paper); border: var(--rule-ink) solid var(--color-ink); padding: var(--space-md); display: grid; gap: var(--space-sm); animation: sheet-in var(--dur-short) var(--ease-out) both; }
@keyframes sheet-in { from { transform: translateY(1rem); } to { transform: none; } }
.sheet__title { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-xl); }
.textarea { width: 100%; min-height: 7rem; padding: var(--space-sm); border: var(--rule-ink) solid var(--color-ink); border-radius: var(--radius-md); background: var(--color-paper); font-family: var(--font-hand); font-size: 1rem; line-height: 1.6; resize: vertical; }

/* ページの下 */
.foot { margin-top: var(--space-xl); padding-top: var(--space-sm); border-top: var(--rule-thin) solid var(--color-rule); background: var(--color-paper); display: grid; gap: var(--space-xs); font-size: var(--text-sm); }
.foot__rakko { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 2.75rem; color: var(--color-ink); text-decoration: none; font-weight: 700; white-space: nowrap; }
.foot__rakko img { width: 2rem; height: 2rem; border-radius: 22%; }
.foot__links { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-md); }
.foot__links button, .foot__links a { min-height: 2.75rem; padding: 0; border: 0; background: none; color: var(--color-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 0.25em; white-space: nowrap; display: inline-flex; align-items: center; }
.foot__small { font-size: var(--text-xs); color: var(--color-muted); line-height: 1.7; }

.loading { padding: var(--space-xl) 0; font-family: var(--font-hand); color: var(--color-pencil); background: var(--color-paper); }
.err { border: var(--rule-ink) solid var(--color-red); background: var(--color-paper); padding: var(--space-md); color: var(--color-red-ink); font-weight: 700; }

/* 数える: 札が1枚ずつ出る舞台 */
.stage { display: grid; place-items: center; min-height: 11.5rem; gap: var(--space-sm); background: var(--color-paper); border: var(--rule-ink) solid var(--color-ink); padding: var(--space-md); }
.stage__cards { display: flex; gap: var(--space-sm); min-height: 9.1rem; align-items: center; }
.stage__count { font-size: var(--text-lg); font-weight: 700; color: var(--color-ink); }
.stage__cards { transition: transform var(--dur-micro) var(--ease-out); }
.review { display: flex; flex-wrap: wrap; gap: 2rem var(--space-xs); padding-bottom: 1.7rem; background: var(--color-paper); }
.review .card__tag { font-size: var(--text-md); }

/* 最初の表示だけ、上から順に出す */
.reveal > * { animation: reveal var(--dur-long) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 50ms); }
@keyframes reveal { from { transform: translateY(8px); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .verdict__mark path { animation: none; }
}
@media (pointer: coarse) { .btn--small { min-height: 2.75rem; } }

/* 相手の札と自分の手 */
.tableau { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-lg); align-items: start; }
.tableau__side { display: grid; gap: var(--space-2xs); min-width: 0; }
.tableau .hand-cards { flex-wrap: wrap; row-gap: var(--space-xs); }

/* 出題の設定（開閉） */
.opts { background: var(--color-paper); border-bottom: var(--rule-thin) solid var(--color-rule); margin-bottom: var(--space-xs); }
.opts__toggle { width: 100%; min-height: 2.75rem; display: flex; align-items: center; gap: var(--space-xs); padding: 0; border: 0; background: none; font-size: var(--text-sm); font-weight: 700; color: var(--color-ink); text-align: start; white-space: nowrap; }
.opts__toggle::before { content: ""; width: 0.5rem; height: 0.5rem; border-right: 2px solid var(--color-ink); border-bottom: 2px solid var(--color-ink); transform: rotate(-45deg); transition: transform var(--dur-micro) var(--ease-out); flex: none; margin-inline: 0.2rem 0.3rem; }
.opts__toggle[aria-expanded="true"]::before { transform: rotate(45deg); }
.opts__toggle:active { background: var(--color-paper-2); }
.opts__body { padding-bottom: var(--space-sm); }

/* 画面を切り替えた直後は、前の画面への2度押しが新しい画面のボタンに当たらないようにする */
.page.is-guard { pointer-events: none; }

/* 数え方の見本 */
.legendrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); margin-block: var(--space-sm); }
.legendrow > div { display: grid; gap: var(--space-2xs); justify-items: start; font-size: var(--text-sm); line-height: 1.4; }
.legendrow .hand-cards--open .card + .card { margin-inline-start: var(--space-3xs); }

.chart__cap { caption-side: top; text-align: left; font-family: var(--font-hand); font-weight: 600; font-size: var(--text-md); padding: var(--space-sm) 0 var(--space-2xs); background: var(--color-paper); color: var(--color-ink); }
.chart-swatch[data-a="H"] { background: var(--color-paper); }
.chart-swatch[data-a="S"] { background: var(--color-ink); }
.chart-swatch[data-a="D"] { background: var(--color-blue-wash); border-color: var(--color-blue); }
.chart-swatch[data-a="Ds"] { background: repeating-linear-gradient(135deg, var(--color-blue-wash) 0 3px, var(--color-paper) 3px 5px); border-color: var(--color-blue); }
.chart-swatch--dev { background: var(--color-paper); box-shadow: inset 0 0 0 2px var(--color-red); border-color: var(--color-red); }
.chart-swatch[data-a="P"] { background: var(--color-blue); }
.chart-swatch[data-a="R"], .chart-swatch[data-a="Rs"], .chart-swatch[data-a="Rp"] { background: var(--color-red-wash); border-color: var(--color-red); }

/* 実戦の卓: 追加 */
.felt__tray svg { display: block; width: 100%; height: auto; }
.felt__me { border-top: var(--rule-thin) dashed var(--color-rule); padding-top: var(--space-xs); }
.seat--me .seat__hands { min-height: 5.6rem; }
.hud__eye { min-height: 2.75rem; padding-inline: var(--space-sm); gap: var(--space-2xs); font-size: var(--text-sm); }
.hud__eye svg { width: 1.1rem; height: 1.1rem; flex: none; }
.ctl { min-height: 9.5rem; align-content: start; }
/* 客の札も、数字とマークが両方見えるくらいに重ねる */
.seat--bot .hand-cards .card + .card { margin-inline-start: calc(var(--cw) * -0.25); }
/* 縦の短い画面では卓を詰めて、カウントから「賭ける」までを1画面に近づける */
@media (max-height: 820px) {
  .felt { min-height: 15rem; }
  .seat--me .seat__hands { min-height: 4.4rem; }
}
.ctl.is-guard { pointer-events: none; }

.legendrow__k { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); white-space: nowrap; }
.legendrow__v { font-size: var(--text-2xl); line-height: 1; }

/* 問い合わせ欄（共通部品 rakko-contact.js）をノートの見た目に合わせる */
body .rkc-wrap { background: var(--color-shade); -webkit-backdrop-filter: none; backdrop-filter: none; align-items: flex-end; z-index: var(--z-modal); }
body .rkc-card { max-width: 30rem; border-radius: 0; background: var(--color-paper); color: var(--color-ink); border: var(--rule-ink) solid var(--color-ink); box-shadow: none; }
body .rkc-title { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-xl); }
body .rkc-label { font-size: var(--text-sm); }
body .rkc-body, body .rkc-note { color: var(--color-muted); font-size: var(--text-xs); }
body .rkc-ta { border: var(--rule-ink) solid var(--color-ink); border-radius: var(--radius-md); background: var(--color-paper); color: var(--color-blue); font-family: var(--font-hand); font-size: 1rem; }
body .rkc-ta:focus { outline: 2px solid var(--color-focus); outline-offset: 2px; border-color: var(--color-ink); }
body .rkc-btn { border-radius: var(--radius-md); min-height: 3rem; font-size: var(--text-md); }
body .rkc-btn.primary { background: var(--color-ink); color: var(--color-paper); }
body .rkc-btn.primary:disabled { background: var(--color-faint); }
body .rkc-btn.ghost { background: var(--color-paper); color: var(--color-ink); border: var(--rule-ink) solid var(--color-ink); }
body .rkc-status { color: var(--color-red-ink); font-size: var(--text-sm); }
body .rkc-link { color: var(--color-ink); font-size: var(--text-sm); min-height: 2.75rem; }

/* 広告（区切りの画面のいちばん下）。ボタンから離し、「広告」と書く。付かなかったら箱ごと隠す */
.ad-box { margin-top: var(--space-xl); padding-top: var(--space-xs); border-top: var(--rule-thin) solid var(--color-rule); background: var(--color-paper); min-width: 0; }
.ad-box__label { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); margin-bottom: var(--space-2xs); }
.ad-box:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }

/* 賭け金表を1行に（いまのカウントに赤丸） */
.rampstrip { display: flex; flex-wrap: wrap; gap: var(--space-2xs) 0; background: var(--color-paper); border-top: var(--rule-ink) solid var(--color-ink); border-bottom: var(--rule-thin) solid var(--color-rule); padding: var(--space-2xs) 0; }
.rampstrip__cell { flex: 1 0 auto; display: grid; justify-items: center; gap: 0; padding: var(--space-3xs) 0.3rem; min-width: 2.7rem; border-inline-end: var(--rule-thin) solid var(--color-rule); }
.rampstrip__cell:last-child { border-inline-end: 0; }
.rampstrip__tc { font-size: var(--text-xs); font-weight: 700; color: var(--color-muted); white-space: nowrap; line-height: 1.5; }
.rampstrip__bet { font-family: var(--font-hand); font-weight: 600; font-size: var(--text-md); line-height: 1.3; white-space: nowrap; }
.rampstrip__cell.is-now { outline: 2px solid var(--color-red); outline-offset: -2px; border-radius: 999px; border-inline-end-color: transparent; }
.rampstrip__cell.is-now .rampstrip__bet { color: var(--color-red-ink); }
/* 段が多いときは詰めて、1行に収める */
.rampstrip--dense .rampstrip__cell { min-width: 0; padding-inline: 0.12rem; }
.rampstrip--dense .rampstrip__bet { font-size: var(--text-sm); }
