/* ==========================================================================
   HALVE — 生成りの裁ち台 × 墨 × 藍／朱 × 真鍮
   デザイン原本: design/juice/halve.html（色・書体・罫線・面構成はここから写す）
   モバイル (<900px): 100dvh 縦 flex（上=温灰の帯 / 下=生成りの紙）
   PC (>=900px): 温灰の地に 盤面 + 340px の紙パネルの2カラム
   hover 依存の情報は作らない（:active と :focus-visible のみ）。
   ========================================================================== */

:root {
  /* --- Juice 原本のトークン --- */
  --ground-band: #d6d4d3;     /* 上段の温灰の帯 */
  --ground-paper: #fbfaf8;    /* 生成りの紙（下段・リザルト地） */
  --surface-mat: #fafaf7;     /* 裁ち台・カード・ピル */
  --ink: #282825;
  --ink-ctrl: #292926;        /* 主ボタン・スタンプ */
  --ink-muted: #777777;
  --ink-subtle: #92928d;
  --ink-light: #f9f9f7;

  --border-pill: #d4d2d0;
  --border-pill-active: #c9c8c4;
  --dot-active: #45453f;
  --arrow-glyph: #30302b;

  --mat-grid: #ecebe7;
  --mat-frame: #e4e3de;
  --mat-cross: #5c5c57;
  --mat-corner: #62625d;
  --mat-shadow: rgba(169, 167, 163, 0.55);

  --cut-hairline: #35352f;    /* 糸・自分の切り線 */
  --handle-rim: #4a4a44;
  --gold: #b68d40;            /* 金の正解線 */

  --cut-l: #263c5a;           /* 切片 左: 藍ベタ */
  --cut-l-edge: #1e3048;
  --cut-r: #d96236;           /* 切片 右: 朱の 45° ハッチ */
  --cut-r-edge: #c5542b;
  --cut-r-bg: #f6dfd4;

  --card-border: #e7e5e1;
  --row-divider: #e4e4e0;
  --dist-border: #deddd8;
  --well: #f2f1ee;            /* 済ピル・押下・連続記録の面 */
  --track: #efeeea;           /* セグメント切替の溝 */

  --rank-s: #8a6a2c;          /* 総合 S: 真鍮（紙上で可読コントラスト） */
  --rank-a: #263c5a;          /* 総合 A / 自分: 藍 */
  --rank-b: #4a6b8a;          /* 総合 B: 藍鼠 */
  --rank-c: #8a6d4a;          /* 総合 C: 渋茶 */
  --rank-d: #9a4a4a;          /* 総合 D: 臙脂 */
  --stamp-dot: #6cc27d;

  /* --- 役割への割り当て --- */
  --shape-a: #efede7;         /* 紙の図形 */
  --shape-b: #dedcd6;         /* 二枚目の紙（+ A/B 刻印） */
  --shape-edge: #35352f;
  --pin: #3a3a36;
  --pin-core: #d6d4d3;
  --warn: #d96236;            /* 鉄芯接触・無効糸 */
  --ghost: #9a4a4a;           /* 相手ゴースト線 */

  --rank-exact: #b68d40;
  --rank-perfect: #263c5a;
  --rank-great: #4a6b8a;
  --rank-good: #6c8399;
  --rank-ok: #8a6d4a;
  --rank-miss: #92928d;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --pad-x: 16px;
  --dist-h: 126px;

  --font: Arimo, "Helvetica Neue", Helvetica, Arial, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Noto Serif JP", "Noto Serif CJK JP", "Hiragino Mincho ProN", "Yu Mincho", YuMincho,
    "Songti SC", "Noto Serif SC", "SimSun", serif;

  color-scheme: light;
}

/* ---------- リセット ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  height: 100%;
  background: var(--ground-paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ground-paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; padding: 0; }
ol, ul { list-style: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
button:disabled { cursor: default; }

a { color: inherit; }
a, [role="button"] { touch-action: manipulation; }

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

.tnum { font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.ico {
  width: 16px;
  height: 16px;
  fill: none;
  flex: none;
}
.ico-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- アプリ枠 ---------- */
.app {
  --banner-h: 0px;
  --board: max(240px, min(100vw - 32px, 100vh - 282px - var(--banner-h) - var(--safe-b)));
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--ground-paper);
  transition: opacity 80ms ease-out;
}
@supports (height: 100dvh) {
  .app { --board: max(240px, min(100vw - 32px, 100dvh - 282px - var(--banner-h) - var(--safe-b))); }
}
.app:has(> .banner:not([hidden])) { --banner-h: 28px; }
.app:has(> .banner[data-kind="tutorial"]:not([hidden])) { --banner-h: 64px; }
.app[data-ready="false"] { opacity: 0; }

.view {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: none;
  padding: 0 var(--pad-x);
}
.app[data-view="home"] > .view-home { display: flex; }
.app[data-view="play"] > .view-play { display: grid; }
.app[data-view="challenge"] > .view-challenge { display: flex; }
.app[data-view="summary"] > .view-summary { display: flex; }

/* ---------- ヘッダー (48px) ---------- */
.hdr {
  position: relative;
  z-index: 20;
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 var(--pad-x);
  min-width: 0;
}
/* 紙の上のヘッダーは下罫線で仕切る（プレイ中は温灰の帯に溶け込む） */
.hdr::after {
  content: "";
  position: absolute;
  left: var(--pad-x);
  right: var(--pad-x);
  bottom: 0;
  border-bottom: 1px solid var(--row-divider);
}
.app[data-view="play"] > .hdr { background: var(--ground-band); }
.app[data-view="play"] > .hdr::after { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
}
/* ロゴ: 罫線で囲った箱（クリックでホームへ戻る） */
.brand-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1.6px;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease;
}
.brand-name:hover { background: rgba(40, 40, 37, 0.08); }
.brand-name:active { background: var(--ink); color: var(--surface-mat); }
.brand-sub {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: #474742;
  white-space: nowrap;
}

.badge {
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 8px;
  border: 1px solid var(--border-pill);
  border-radius: 4px;
  background: var(--surface-mat);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink);
}
.app[data-mode="ghost"] .badge { color: var(--ghost); border-color: currentColor; }

.hdr-tools {
  display: flex;
  flex: none;
}

/* 見た目は 28px の角丸、タップ領域は 40×44 */
.icon-btn {
  position: relative;
  width: 40px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--ink-ctrl);
}
.icon-btn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 6px;
  transition: background-color 150ms ease;
}
.icon-btn:active::before { background: rgba(40, 40, 37, 0.07); }
.icon-btn > * { position: relative; }
.ico-text { font-size: 15px; font-weight: 500; line-height: 1; }

#btn-mute .ico-sound-off { display: none; }
#btn-mute[aria-pressed="true"] { color: var(--ink-subtle); }
#btn-mute[aria-pressed="true"] .ico-sound-on { display: none; }
#btn-mute[aria-pressed="true"] .ico-sound-off { display: block; }

.lang-menu {
  position: absolute;
  top: 44px;
  right: 10px;
  z-index: 30;
  min-width: 136px;
  padding: 4px;
  display: grid;
  background: var(--surface-mat);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(40, 40, 37, 0.18), 0 2px 6px rgba(40, 40, 37, 0.08);
}
.lang-opt {
  height: 40px;
  padding: 0 12px 0 28px;
  position: relative;
  text-align: left;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
}
.lang-opt:active { background: var(--well); }
.lang-opt[aria-pressed="true"] { font-weight: 700; }
.lang-opt[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: var(--dot-active);
}

/* ---------- バナー（過去問 / 練習 / 明日解禁） ---------- */
.banner {
  flex: none;
  height: 28px;
  padding: 0 var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--ink);
  min-width: 0;
}
.app[data-view="play"] > .banner { background: var(--ground-band); }
.banner-mark {
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dot-active);
}
.banner-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.banner[data-kind="tomorrow"] .banner-mark { background: var(--gold); }
.banner[data-kind="tomorrow"] .banner-text { font-weight: 700; }
.banner[data-kind="tutorial"],
.app[data-view="play"] > .banner[data-kind="tutorial"] {
  height: auto;
  min-height: 44px;
  padding: 6px var(--pad-x);
  align-items: flex-start;
  background: var(--surface-mat);
  border-bottom: 1px solid var(--row-divider);
}
.banner[data-kind="tutorial"] .banner-mark {
  margin-top: 6px;
  background: var(--gold);
}
.banner[data-kind="tutorial"] .banner-text {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}

/* ==========================================================================
   ホームビュー（チュートリアル / 今日の一本 / フリープレイ）
   ========================================================================== */
.view-home {
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding-top: 16px;
  padding-bottom: 20px;
}
.home-inner {
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.home-seal {
  width: 44px;
  height: 44px;
}
.home-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1.1;
  color: var(--ink);
  padding-left: 0.16em;
}
.home-tagline {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.4;
}
.home-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.home-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 16px;
  text-align: left;
  background: var(--surface-mat);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: var(--ink);
  transition: border-color 140ms ease, background-color 140ms ease, transform 100ms ease;
}
.home-card:hover { border-color: var(--border-pill-active); background: var(--well); }
.home-card:active { transform: translateY(1px); }
.home-card.is-primary {
  background: var(--ink-ctrl);
  border-color: var(--ink-ctrl);
  color: var(--surface-mat);
}
.home-card.is-primary:hover { background: #1c1c19; border-color: #1c1c19; }
.home-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.home-card-title-row {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}
.home-card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.25;
}
.home-card-sub {
  font-size: 12px;
  opacity: 0.72;
}
.home-card-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-muted);
}
.home-card.is-primary .home-card-desc {
  color: rgba(251, 250, 248, 0.78);
}
.home-pill {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--track);
  color: var(--ink-ctrl);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.home-pill[data-tone="gold"] {
  background: rgba(168, 126, 34, 0.16);
  color: #7c5b10;
}
.home-pill[data-tone="done"] {
  background: rgba(48, 93, 134, 0.12);
  color: var(--cut-l);
}
.home-card.is-primary .home-pill {
  background: rgba(251, 250, 248, 0.18);
  color: var(--surface-mat);
}
.home-card.is-primary .home-pill[data-tone="gold"] {
  background: var(--gold);
  color: #1c1a15;
}

/* ==========================================================================
   プレイビュー
   375×667: hdr 48 + [pips 36 + topic 44 + 盤面 343 + 帯下 14 + status 40 + actions 60] + ftr 40 = 625px
   ========================================================================== */
.view-play {
  padding: 0;
  touch-action: none;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 36px 44px auto 40px 60px;
  grid-template-areas:
    "pips"
    "topic"
    "board"
    "status"
    "actions";
  align-content: start;
}
.pips { grid-area: pips; }
.topic { grid-area: topic; touch-action: none; }
.board-cell { grid-area: board; }
.status { grid-area: status; touch-action: none; }
.actions { grid-area: actions; }
.keys { grid-area: keys; display: none; }

.pips,
.topic,
.board-cell { background: var(--ground-band); }
.pips,
.topic,
.status,
.actions { padding-inline: var(--pad-x); }

/* ---------- 問題インジケータ（角のピル） ---------- */
.pips {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  min-width: 0;
  -webkit-user-select: none;
  user-select: none;
}
.pip {
  flex: 0 1 auto;
  height: 24px;
  min-width: 46px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--surface-mat);
  border: 1px solid var(--border-pill);
  font-size: 12px;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}
.pip[data-state="current"] {
  border-color: var(--border-pill-active);
  border-radius: 5px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(40, 40, 37, 0.06);
}
.pip[data-state="current"]::before {
  content: "";
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dot-active);
}
.pip[data-state="done"] {
  --rank: var(--rank-miss);
  color: var(--ink-muted);
  background: var(--well);
}
.pip[data-state="done"]::before {
  content: "";
  flex: none;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--rank);
}
.pip[data-state="done"][data-rank="exact"] { --rank: var(--rank-exact); }
.pip[data-state="done"][data-rank="exact"]::before { box-shadow: 0 0 0 1.5px var(--well), 0 0 0 2.5px var(--rank-exact); }
.pip[data-state="done"][data-rank="perfect"] { --rank: var(--rank-perfect); }
.pip[data-state="done"][data-rank="great"] { --rank: var(--rank-great); }
.pip[data-state="done"][data-rank="good"] { --rank: var(--rank-good); }
.pip[data-state="done"][data-rank="ok"] { --rank: var(--rank-ok); }
.pip[data-state="done"][data-rank="miss"] { --rank: var(--rank-miss); }

.pip.is-compare-current {
  color: var(--ink);
  font-weight: 700;
  border-color: var(--ink);
  border-radius: 5px;
  background: var(--surface-mat);
}
.pip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- お題行 ---------- */
.topic {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  padding-top: 8px;
}
.topic-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-serif);
  font-size: clamp(15px, 4.4vw, 19px);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.04em;
}
.topic-target {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.topic-target-label {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  color: #5b5a55;
}

/* ---------- 盤面（裁ち台） ---------- */
.board-cell {
  display: grid;
  justify-items: center;
  align-items: start;
  min-width: 0;
  min-height: 0;
  padding: 0 var(--pad-x) 14px;
  touch-action: none;
}
.board-wrap {
  position: relative;
  width: var(--board);
  height: var(--board);
  flex: none;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-mat);
  box-shadow: 0 8px 20px var(--mat-shadow);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: crosshair;
}
.board:focus-visible { outline-offset: -3px; }
.app[data-phase="slashing"] .board,
.app[data-phase="result"] .board { cursor: default; }

/* SVG の中身（svg-view.js が生成する要素のクラス規約）
   注意: url(#...) 参照（pat-hatch / clip-neg / clip-pos / fx-glow）は CSS ではなく
   必ず SVG 属性（fill="url(#pat-hatch)" 等）で指定すること。 */
.board * { vector-effect: non-scaling-stroke; }

.mat-rim,
.mat { fill: var(--surface-mat); }
.mat-grid-line { fill: none; stroke: var(--mat-grid); stroke-width: 1px; }
.mat-frame { fill: none; stroke: var(--mat-frame); stroke-width: 1px; }
.mat-corner { fill: var(--mat-corner); }
.mat-cross { fill: none; stroke: var(--mat-cross); stroke-width: 1px; opacity: 0.65; }
.rail {
  fill: none;
  stroke: var(--mat-frame);
  stroke-width: 1px;
  stroke-dasharray: 2 6;
}
.hatch-base { fill: var(--cut-r-bg); }
.hatch-stripe { fill: var(--cut-r); }

.shape {
  fill: var(--shape-a);
  stroke: var(--shape-edge);
  stroke-width: 1.4px;
  stroke-linejoin: round;
  transition: fill 160ms linear, opacity 160ms linear;
}
.shape[data-shape="b"] { fill: var(--shape-b); }
.shape.is-lit { stroke: var(--shape-edge); stroke-width: 1.4px; }
.shape.is-miss { stroke: var(--warn); stroke-width: 3px; stroke-dasharray: 7 5; }
.is-dim { opacity: 0.45; }
.layer-shapes { filter: drop-shadow(0 2px 3px rgba(40, 40, 37, 0.16)); }

.shape-mark {
  fill: var(--shape-edge);
  fill-opacity: 0.46;
  font-family: var(--font-serif);
  font-size: 64px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.piece-l { fill: var(--cut-l); stroke: var(--cut-l-edge); }
.piece-r { stroke: var(--cut-r-edge); }
.piece-l,
.piece-r {
  stroke-width: 1.2px;
  stroke-linejoin: round;
}

.pin { fill: var(--pin); stroke: var(--surface-mat); stroke-width: 1.5px; }
.pin-core { fill: var(--pin-core); }
.pin-ring {
  fill: none;
  stroke: var(--warn);
  stroke-width: 2.5px;
  opacity: 0;
}
.pin-ring.is-on { opacity: 1; }
.spark { fill: var(--warn); }

/* 糸: 墨の細線。生成りの縁取りで図形の輪郭線と分離する */
.thread-case {
  fill: none;
  stroke: var(--surface-mat);
  stroke-width: 5px;
  stroke-linecap: round;
  opacity: 0.9;
}
.thread {
  fill: none;
  stroke: var(--cut-hairline);
  stroke-width: 1.8px;
  stroke-linecap: round;
}
.thread.is-ng {
  stroke: var(--warn);
  stroke-width: 2px;
  stroke-dasharray: 8 6;
}
.thread.is-tight { stroke: var(--ink); stroke-width: 1px; }
.user-cut-case {
  fill: none;
  stroke: var(--surface-mat);
  stroke-width: 4.5px;
  stroke-linecap: round;
  opacity: 0.85;
}
.user-cut-line {
  fill: none;
  stroke: var(--cut-hairline);
  stroke-width: 1.6px;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
}

.handle {
  fill: var(--surface-mat);
  stroke: var(--handle-rim);
  stroke-width: 1.8px;
}
.handle.is-active { fill: var(--ink-ctrl); stroke: var(--ink-ctrl); }
.handle.is-nudge-flash { fill: var(--gold); stroke: var(--gold); stroke-width: 2.5px; }
.handle-hit { fill: transparent; stroke: none; cursor: grab; }
.nudge-ripple {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2px;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: nudge-ripple 200ms ease-out forwards;
}

.ghost-case {
  fill: none;
  stroke: var(--surface-mat);
  stroke-width: 5.5px;
  stroke-linecap: round;
  opacity: 0.92;
}
.ghost-line {
  fill: none;
  stroke: var(--ghost);
  stroke-width: 2.4px;
  stroke-linecap: round;
  stroke-dasharray: 16 9;
}
.ghost-end { fill: var(--ghost); stroke: var(--surface-mat); stroke-width: 1.5px; }
.ghost-badge-bg { fill: var(--surface-mat); stroke: var(--ghost); stroke-width: 1.5px; }
.ghost-badge-text {
  font-family: var(--font);
  font-size: 26px;
  font-weight: 700;
  fill: var(--ghost);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* 金の正解線: 墨の細い縁取りで藍・朱ハッチ・裁ち台のどの上でも読める */
.ideal-case {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4.4px;
  stroke-linecap: round;
  opacity: 0.6;
}
.ideal-line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2.4px;
  stroke-linecap: round;
}
.ideal-line.is-fallback { stroke-dasharray: 7 6; }
.ideal-band { fill: var(--gold); fill-opacity: 0.2; stroke: none; }
.band-hatch-base { fill: var(--surface-mat); fill-opacity: 0.84; }
.band-hatch-stripe { fill: var(--gold); fill-opacity: 0.72; }
.ideal-band-in { stroke: none; pointer-events: none; }

.cut-core { fill: none; stroke: var(--ink); stroke-width: 2.5px; stroke-linecap: round; }
.cut-glow { fill: none; stroke: var(--ink); stroke-width: 9px; stroke-linecap: round; opacity: 0.22; }
.cut-core.is-gold,
.cut-glow.is-gold { stroke: var(--gold); }
.cut-glow.is-gold { opacity: 0.55; }

.pct-label,
.ghost-label,
.board-label {
  font-family: var(--font);
  font-size: 44px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
  dominant-baseline: central;
  fill: var(--ink);
  stroke: var(--surface-mat);
  stroke-width: 3.5px;
  stroke-linejoin: round;
  paint-order: stroke fill;
  pointer-events: none;
}
/* 藍の上は生成りの字、朱ハッチの上は墨の字（6px 不透明縁取りで縞・破線から浮かせる） */
.pct-label.is-l { fill: var(--surface-mat); stroke: var(--cut-l); stroke-width: 6px; }
.pct-label.is-r { fill: var(--ink); stroke: var(--cut-r-bg); stroke-width: 6px; }
.pct-label.is-dim { opacity: 0.82; }
.ghost-label { fill: var(--ghost); font-size: 38px; }
.adopt-mark { fill: var(--gold); stroke: var(--surface-mat); stroke-width: 3px; paint-order: stroke fill; }
.confetti { pointer-events: none; }
.fx-ring { pointer-events: none; }
.demo-thread-case { fill: none; stroke: var(--surface-mat); stroke-width: 5px; stroke-linecap: round; opacity: 0.9; }
.demo-thread-live { fill: none; stroke: var(--cut-hairline); stroke-width: 1.8px; stroke-dasharray: 5 6; stroke-linecap: round; opacity: 0.9; }
.demo-finger-live { fill: var(--ink); fill-opacity: 0.16; stroke: var(--handle-rim); stroke-width: 1.5px; }

/* 盤面オーバーレイ（外周帯のみ。盤面の内側には何も置かない） */
.board-flash {
  position: absolute;
  inset: 0;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
}
.hint {
  position: absolute;
  left: 50%;
  bottom: 1.6%;
  transform: translateX(-50%);
  max-width: calc(100% - 20px);
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--surface-mat);
  border: 1px solid var(--border-pill);
  box-shadow: 0 1px 2px rgba(40, 40, 37, 0.06);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* 結果スタンプ: 墨の1行ピル + ランクの点 */
.stamp {
  --stamp: var(--stamp-dot);
  position: absolute;
  left: 50%;
  top: 1.6%;
  transform: translateX(-50%);
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--ink-ctrl);
  color: var(--surface-mat);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 10px rgba(40, 40, 37, 0.22);
}
.stamp::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stamp);
}
.stamp-label { font-weight: 700; }
.stamp-off { font-variant-numeric: tabular-nums; }
.stamp-off:not(:empty)::before { content: "·"; margin-right: 6px; opacity: 0.7; }
.stamp[data-rank="exact"] { --stamp: #e2bd6e; box-shadow: 0 0 0 1.5px var(--gold), 0 3px 10px rgba(40, 40, 37, 0.22); }
.stamp[data-rank="perfect"] { --stamp: #d4ae62; }
.stamp[data-rank="great"] { --stamp: #7ba3c9; }
.stamp[data-rank="good"] { --stamp: #8fb3d6; }
.stamp[data-rank="ok"] { --stamp: #d3ad7c; }
.stamp[data-rank="miss"] { --stamp: #a9a9a4; }

/* ---------- ステータス帯 (40px) ---------- */
.status {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  height: 40px;
  padding-top: 4px;
  overflow: hidden;
}
.status-text,
.chips,
.readout { display: none; }
.status[data-state="text"] .status-text { display: block; }
.status[data-state="chips"] .chips { display: flex; }
.status[data-state="result"] .readout { display: flex; }
/* チップ未生成の間は案内文を出す */
.status[data-state="chips"]:has(.chips:empty) .status-text { display: block; }

.status-text {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.chips {
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid var(--card-border);
  background: var(--surface-mat);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink-subtle);
}
/* 実線/破線 + ✓/✗ で色に依存しない */
.chip-mark { font-weight: 500; color: var(--ink); }
.chip[data-ok="true"] { border-style: solid; border-color: var(--border-pill-active); color: var(--ink); }
.chip[data-ok="false"] { border-style: dashed; border-color: var(--border-pill-active); }
.chip[data-ok="false"] .chip-mark { color: var(--ink-muted); }
.chip[data-kind="pin"][data-ok="false"],
.chip[data-kind="pin"][data-ok="false"] .chip-mark { border-color: var(--warn); color: var(--cut-r-edge); }
.chip-mark::before { content: "–"; }
.chip[data-ok="true"] .chip-mark::before { content: "✓"; }
.chip[data-ok="false"] .chip-mark::before { content: "✗"; }

.readout {
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.readout-item { display: inline-flex; align-items: baseline; gap: 5px; }
.readout-tag { font-family: var(--font-serif); font-size: 12px; font-weight: 700; color: var(--ink-muted); }
.readout-l { color: var(--cut-l); }
.readout-r { color: var(--cut-r-edge); }
.readout-sep { color: var(--ink-subtle); font-weight: 400; }
.readout-off { font-size: 11.5px; font-weight: 500; color: var(--ink-muted); }
.readout-rival {
  font-size: 11px;
  font-weight: 500;
  color: var(--ghost);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid currentColor;
  background: var(--surface-mat);
}
.readout-item[data-adopted="true"]::after { content: "◀"; font-size: 11px; color: var(--gold); }
.readout-item[data-adopted="false"] { opacity: 0.4; }
.app[data-twin="true"] .readout { font-size: 15px; gap: 8px; }
.app[data-phase="result"] .btn-undo,
.app[data-phase="result"] .btn-nudge { display: none; }

/* ---------- アクションバー (60px / ボタン高 46px) ---------- */
.actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  height: 60px;
  padding-top: 4px;
  min-width: 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  border-radius: 6px;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  transition: transform 120ms ease, background-color 150ms ease, border-color 150ms ease;
}
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(1px); }

.btn-tool {
  flex: none;
  width: 46px;
  height: 46px;
  background: var(--surface-mat);
  border: 1px solid var(--border-pill);
  color: var(--arrow-glyph);
  font-size: 13px;
}
.btn-tool:active:not(:disabled) { background: var(--well); border-color: var(--border-pill-active); }
.btn-tool:disabled { color: #bdbcb7; border-color: var(--card-border); }
.btn-retry {
  width: auto;
  padding: 0 14px;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
}
.btn-retry[hidden] { display: none; }

.btn-slash {
  flex: 1 1 0;
  height: 46px;
  background: var(--ink-ctrl);
  border: 1px solid var(--ink-ctrl);
  color: var(--surface-mat);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.18em;
}
.btn-slash:active:not([aria-disabled="true"]) { background: #1a1a17; }
.btn-slash-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-slash[aria-disabled="true"] {
  background: var(--track);
  border-color: var(--border-pill);
  color: var(--ink-subtle);
}
.btn-slash[data-role="next"] { letter-spacing: 0.08em; }

/* ---------- フッター (40px + safe-area) ---------- */
.ftr {
  position: relative;
  flex: none;
  height: calc(40px + var(--safe-b));
  padding: 0 var(--pad-x) var(--safe-b);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
}
.ftr::before {
  content: "";
  position: absolute;
  left: var(--pad-x);
  right: var(--pad-x);
  top: 0;
  border-top: 1px solid var(--row-divider);
}
.ftr-link {
  position: relative;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-decoration: none;
}
/* 見た目はそのまま、タップ領域だけ広げる */
.ftr-link::after {
  content: "";
  position: absolute;
  inset: -10px -8px;
}
.ftr-link:active { text-decoration: underline; }
.mode-switch {
  display: inline-flex;
  gap: 4px;
  padding: 2px;
  background: var(--track);
  border-radius: 6px;
}
.mode-opt {
  position: relative;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 16px;
  color: var(--ink-ctrl);
  white-space: nowrap;
  transition: background-color 180ms ease, color 180ms ease;
}
.mode-opt::after {
  content: "";
  position: absolute;
  inset: -8px -2px;
}
@media (max-width: 359.98px) {
  .ftr { gap: 6px; }
  .mode-opt { padding: 4px 7px; font-size: 10.5px; }
}
.mode-opt[aria-pressed="true"] {
  background: var(--ink-ctrl);
  color: var(--surface-mat);
  font-weight: 500;
}

/* ==========================================================================
   カード（称号・行・分布・挑戦状）共通の面
   ========================================================================== */
.sum-hero,
.sum-rows,
.dist,
.ch-card {
  background: var(--surface-mat);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

/* ==========================================================================
   挑戦状カード / 保留画面
   ========================================================================== */
.view-challenge {
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
.ch-card {
  position: relative;
  width: min(100%, 343px);
  padding: 40px 20px 20px;
  text-align: center;
}
.ch-seal {
  position: absolute;
  top: -24px;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translateX(-50%);
}
.ch-seal-paper { fill: var(--shape-a); stroke: var(--shape-edge); stroke-width: 1.4; }
.ch-seal-cut { fill: none; stroke: var(--cut-hairline); stroke-width: 1.6; stroke-dasharray: 5 4; stroke-linecap: round; }

.ch-body { display: none; }
.view-challenge[data-kind="invite"] .ch-body[data-for="invite"],
.view-challenge[data-kind="finish-first"] .ch-body[data-for="finish-first"],
.view-challenge[data-kind="tomorrow"] .ch-body[data-for="tomorrow"] {
  display: grid;
  gap: 10px;
}
.ch-intro {
  font-size: 12px;
  font-weight: 500;
  color: var(--cut-l);
  line-height: 1.4;
}
.ch-intro[hidden] { display: none; }
.ch-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
}
.ch-total {
  display: grid;
  gap: 3px;
  justify-items: center;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ghost);
}
.ch-total-num { white-space: nowrap; }
.ch-total-grade {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
}
.ch-marks {
  font-size: 16px;
  letter-spacing: 3px;
  line-height: 1.2;
}
.ch-marks:empty { display: none; }
.ch-lead { font-size: 13px; line-height: 1.55; text-wrap: balance; }
.ch-note { font-size: 11px; line-height: 1.55; color: var(--ink-muted); text-wrap: balance; }
.ch-actions { display: grid; gap: 7px; margin-top: 8px; }
.btn-link {
  min-height: 36px;
  padding: 4px 10px;
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--ink); }

.btn-primary {
  min-height: 46px;
  padding: 6px 16px;
  background: var(--ink-ctrl);
  border: 1px solid var(--ink-ctrl);
  color: var(--surface-mat);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.btn-primary:active { background: #1a1a17; }
.btn-ghost {
  min-height: 40px;
  padding: 4px 12px;
  background: var(--surface-mat);
  border: 1px solid var(--border-pill);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 500;
}
.btn-ghost:active { background: var(--well); border-color: var(--border-pill-active); }
.btn-stack { flex-direction: column; gap: 3px; }
.btn-stack small { font-size: 10px; font-weight: 400; letter-spacing: 0.02em; opacity: 0.72; }
.btn-primary.btn-stack { min-height: 52px; }
.btn-ghost.btn-stack { min-height: 48px; }

/* ==========================================================================
   リザルト（SUMMARY）
   375×667: 48 + [10 + 72 + 167 + 126 + 28 + 46 + 40 + gap 8×4 + 7 + 10] + 40 = 626px
   ========================================================================== */
.view-summary {
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}
.sum-main,
.sum-side { display: contents; }
.view-summary > *,
.sum-main > *,
.sum-side > * { flex: none; }

/* 称号カード: 傾いた二重丸の印 + 明朝の称号 + 右にズレ計 */
.sum-hero {
  --grade: var(--ink);
  position: relative;
  height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  min-width: 0;
}
.sum-hero[data-grade="S"] { --grade: var(--rank-s); }
.sum-hero[data-grade="A"] { --grade: var(--rank-a); }
.sum-hero[data-grade="B"] { --grade: var(--rank-b); }
.sum-hero[data-grade="C"] { --grade: var(--rank-c); }
.sum-hero[data-grade="D"] { --grade: var(--rank-d); }

.sum-grade {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--grade);
  border-radius: 50%;
  transform: rotate(-16deg);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  color: var(--grade);
}
.sum-grade::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid var(--grade);
  border-radius: 50%;
  opacity: 0.7;
}
.sum-hero-text {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title total"
    "heading total";
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
}
.sum-title {
  grid-area: title;
  align-self: end;
  font-family: var(--font-serif);
  font-size: clamp(12.5px, 3.85vw, 20px);
  font-weight: 700;
  line-height: 1.32;
  padding-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sum-heading {
  grid-area: heading;
  align-self: start;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sum-total {
  grid-area: total;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  white-space: nowrap;
}
.sum-total-label { font-size: 10px; letter-spacing: 0.04em; color: var(--ink-muted); }
.sum-total-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
/* 勝敗・自己ベスト等の札: カード上辺にまたがる小さなピル */
.sum-flag {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 70%;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: var(--ground-paper);
  color: #8a6a2c;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sum-flag[data-kind="lose"] { border-color: var(--ghost); color: var(--ghost); }
.sum-flag[data-kind="draw"] { border-color: var(--border-pill); color: var(--ink-muted); }

/* 5問の台帳（チュートリアル時は 3問） */
.sum-rows {
  height: 167px;
  display: grid;
  grid-template-rows: repeat(5, 33px);
  overflow: hidden;
}
.sum-rows[data-count="3"] {
  height: auto;
  grid-template-rows: repeat(3, 36px);
}
.sum-rows[data-count="3"] .sum-row[data-index="2"] { border-bottom: 0; }
.pip[hidden],
.sum-row[hidden] { display: none; }
.sum-row {
  --rank: var(--rank-miss);
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto 38px minmax(48px, auto);
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-bottom: 1px solid var(--row-divider);
  font-size: 12px;
  min-width: 0;
}
.sum-row:last-child { border-bottom: 0; }
.sum-row[data-rank="exact"] { --rank: var(--rank-exact); }
.sum-row[data-rank="perfect"] { --rank: var(--rank-perfect); }
.sum-row[data-rank="great"] { --rank: var(--rank-great); }
.sum-row[data-rank="good"] { --rank: var(--rank-good); }
.sum-row[data-rank="ok"] { --rank: var(--rank-ok); }
.sum-row[data-rank="miss"] { --rank: var(--rank-miss); }
.sum-pip { font-weight: 700; line-height: 1; white-space: nowrap; }
.sum-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-serif);
  color: #464641;
}
.sum-split { white-space: nowrap; font-size: 11.5px; }
.sum-off { text-align: right; font-size: 11.5px; color: var(--ink-muted); white-space: nowrap; }
.sum-rank {
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--rank);
}
.sum-row[data-rank="miss"] .sum-rank { color: var(--ink-muted); font-weight: 500; }
.sum-friend { color: var(--ghost); font-weight: 500; }

.sum-cap-note {
  margin-top: 4px;
  font-size: 10px;
  color: var(--ink-muted);
  text-align: right;
}

/* ---------- 分布カード: L0/L1 二層・固定高（CLS 0） ---------- */
.dist {
  position: relative;
  height: var(--dist-h);
  border-color: var(--dist-border);
  border-radius: 10px;
  overflow: hidden;
  contain: strict;
}
.dist-layer {
  position: absolute;
  inset: 0;
  padding: 9px 12px 6px;
  display: grid;
  grid-template-rows: 18px minmax(0, 1fr) 17px 15px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms linear, visibility 0s linear 200ms;
}
.dist[data-layer="l0"] .dist-l0,
.dist[data-layer="l1"] .dist-l1 {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms linear, visibility 0s linear 0s;
}
.dist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.dist-title {
  flex: none;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
.dist-headline {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.dist-headline[data-tone="gold"] { color: var(--rank-s); }
.dist-headline[data-tone="neutral"] { color: var(--ink); }
.dist-headline[data-tone="muted"] { color: var(--ink-muted); font-weight: 500; font-size: 11px; }

/* グラフ: 12本／5本を厳密 CSS Grid で並べ、下のランク軸と列境界をピクセル完全一致させる */
.dist-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: stretch;
  gap: 4px;
  margin-top: 6px;
  padding-top: 10px;
  border-bottom: 1px solid var(--row-divider);
  min-width: 0;
}
.dist[data-bars="5"] .dist-chart {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.bar {
  --h: 0;
  position: relative;
  min-width: 0;
}
.bar-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: max(2px, calc(var(--h) * 100%));
  border-radius: 2px 2px 0 0;
  background: #b5b3ac;
}
.dist-l1 .bar-fill { background: #9aa8b8; }
.bar.is-you .bar-fill { background: var(--cut-l); }
.bar.is-you.is-retried .bar-fill { background: #b5b3ac; }
/* 自分: 藍 + ▼ / やり直し: ▽ / 中央値: ▲（色に依存しない記号） */
.bar.is-you::before {
  content: "▼";
  position: absolute;
  left: 50%;
  bottom: calc(max(2px, var(--h) * 100%) + 1px);
  transform: translateX(-50%);
  font-size: 8px;
  line-height: 1;
  color: var(--cut-l);
}
.bar.is-you.is-retried::before {
  content: "▽";
  color: var(--ink-muted);
}
.bar.is-median::after {
  content: "▲";
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  font-size: 7px;
  line-height: 1;
  color: var(--ink);
}
.dist-axis {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 13px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.dist[data-bars="5"] .dist-axis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.dist-grade-cell {
  text-align: center;
  border-right: 1px solid var(--row-divider);
  padding: 1px 0;
}
.dist-grade-cell:last-child { border-right: 0; }
.dist-note {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  font-size: 9.5px;
  line-height: 13px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dist-you { color: var(--cut-l); font-weight: 700; }
.dist-early {
  font-size: 10.5px;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.3;
  margin-top: -2px;
}

/* ---------- 同一ID プチランキング TOP 5 ---------- */
.top5 {
  padding: 9px 12px 7px;
  background: var(--surface-mat);
  border: 1px solid var(--dist-border);
  border-radius: 10px;
}
.top5[hidden] { display: none; }
.top5-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.top5-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
.top5-scope {
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.top5-list {
  display: flex;
  flex-direction: column;
}
.top5-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 2px 4px;
  border-top: 1px solid var(--row-divider);
  font-size: 11.5px;
}
.top5-row.is-self {
  background: rgba(38, 60, 90, 0.06);
  border-radius: 4px;
}
.top5-rank {
  font-weight: 700;
  color: var(--ink-muted);
  text-align: center;
}
.top5-row[data-pos="1"] .top5-rank { color: var(--rank-s); }
.top5-row[data-pos="2"] .top5-rank { color: var(--cut-l); }
.top5-row[data-pos="3"] .top5-rank { color: var(--rank-ok); }
.top5-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.top5-name {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 98px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
}
.top5-marks {
  flex: none;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.top5-score {
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.top5-you {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--cut-l);
  color: var(--surface-mat);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.top5-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid var(--border-pill);
  background: var(--surface-mat);
  color: var(--ink);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.top5-btn:hover { background: var(--well); border-color: var(--border-pill-active); }
.top5-btn:active { transform: translateY(1px); }
.top5-name-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--row-divider);
}
.top5-name-form[hidden] { display: none; }
.top5-name-input {
  flex: 1 1 0;
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid var(--border-pill);
  background: var(--ground-paper);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  user-select: text;
  -webkit-user-select: text;
}
.top5-name-input::placeholder { color: var(--ink-subtle); font-size: 11px; }
.top5-name-input:focus { outline: 2px solid var(--cut-l); outline-offset: -1px; border-color: transparent; }
.top5-name-save {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border-radius: 5px;
  background: var(--ink-ctrl);
  color: var(--surface-mat);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.top5-name-save:disabled { opacity: 0.5; }
@media (hover: none) and (pointer: coarse) {
  .top5-name-input,
  .top5-name-save { height: 40px; }
  .top5-name-input { font-size: 16px; }
  .top5-name-save { padding: 0 14px; font-size: 12px; }
}

/* 低い画面: 見出し行のみ 40px */
@media (max-width: 899.98px) and (max-height: 620px) {
  :root { --dist-h: 40px; }
  .dist-layer { padding: 0 12px; grid-template-rows: minmax(0, 1fr); }
  .dist-chart,
  .dist-axis,
  .dist-note { display: none; }
}

/* ---------- 連続記録 (28px) / シェア (46px) / 副ボタン (40px) ---------- */
.streak {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 6px;
  background: #f2f1ed;
  font-size: 11.5px;
  white-space: nowrap;
  min-width: 0;
}
.streak-mark {
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
}
.streak-current { font-weight: 700; }
.streak-max::before { content: "·"; margin-right: 8px; }

.sum-share-row {
  height: 46px;
  min-height: 46px;
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 7px;
  margin-top: 2px;
}
.sum-share-row .btn {
  height: 46px;
  min-height: 46px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sum-share-row .btn[hidden] + .btn,
.sum-share-row .btn:only-child { grid-column: 1 / -1; }
.btn-share-x .ico-x { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.btn-share .ico { width: 15px; height: 15px; }
.btn-share .ico-line { stroke-width: 2; }
.sum-sub {
  height: 40px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: -1px;
}
.sum-sub .btn {
  height: 40px;
  min-height: 40px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sum-sub .btn[hidden] + .btn,
.sum-sub .btn:only-child { grid-column: 1 / -1; }

/* ==========================================================================
   ヘルプモーダル
   ========================================================================== */
.modal {
  width: min(100vw - 24px, 460px);
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px - var(--safe-b));
  margin: auto;
  padding: 0;
  background: var(--ground-paper);
  color: var(--ink);
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 18px 42px rgba(40, 40, 37, 0.18),
    0 2px 6px rgba(40, 40, 37, 0.08),
    0 0 0 1px rgba(40, 40, 37, 0.12);
}
.modal::backdrop { background: rgba(40, 40, 37, 0.42); }
.modal[open] { display: flex; }
.modal-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}
.modal-hdr {
  position: relative;
  z-index: 2;
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 16px;
  background: var(--ground-paper);
}
.modal-hdr::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  border-bottom: 1px solid var(--row-divider);
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 12px;
  line-height: 1.6;
}
.modal-body > * { flex: none; }
.help-intro { font-size: 13px; font-weight: 500; }
.demos {
  display: grid;
  background: var(--surface-mat);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}
.demo {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--row-divider);
}
.demo:last-child { border-bottom: 0; }
.demo-svg { width: 110px; height: 66px; display: block; border-radius: 6px; }
.demo-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.demo-text p { font-size: 11.5px; color: var(--ink-muted); }
.demo-mat { fill: var(--ground-band); }
.demo-shape { fill: var(--shape-a); stroke: var(--shape-edge); stroke-width: 1; }
.demo-shape-b { fill: var(--surface-mat); }
.demo-mark {
  fill: var(--shape-edge);
  fill-opacity: 0.5;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  text-anchor: middle;
}
.demo-thread {
  fill: none;
  stroke: var(--cut-hairline);
  stroke-width: 1.6;
  stroke-linecap: round;
}
.demo-thread-draw { stroke-dasharray: 100; stroke-dashoffset: 0; }
.demo-thread-ng { stroke: var(--warn); stroke-dasharray: 5 4; }
.demo-finger { fill: var(--surface-mat); stroke: var(--handle-rim); stroke-width: 1.5; }
.demo-pin { fill: var(--pin); stroke: var(--surface-mat); stroke-width: 1.2; }
.demo-pin-core { fill: var(--pin-core); }
.demo-pin-ring { fill: none; stroke: var(--warn); stroke-width: 1.6; }
.demo-swing { transform-box: view-box; transform-origin: 28% 60%; }

.help-score { color: var(--ink); }
.help-pieces {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.help-tables {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}
@media (min-width: 430px) {
  .help-tables {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}
.help-subhead {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
}
.help-ranks,
.help-grades {
  display: grid;
  background: var(--surface-mat);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-size: 11.5px;
}
.help-ranks li,
.help-grades li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 27px;
  padding: 2px 10px;
  border-bottom: 1px solid var(--row-divider);
}
.help-ranks li:last-child,
.help-grades li:last-child { border-bottom: 0; }
.help-rank-name,
.help-grade-name {
  min-width: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.help-grades li:nth-child(1) .help-grade-name { color: var(--rank-s); }
.help-grades li:nth-child(2) .help-grade-name { color: var(--rank-a); }
.help-grades li:nth-child(3) .help-grade-name { color: var(--rank-b); }
.help-grades li:nth-child(4) .help-grade-name { color: var(--rank-c); }
.help-grades li:nth-child(5) .help-grade-name { color: var(--rank-d); }
.help-rank-val,
.help-grade-val { flex: none; color: var(--ink-muted); font-size: 11px; white-space: nowrap; }
.help-cap { font-size: 10.5px; color: var(--ink-muted); }
.swatch { flex: none; width: 22px; height: 14px; border-radius: 2px; }
.swatch-l { background: var(--cut-l); border: 1px solid var(--cut-l-edge); }
.swatch-r {
  border: 1px solid var(--cut-r-edge);
  background:
    repeating-linear-gradient(45deg, var(--cut-r) 0 2px, transparent 2px 5px),
    var(--cut-r-bg);
}
.privacy {
  padding-top: 12px;
  border-top: 1px solid var(--row-divider);
  font-size: 10.5px;
  color: var(--ink-muted);
}

/* ==========================================================================
   トースト
   ========================================================================== */
.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(112px + var(--safe-b));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  pointer-events: none;
}
.toast {
  max-width: min(100%, 420px);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ink-ctrl);
  color: var(--surface-mat);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 3px 10px rgba(40, 40, 37, 0.22);
  transition: opacity 200ms ease;
}
.toast.is-out { opacity: 0; }

.noscript {
  position: fixed;
  inset: auto 16px 56px;
  z-index: 70;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink-ctrl);
  color: var(--surface-mat);
  font-size: 12px;
  text-align: center;
}

/* ==========================================================================
   PC (>= 900px): 温灰の地に 盤面 + 340px の紙パネル
   ========================================================================== */
@media (min-width: 900px) {
  :root {
    --pad-x: 24px;
    --dist-h: 150px;
  }
  .app { --board: max(240px, min(560px, 100vh - 176px - var(--banner-h), 100vw - 436px)); }
  @supports (height: 100dvh) {
    .app { --board: max(240px, min(560px, 100dvh - 176px - var(--banner-h), 100vw - 436px)); }
  }
  .app[data-view="play"] { background: var(--ground-band); }

  .hdr,
  .ftr {
    width: 100%;
    max-width: calc(var(--board) + 364px + 2 * var(--pad-x));
    margin-inline: auto;
  }
  .hdr { height: 56px; padding-right: 16px; }
  .ftr { height: calc(44px + var(--safe-b)); }
  .mode-opt::after { inset: -10px -2px; }
  .app[data-view="play"] > .ftr::before { border-top-color: var(--border-pill-active); }
  .app:has(> .banner[data-kind="tutorial"]:not([hidden])) { --banner-h: 48px; }
  .banner {
    align-self: center;
    width: calc(var(--board) + 364px);
    max-width: calc(100% - 2 * var(--pad-x));
  }
  .banner[data-kind="tutorial"] {
    border-radius: 10px;
    border: 1px solid var(--card-border);
    margin-bottom: 6px;
  }

  .view-play {
    padding: 0 var(--pad-x);
    grid-template-columns: var(--board) 340px;
    grid-template-rows: 60px 76px 44px 62px minmax(0, calc(var(--board) - 242px));
    grid-template-areas:
      "board pips"
      "board topic"
      "board status"
      "board actions"
      "board keys";
    column-gap: 24px;
    justify-content: center;
    align-content: center;
    height: auto;
  }
  /* 右パネル: 紙の面（DOM ラッパーなしで背景だけ敷く） */
  .view-play::before {
    content: "";
    grid-column: 2;
    grid-row: 1 / -1;
    background: var(--ground-paper);
    border-radius: 18px;
    box-shadow:
      0 18px 42px rgba(40, 40, 37, 0.14),
      0 2px 6px rgba(40, 40, 37, 0.06),
      0 0 0 1px rgba(40, 40, 37, 0.08);
  }
  .pips,
  .topic,
  .board-cell { background: none; }
  .board-cell { grid-row: 1 / -1; height: var(--board); padding: 0; }
  .pips,
  .topic,
  .status,
  .actions,
  .keys { padding-inline: 20px; z-index: 1; }
  .pips { padding-top: 20px; justify-content: flex-start; }
  .topic {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    padding-top: 0;
  }
  .topic-name {
    flex: none;
    max-width: 100%;
    font-size: 22px;
    line-height: 1.3;
  }
  .status { height: auto; min-height: 44px; padding-top: 0; }
  .app[data-twin="true"] .readout {
    flex-wrap: wrap;
    row-gap: 4px;
    column-gap: 10px;
    font-size: 15px;
  }
  .actions { height: 62px; padding-top: 6px; position: relative; z-index: 2; }
  .keys {
    display: block;
    align-self: stretch;
    max-height: 100%;
    margin: 0 20px;
    padding: 14px 0 18px;
    border-top: 1px solid var(--row-divider);
    font-size: 11.5px;
    color: var(--ink-muted);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  @media (max-height: 720px), (hover: none) and (pointer: coarse) {
    .keys { display: none; }
  }
  .keys-title { font-size: 11.5px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
  .keys-list { display: grid; gap: 4px; }
  .keys-list > div {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: center;
  }
  .keys-list dt { display: flex; gap: 4px; }
  .keys-note { margin-top: 8px; font-size: 10.5px; }
  kbd {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    background: var(--surface-mat);
    color: var(--ink);
    font: inherit;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
  }

  .toasts { bottom: 64px; }

  /* SUMMARY 2カラム */
  .view-summary {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
    padding-top: clamp(18px, 8vh, 76px);
    padding-bottom: 24px;
  }
  .sum-main,
  .sum-side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
  }
  .sum-main { flex: 0 1 520px; }
  .sum-side { flex: 0 0 340px; }
  .sum-hero { height: 96px; padding: 0 22px; gap: 16px; }
  .sum-grade { width: 60px; height: 60px; font-size: 32px; }
  .sum-title { font-size: 23px; line-height: 1.32; padding-bottom: 1px; }
  .sum-heading { font-size: 12px; }
  .sum-total-value { font-size: 28px; }
  .sum-rows { height: auto; grid-template-rows: repeat(5, 46px); }
  .sum-rows[data-count="3"] { grid-template-rows: repeat(3, 46px); }
  .sum-row {
    grid-template-columns: 24px minmax(0, 1fr) auto 56px 84px;
    gap: 14px;
    padding: 0 20px;
    font-size: 13.5px;
  }
  .sum-split,
  .sum-off { font-size: 13px; }
  .sum-rank { font-size: 12px; }
  .btn-share { margin-top: 0; }
}

/* スマホ横向き・極端に低い画面でも盤面と操作が重ならないようにする */
@media (max-width: 899.98px) and (max-height: 480px) {
  body { overflow-y: auto; }
  .app {
    --board: max(200px, min(100vw - 32px, 100dvh - 180px));
    min-height: 100dvh;
    height: auto;
    padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
  }
  .view-play,
  .topic,
  .status { touch-action: pan-y; }
}

/* PC でも高さが足りない場合は縦スクロールを許可（盤面は 240px 下限） */
@media (min-width: 900px) and (max-height: 520px) {
  .view-play { align-content: start; overflow-y: auto; touch-action: pan-y; }
}

/* ==========================================================================
   モーション（reduce 時はすべて無効。静止状態がそのまま意味を持つように作る）
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  .shape.is-miss { animation: blink 520ms steps(2, jump-none) infinite; }
  .pin-ring.is-on { animation: ring 700ms ease-out infinite; transform-box: fill-box; transform-origin: center; }
  .board-wrap.is-shake { animation: shake 90ms linear; }
  .board-flash.is-on { animation: flash 40ms linear; }
  .stamp:not([hidden]) { animation: stamp 200ms ease both; }
  .btn-slash.is-shake { animation: nope 220ms linear; }
  .btn-slash.is-pulse:not([aria-disabled="true"]) { animation: pulse 1100ms ease-in-out infinite; }
  .handle.is-pulse { animation: handle-pulse 1100ms ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
  .handle.is-nudge-flash { animation: nudge-flash 220ms ease-out; transform-box: fill-box; transform-origin: center; }
  .chip.is-flash { animation: chip-flash 320ms linear; }
  .hint:not([hidden]) { animation: rise 220ms ease-out both; }
  .toast { animation: toast-in 200ms ease both; }
  .ideal-case,
  .ideal-line,
  .ideal-band,
  .ghost-case,
  .ghost-line,
  .ghost-end { animation: fade-in 300ms linear both; }
  .app[data-view="summary"] .bar-fill { animation: bar-rise 500ms ease-out both; transform-origin: bottom; }

  .modal[open] .demo-thread-draw { animation: demo-draw 2400ms ease-in-out infinite; }
  .modal[open] .demo-finger { animation: demo-finger 2400ms ease-in-out infinite; }
  .modal[open] .demo-pin-ring { animation: ring 900ms ease-out infinite; transform-box: fill-box; transform-origin: center; }
  .modal[open] .demo-swing { animation: demo-swing 3200ms ease-in-out infinite; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .board-flash { display: none; }
}

@keyframes blink { from { stroke-opacity: 1; } to { stroke-opacity: 0.15; } }
@keyframes ring {
  from { transform: scale(0.85); opacity: 1; }
  to { transform: scale(1.3); opacity: 0.2; }
}
@keyframes shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(3px, -2px); }
  50% { transform: translate(-3px, 2px); }
  75% { transform: translate(2px, 3px); }
  100% { transform: translate(0, 0); }
}
@keyframes flash { from { opacity: 0.14; } to { opacity: 0; } }
@keyframes stamp {
  from { transform: translateX(-50%) translateY(4px) scale(0.95); opacity: 0; }
  to { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}
@keyframes nope {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(41, 41, 38, 0.4); }
  50% { box-shadow: 0 0 0 7px rgba(41, 41, 38, 0); }
}
@keyframes handle-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}
@keyframes nudge-flash {
  0% { transform: scale(1.45); }
  100% { transform: scale(1); }
}
@keyframes nudge-ripple {
  0% { transform: scale(0.9); opacity: 0.95; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes chip-flash {
  0%, 100% { background: var(--surface-mat); }
  30% { background: var(--cut-r-bg); }
}
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes bar-rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes demo-draw {
  0%, 10% { stroke-dashoffset: 100; }
  55%, 100% { stroke-dashoffset: 0; }
}
@keyframes demo-finger {
  0%, 10% { transform: translate(-140px, 60px); opacity: 1; }
  55% { transform: translate(0, 0); opacity: 1; }
  75%, 100% { transform: translate(0, 0); opacity: 0; }
}
@keyframes demo-swing {
  0%, 45%, 100% { transform: rotate(0deg); }
  72% { transform: rotate(12deg); }
}
