/* 画面の高さ。iOS Safari の 100vh はツールバーの裏まで含むので、使える所では見えている高さ（dvh）を使う */
:root { --app-h: 100vh; }
@supports (height: 100dvh) { :root { --app-h: 100dvh; } }
:root {
  color-scheme: dark; /* ネイティブのプルダウンなども暗い配色で描かせる */
  /* 選択中の NAGA タイプの色（types.js の applyThemeCss で上書き） */
  --type: #FF9898;
  --type-text: #FF9898;
  --type-edge: #FF9898;
  --type-ink: #141625;
  --type-light: #D63333;
  --type-glow: #FF9898;
  --glass: rgba(9, 16, 40, 0.74);
  --glass-strong: rgba(8, 14, 34, 0.9);
  --line: rgba(160, 185, 255, 0.16);
  --line-strong: rgba(180, 200, 255, 0.3);
  --text: #eef2ff;
  /* 補助の文字のグレー。暗い背景でも読めるよう明るめにする（muted: 見出し・説明、faint: さらに控えめな注記） */
  --muted: #b9c4e6;
  --faint: #93a1c9;
  --naga: #a67ae0;
  --naga-deep: #6c43a8;
  --gold: #ffc94d;
  --good: #3ddc97;
  --bad: #ff5470;
  --warn: #ff9f43;
  --mild: #ffd84d;
  --seat0: #ffffff;
  --seat1: #34d3c3;
  --seat2: #f47ad3;
  --seat3: #ffb03a;
  --win: #7bd88f;
  --deal: #ff6b7d;
  --side: #ffe16b;
  --draw: #8a93ad;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --dock-h: 92px; /* タイムライン（約 40px）と移動のボタン。低いほど卓を大きく写せる（狭い画面は下の指定） */
  --top-h: 46px; /* 上部のバー。ボタン（34px）の上下に 6px ずつ */
  --panel-w: 372px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
/* どうしてもスクロールが要るとき（狭い画面）も、スクロールバーは目立たせない（細く、マウスを乗せたときだけ見える） */
.modal-card, .drawer-inner, .naga-body, .sum-table-wrap { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.modal-card:hover, .drawer-inner:hover, .naga-body:hover, .sum-table-wrap:hover { scrollbar-color: rgba(200, 210, 255, 0.28) transparent; }
/* hidden 属性は、display を指定した部品（ツールチップ・メニューなど）でも必ず隠す */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #02040c; color: var(--text); }
body {
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* ダイアログは開いたときにカード自体へフォーカスを移すが、その枠は出さない（中のボタンには出す） */
.modal-card:focus, .modal-card:focus-visible { outline: none; }

/* スマホでダブルタップしても拡大しない（「次」を素早く 2 回押したときなどに画面がズームしないように）。
   スクロールと 2 本指の拡大はそのまま使える。卓（#scene）は 3D の操作のため none のまま（下の指定とカメラ操作が付ける） */
html, body, body * { touch-action: manipulation; }
/* 長押しや範囲のドラッグで文字を選択させない・長押しのメニュー（iOS のコピーや画像の保存）を出さない。
   アプリの操作（ボタンの長押し・連打）で、変なところが選択された状態にならないように。
   例外は解析レポートの URL・report_id の入力欄だけ（貼り付け・選択・編集に使う） */
html, body, body * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
img { -webkit-user-drag: none; }
input[type="text"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
/* iPhone のブラウザー（WebKit）は、文字が 16px より小さい入力欄に触れるとページを拡大し、閉じても戻さない（UI が画面の外へはみ出す。
   もしも局面の「点数など」の 13px の欄で、1.23 倍に拡大したままの報告があった）。タッチの画面では、入力欄の文字を 16px にする */
@media (any-pointer: coarse) {
  input:not([type="range"], [type="checkbox"], [type="radio"], [type="file"], [type="button"], [type="submit"], [type="color"]), select, textarea { font-size: 16px !important; }
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#scene:focus { outline: none; }
/* 拡大していないのに、見えている範囲がページの範囲より狭く、その内側にずれているとき（iPad の Chrome で、ページの上がバーの裏に回る）は、
   ページ（body）を見えている範囲に合わせ、canvas と固定配置の UI をその中に並べ直す（viewport.js の fitToVisible）。
   transform を付けると、body が固定配置の要素の基準になる */
body.vv-fit {
  position: fixed; left: var(--vv-x); top: var(--vv-y); width: var(--vv-w); height: var(--vv-h); transform: translateZ(0);
  --app-h: var(--vv-h);
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--shadow);
}

/* 解析データを読み込むまでは UI を隠し、卓と NAGA だけを見せる */
body.loading .topbar, body.loading .left-col, body.loading .naga-panel, body.loading .dock { visibility: hidden; }

/* ---- 3D に付いて動くラベル --------------------------------------------- */
.labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.world-label { position: absolute; left: 0; top: 0; will-change: transform; white-space: nowrap; }

/* 発声（リーチ・チー・ポン・カン・ツモ・ロン）: 発声した席の側に大きく出し、その局面にいる間は出し続ける */
.callouts { position: fixed; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }
/* 文字は種類によらず白。黒い縁取りで、どの背景の上でも読めるようにする */
.callout { position: absolute; left: 0; top: 0; display: grid; justify-items: center; will-change: transform; }
.callout .word {
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif; font-weight: 900; line-height: 1.08; letter-spacing: 0.04em; color: #fff;
  font-size: clamp(36px, 5vw, 72px); -webkit-text-stroke: 4px #0a0f26; paint-order: stroke fill;
  text-shadow: 0 4px 0 #0a0f26, 0 0 18px rgba(0, 0, 0, 0.55);
}
.callout.kind-win .word { font-size: clamp(44px, 6.4vw, 92px); }
.callout.enter { animation: callout-pop 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
@keyframes callout-pop { 0% { opacity: 0; scale: 0.5; } 100% { opacity: 1; scale: 1; } }
.delta-label { font-weight: 900; font-size: calc(18px * var(--depth, 1)); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7); font-variant-numeric: tabular-nums; animation: rise 2.2s ease-out both; }
.delta-label.plus { color: var(--good); }
.delta-label.minus { color: var(--bad); }
@keyframes rise { 0% { opacity: 0; translate: 0 10px; } 15% { opacity: 1; translate: 0 0; } 80% { opacity: 1; } 100% { opacity: 0; translate: 0 -24px; } }

/* ---- 上部バー ----------------------------------------------------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--top-h);
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: linear-gradient(180deg, rgba(2, 5, 16, 0.85), rgba(2, 5, 16, 0));
  z-index: 20;
}
/* 局とドラ表示（左の列の一番上に固定） */
.round-chip {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 8px 10px 8px 12px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--line); font-weight: 700; white-space: nowrap;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.round-chip .rc-head { display: grid; gap: 1px; }
.round-chip .round { font-size: 20px; font-family: "Hiragino Mincho ProN", "Noto Serif JP", serif; font-weight: 900; }
.round-chip .meta { color: var(--muted); font-size: 11px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.round-chip .dora { display: flex; align-items: center; gap: 10px; }
.round-chip .dora .lbl { color: var(--muted); font-size: 11px; line-height: 1.25; font-weight: 800; }
.round-chip .dora .tiles { display: flex; gap: 4px; }
.round-chip .dora img { height: 44px; border-radius: 4px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }
.round-chip .meta-s { display: none; } /* 狭い画面用の短い表記（0本 供1 / 残34） */
.round-chip .meta-s .sp { display: none; } /* 1 行に並べるとき（情報の列を上に並べるとき）だけの空き */
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn, .seg button {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--line); cursor: pointer; font-weight: 700; font-size: 13px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.icon-btn:hover, .seg button:hover { border-color: var(--line-strong); background: rgba(30, 44, 90, 0.8); }
.icon-btn:active { transform: translateY(1px); }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.seg button { height: 28px; border: 0; background: transparent; padding: 0 12px; }
.seg button[aria-pressed="true"] { background: rgba(166, 122, 224, 0.35); box-shadow: inset 0 0 0 1px rgba(200, 170, 255, 0.5); }

/* ---- 情報の列（局とドラ表示・各プレイヤー・状況） --------------------------------
   左に縦に並べる（layout-side）か、上に横 1 列に並べる（layout-top）。どちらにするかは main.js の applyLayout が
   卓を大きく写せる方を選ぶ。点数は中央パネルにあるので、ここには出さない */
.left-col { position: fixed; left: 14px; top: calc(var(--top-h) + 2px); width: 236px; z-index: 10; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-content: start; }
.scoreboard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; }
.player {
  position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; align-content: center; gap: 1px 9px;
  padding: 6px 10px 6px 8px; border-radius: 12px; cursor: pointer; text-align: left; width: 100%; min-width: 0;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.2s, background 0.2s;
}
.player::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--seat-color); }
.player:hover { border-color: var(--line-strong); }
.player.viewer { background: rgba(60, 42, 110, 0.72); border-color: rgba(190, 150, 255, 0.55); }
.player.acting { box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(255, 201, 77, 0.25); }
.player .wind {
  grid-row: span 3; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-family: "Hiragino Mincho ProN", "Noto Serif JP", serif; font-weight: 900; font-size: 16px;
  background: rgba(255, 255, 255, 0.08);
}
.player .wind.oya { background: #e8394f; }
/* 名前の行: 名前（長ければ省略）と、右端に点数。点数は中央パネルと同じく末尾の 00 を小さく薄く */
.player .name-row { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.player .name { flex: 1 1 auto; min-width: 0; font-weight: 800; font-size: 13px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .score { flex: none; font-weight: 800; font-size: 13px; line-height: 1.25; font-variant-numeric: tabular-nums; color: var(--text); }
.player .score small { font-size: 0.72em; font-weight: 700; color: var(--faint); margin-left: 0.5px; }
.player .sub { color: var(--muted); font-size: 10.5px; line-height: 1.3; display: flex; gap: 5px; align-items: center; white-space: nowrap; overflow: hidden; min-width: 0; }
.player .sub span { flex: none; }
.player .rel { color: var(--seat-color); font-weight: 800; }
/* 視点・リーチの札は左上に置く（右上は名前の行の点数があるので、重ならないように） */
.player .badges { position: absolute; left: 40px; top: -7px; display: flex; gap: 4px; }
.badge { font-size: 10px; font-weight: 900; padding: 1px 6px; border-radius: 6px; letter-spacing: 0.04em; }
.player .badge { font-size: 9px; line-height: 12px; padding: 0 6px; white-space: nowrap; }
.badge.riichi { background: var(--gold); color: #221600; }
.badge.you { background: var(--naga); color: #fff; }
/* 聴牌率（視点の席から見た各相手） */
.player .tp { grid-column: 2; display: grid; grid-template-columns: auto 1fr minmax(34px, auto); align-items: center; gap: 5px; font-size: 10px; color: var(--muted); font-weight: 700; line-height: 1.2; }
.player .tp b { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-size: 10.5px; }
.player .tp.hot b { color: var(--bad); }
.player .meter { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.player .meter i { display: block; height: 100%; background: linear-gradient(90deg, #ffb3c0, var(--bad)); transition: width 0.4s; }

/* 状況（視点の席から見た予測）: 見出しは付けず、各行の頭の短いラベルで示す */
.sit-card { padding: 8px 10px; }
.sit-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 6px; min-height: 18px; }
.sit-row + .sit-leg + .sit-row, .sit-leg + .sit-row { margin-top: 5px; }
.sit-row .k { font-size: 10px; color: var(--muted); font-weight: 800; white-space: nowrap; }
.sit-row .stack { height: 10px; grid-column: 2; }
.sit-row:not(:has(.exp)) .stack, .sit-row .machi { grid-column: 2 / 4; }
.sit-row .exp { font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1; }
.sit-row .exp small { font-size: 9px; color: var(--muted); font-weight: 700; margin-left: 2px; }
.sit-leg { display: flex; justify-content: space-between; gap: 3px; margin: 2px 0 0 0; font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.sit-leg span { display: inline-flex; align-items: center; gap: 2px; }
.sit-leg span::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--c); }
.sit-leg b { color: var(--text); font-size: 10.5px; font-variant-numeric: tabular-nums; margin-left: 1px; }
.sit-row .machi { height: 22px; }
.sit-row .machi img { height: 21px; }
.sit-row .machi .none { font-size: 10px; color: var(--faint); }

/* 左に縦に並べるときは下寄せにする（プレイヤーの視線は自分の手牌のある画面の下側が中心なので）。下端は右の解説パネルとそろえる */
body.layout-side .left-col { top: auto; bottom: calc(var(--dock-h) + var(--dock-lift, 0px) + 14px); max-height: calc(var(--app-h) - var(--top-h) - var(--dock-h) - var(--dock-lift, 0px) - 18px); }
/* 卓の左右が空いているときは、左に縦に並べた情報の列と右の解説パネルを、牌のすぐ外まで中央へ寄せる（量は main.js の hugAmounts）。
   解説パネルは、情報の列を上に並べるときも寄せる（そのときは情報の列の下から始めるので、寄せても列に重ならない） */
body.layout-side .left-col { transform: translateX(var(--hug-l, 0px)); transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
body:is(.layout-side, .layout-top) .naga-panel { transform: translateX(calc(-1 * var(--hug-r, 0px))); transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
body.hug-instant .left-col, body.hug-instant .naga-panel, body.hug-instant .dock { transition: none; }

/* 上に横 1 列に並べる（横幅に余裕のない画面）: 局・4 人・状況を 1 行に。凡例の数値と段位は省く（棒に乗せると数値が出る） */
body.layout-top .left-col {
  right: calc(var(--panel-w) + 28px); width: auto; display: grid; gap: 6px; align-items: stretch;
  grid-template-columns: auto minmax(0, 4fr) minmax(170px, 1.25fr);
}
body.layout-top .scoreboard { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; container-type: inline-size; }
/* 情報の列を上に並べるときは、列を画面の右端まで伸ばし、解説パネルは列の下から始める（パネルを卓へ寄せても列に重ならない）。
   列の下端の位置は main.js の applyLayout が --row-bottom に入れる */
body.layout-top .left-col { right: 14px; }
body.layout-top .naga-panel { top: var(--row-bottom, calc(var(--top-h) + 2px)); }

/* 上に並べるときは、どのカードも 2 行に収めて段を低くする（段の高さは最も高いカードで決まる）。
   局の欄: 局と、本場・供託・残りの短い表記の 2 行。プレイヤー: 名前と点数 / 席・期待順位と聴牌率 */
body.layout-top .round-chip { flex-wrap: nowrap; gap: 8px; padding: 3px 9px; border-radius: 12px; }
body.layout-top .round-chip .round { font-size: 16px; line-height: 1.15; }
body.layout-top .round-chip .meta { display: none; }
body.layout-top .round-chip .meta-s { display: block; color: var(--muted); font-size: 10px; line-height: 1.2; font-variant-numeric: tabular-nums; }
body.layout-top .round-chip .meta-s br { display: none; } /* 1 行に（「0本 供0 残45」） */
body.layout-top .round-chip .meta-s .sp { display: inline; }
body.layout-top .round-chip .dora { gap: 6px; }
body.layout-top .round-chip .dora .lbl { font-size: 10px; line-height: 1.15; }
body.layout-top .round-chip .dora img { height: 26px; }
body.layout-top .player {
  grid-template-columns: 20px minmax(0, 1fr) clamp(48px, 30%, 84px); grid-template-rows: auto auto;
  gap: 0 6px; padding: 3px 8px 3px 7px; border-radius: 10px;
}
body.layout-top .player::before { top: 6px; bottom: 6px; }
body.layout-top .player .wind { grid-row: 1 / 3; width: 20px; height: 20px; font-size: 12px; border-radius: 6px; }
body.layout-top .player .name-row { grid-column: 2 / 4; }
body.layout-top .player .sub { grid-column: 2; grid-row: 2; }
body.layout-top .player .tp { grid-column: 3; grid-row: 2; grid-template-columns: minmax(0, 1fr) minmax(30px, auto); gap: 4px; }
body.layout-top .player .sub .dan, body.layout-top .player .tp > span:first-child { display: none; }
body.layout-top .player .sub .ex i { display: none; } /* 「期待」は省き、「3.70位」だけ（期待順位は数字で分かる） */
body.layout-top .player .name { padding-right: 0; }
body.layout-top .player .badges { top: -8px; }
body.layout-top .sit-card { padding: 3px 9px; display: grid; align-content: center; border-radius: 12px; }
body.layout-top .sit-leg { display: none; }
body.layout-top .sit-row { min-height: 15px; }
/* 終局と順位を 1 行目に並べ、待ちを 2 行目にして、ほかのカードと同じ 2 行にする（3 行だと段がこのカードの分だけ高くなる）。
   列は 1 行目のカードの数（終局・順位の表示設定で 0〜2 枚）に合わせて明示する（--sit-cols は hud.js が入れる）。
   明示しないと暗黙の列になり、待ちの grid-column: 1 / -1 が 1 列目の終端までしか伸びず、多面待ちが切れる */
body.layout-top #situation { display: grid; grid-auto-flow: column; grid-template-rows: auto auto; grid-template-columns: repeat(var(--sit-cols, 2), minmax(0, 1fr)); gap: 1px 10px; align-content: center; }
body.layout-top #situation > .sit-row { margin-top: 0; grid-row: 1; }
body.layout-top #situation > .sit-row:last-child { grid-row: 2; grid-column: 1 / -1; }
body.layout-top .sit-row .machi { min-width: 0; overflow: hidden; }
body.layout-top .sit-row .machi .none { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
body.layout-top .sit-row .machi, body.layout-top .sit-row .machi img { height: 16px; }
body.layout-top .sit-row + .sit-row, body.layout-top .sit-leg + .sit-row { margin-top: 1px; }
/* 1 人分の幅が狭いときは風の四角を省き、風は 2 行目の頭に小さく出す（名前の幅を確保する） */
.player .sub .wind-s { display: none; font-weight: 900; color: var(--text); }
.player .sub .ex i { font-style: normal; }
.player .sub .wind-s.oya { color: #ff6b7d; }
@container (max-width: 560px) {
  body.layout-top .player { grid-template-columns: minmax(0, 1fr) clamp(44px, 32%, 70px); }
  body.layout-top .player .wind { display: none; }
  body.layout-top .player .name-row { grid-column: 1 / 3; }
  body.layout-top .player .sub { grid-column: 1; }
  body.layout-top .player .tp { grid-column: 2; }
  body.layout-top .player .sub .wind-s { display: inline; }
  body.layout-top .player .sub .ex i { display: none; }
}
/* ---- NAGA の解説パネル -------------------------------------------------- */
.naga-panel {
  position: fixed; right: 14px; top: calc(var(--top-h) + 2px); bottom: calc(var(--dock-h) + var(--dock-lift, 0px) + 14px); width: var(--panel-w);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; z-index: 10; pointer-events: none;
}
/* NAGA のワイプと吹き出しは右下に置き、判断の内訳はそのすぐ上に下寄せで積む（高さが変わっても下端は動かない） */
.naga-head { order: 2; }
.naga-body { order: 1; }
.naga-panel > * { pointer-events: auto; }
/* 2 段: 上の段（ワイプの右の空き）にほかのタイプの選択、下の段に吹き出し。ワイプは 2 段にまたがる */
.naga-head { display: grid; grid-template-columns: 96px 1fr auto; grid-template-rows: auto auto; gap: 4px 10px; align-items: end; }
.naga-head > .naga-avatar { grid-column: 1; grid-row: 1 / 3; }
.naga-head > .bubble { grid-column: 2; grid-row: 2; }
.naga-head > .sheet-toggle { grid-column: 3; grid-row: 1 / 3; }
/* NAGA のライブ映像（WebGL で枠の中に直接描く）。背景は透明にしてキャンバスを見せる */
.naga-avatar {
  width: 96px; height: 96px; border-radius: 22px; background: transparent !important;
  box-shadow: inset 0 0 0 2px var(--type-edge), 0 0 0 1px rgba(0, 0, 0, 0.4), 0 8px 30px color-mix(in srgb, var(--type-glow) 45%, transparent);
  transition: box-shadow 0.4s, transform 0.15s;
  position: relative; cursor: pointer; outline: none;
}
/* クリックで次のタイプへ（ワイプの NAGA が入れ替わる） */
.naga-avatar:hover { transform: translateY(-2px); }
.naga-avatar:active { transform: translateY(0) scale(0.97); }
.naga-avatar:focus-visible { box-shadow: inset 0 0 0 2px var(--type-edge), 0 0 0 3px rgba(255, 255, 255, 0.7); }
/* 名札: 選択中のタイプの名前を、そのタイプの色の札で下に出す（黒のタイプは銀の縁取り、文字は塗りの上で読める色） */
.naga-avatar::after {
  content: attr(data-type-label); position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); max-width: calc(100% - 10px);
  font-size: 10px; font-weight: 900; letter-spacing: 0.06em; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--type-ink); background: var(--type); border: 1px solid var(--type-edge); padding: 0 7px; border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.bubble {
  position: relative; padding: 12px 14px; border-radius: 16px; min-height: 64px;
  background: #faf7ff; color: #1d1540; font-weight: 700; line-height: 1.55;
  box-shadow: var(--shadow); display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
}
/* ツノは本体と同じ不透明な色にして、本体へ 1px 重ねる（半透明だと接するところに境界線が出る） */
.bubble::before { content: ""; position: absolute; left: -7px; bottom: 24px; border: 8px solid transparent; border-right-color: #faf7ff; border-left: 0; }
/* 表示項目: NAGA のセリフを消すときは吹き出しだけを消し、ワイプは残す。指摘線を消すときは凡例も消す */
body.no-bubble .bubble, body.bubble-quiet .bubble { visibility: hidden; }
body.no-diff-marks .tl-legend { display: none; }
.bubble-text { min-width: 0; }
.bubble img { height: 30px; margin: 0 2px; vertical-align: middle; border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
.bubble .em {
  /* 強調は文字を色で塗らず（タイプの色が赤だと警告に見えるため）、濃い太字にタイプの色の蛍光ペン風の下線を引く。
     折り返したときは行ごとに線を引く（box-decoration-break） */
  color: #1d1540; font-weight: 900; padding: 0 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone;
  background: linear-gradient(transparent 58%, color-mix(in srgb, var(--type-mark, #b58cff) 60%, transparent) 58%);
}
.bubble .bad { color: #d6123f; }
.bubble .quiet { color: #4f4a75; font-weight: 600; }
.sheet-toggle { display: none; }
/* ほかのタイプの選択: 選んでいないタイプの NAGA の顔（ライブ映像）と、そのタイプが選ぶ牌を小さく並べる。
   顔はワイプと同じく WebGL でキャンバスの枠の中に描くので、枠の背景は透明にする。牌は顔の右下に少し重ねる。
   幅はタイプごとに固定（顔と牌の分）。牌のない札だけの選択でも幅を変えず、局面を動かしても並びがずれないようにする */
.type-picks { grid-column: 2; grid-row: 1; display: flex; flex-wrap: wrap; gap: 3px; --tp-face: 28px; --tp-tile: 22px; --tp-w: 39px; }
.tpk { position: relative; flex: none; width: var(--tp-w); display: flex; align-items: flex-end; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; outline: none; }
.tpk-face {
  width: var(--tp-face); height: var(--tp-face); border-radius: 8px; flex: none; transition: transform 0.15s;
  box-shadow: inset 0 0 0 1.5px var(--c-edge), 0 0 0 1px rgba(0, 0, 0, 0.4), 0 3px 10px color-mix(in srgb, var(--c) 35%, transparent);
}
.tpk:hover .tpk-face { transform: translateY(-2px); }
.tpk:focus-visible .tpk-face { box-shadow: inset 0 0 0 1.5px var(--c-edge), 0 0 0 2px rgba(255, 255, 255, 0.75); }
.tpk-pick { display: flex; align-items: flex-end; }
.tpk-pick img { position: relative; z-index: 1; height: var(--tp-tile); margin-left: -5px; border-radius: 2px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55); }
/* 牌でない選択（ポン・ロンなど）と、聴牌を取る打牌のリーチ・ダマは、ワイプの名札と同じ形の札で顔の下端に出す（牌の下に潜らせる） */
.tpk-act {
  position: absolute; left: calc(var(--tp-face) / 2); bottom: -2px; transform: translateX(-50%);
  font-size: 8px; font-weight: 900; line-height: 1.3; white-space: nowrap; padding: 0 2px; border-radius: 4px;
  color: var(--c-ink); background: var(--c); border: 1px solid var(--c-edge); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
/* そのタイプが予測していない判断（旧タイプのロンなど）は、顔を暗くする */
.tpk.none .tpk-face { background: rgba(4, 6, 18, 0.6); }
/* 3D の NAGA を出さない設定（低スペックの環境向け）: ワイプには、3D の NAGA を同じ構図で写した静止画を出す（js/stills.js）。
   画像は表情を横に並べたもので、表情の位置（--still-x）へずらして見せる。地は 3D のワイプ（NAGA の後ろの暗い部屋）に合わせる。
   解説席を写す視点もないので、カメラの「NAGA」は出さない */
body.naga-still .naga-avatar, body.naga-still .tpk-face {
  background: var(--still-dim, none), var(--still, none) var(--still-x, 0) 0 / calc(var(--still-n, 1) * 100%) 100% no-repeat, linear-gradient(#0c1330, #03050d) !important;
}
body.naga-still .tpk.none .tpk-face { --still-dim: linear-gradient(rgba(4, 6, 18, 0.6) 0 0); }
body.naga-still [data-cam="naga"] { display: none; }
.naga-body { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; padding-right: 2px; scrollbar-width: thin; }
.card {
  border-radius: var(--radius); padding: 12px 14px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.card > header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 10px; }
#decision-card > header { display: grid; grid-template-columns: 1fr; }
#decision-card h2 { font-size: 14px; color: var(--text); }
.card h2 { margin: 0; font-size: 13px; letter-spacing: 0.06em; color: var(--muted); font-weight: 800; }
.card-sub { font-size: 11px; color: var(--faint); }
.type-tabs { display: flex; gap: 3px; flex-wrap: wrap; }
.type-tabs button {
  border: 1px solid color-mix(in srgb, var(--c-edge) 45%, transparent); background: transparent; border-radius: 8px; padding: 2px 8px;
  font-size: 11px; font-weight: 800; cursor: pointer; color: var(--c-text); opacity: 0.8;
}
/* 判断パネルのタブは 1 行に収める（タイプが多いときは文字と余白を詰め、幅を分け合う） */
#type-tabs { flex-wrap: nowrap; gap: 2px; min-width: 0; }
#type-tabs button { flex: 1 1 auto; min-width: 0; padding: 2px 3px; font-size: 10.5px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; border-radius: 7px; }
.type-tabs button:hover { opacity: 1; }
.type-tabs button[aria-selected="true"] {
  background: var(--c); border-color: var(--c-edge); color: var(--c-ink); opacity: 1;
  box-shadow: 0 0 12px color-mix(in srgb, var(--c-edge) 45%, transparent);
}
/* 上部バー: 選択中のタイプ */
/* 打牌候補 */
.cands { display: grid; gap: 6px; }
.cand { display: grid; grid-template-columns: 30px 1fr 52px; gap: 10px; align-items: center; }
.cand img { width: 30px; border-radius: 4px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); }
/* 棒の太さと間は、解析したタイプの数（--bar-n。hud.js）で決める。7 タイプのとき 選択中 11px・ほか 5px・間 2px。
   タイプが少ないときは、1 本あたりの太さと間を広げ、棒の束の高さを 7 タイプのときに近づける（束が細くて行の中で浮かないように）。
   ただし 1〜2 タイプで 1 本が太くなりすぎないよう、上限を付ける */
:root {
  --bar-k: clamp(1, calc(7 / var(--bar-n, 7)), 1.8);
  --bar-other: calc(5px * var(--bar-k));
  --bar-gap: calc(2px * var(--bar-k));
  --bar-main: clamp(11px, calc(11px * (0.5 + var(--bar-k) / 2)), 15px);
}
.cand .bars { display: grid; gap: var(--bar-gap); }
.bar { position: relative; }
.cand .bars, .choice .bars { display: grid; gap: var(--bar-gap); }
/* 棒は、太い棒（選択中のタイプ）も細い棒（他のタイプ）も、打牌候補・選択肢のどちらでも同じ規則で描く。
   溝はどのタイプも同じ暗い色（溝を塗りに近い色にすると 0% でも満ちて見えるため）。
   塗りは上から光を当てたような立体の帯にし、先端に明るい線を付けて、細い棒でも長さと終わりの位置を読めるようにする */
.cand .bar, .choice .bar.main {
  height: var(--bar-main); border-radius: 6px; overflow: hidden;
  background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}
.choice .bar.main { height: calc(var(--bar-main) + 3px); border-radius: 7px; }
.cand .bar.main { margin: 1px 0; }
.cand .bar.other, .choice .bar.other { height: var(--bar-other); border-radius: calc(var(--bar-other) / 2 + 0.5px); }
.cand .bar i, .choice .bar i {
  display: block; height: 100%; border-radius: inherit; transition: width 0.35s;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 62%, #fff) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 80%, #000) 100%);
  box-shadow: inset -2px 0 0 color-mix(in srgb, var(--c) 35%, #fff), 0 0 0 0.5px rgba(0, 0, 0, 0.35);
}
.cand .bar.main i, .choice .bar.main i { box-shadow: inset -3px 0 0 color-mix(in srgb, var(--c) 30%, #fff), 0 0 0 0.5px rgba(0, 0, 0, 0.35); }
/* 最も選ぶ候補は、選択中のタイプの棒をほのかに光らせる */
.cand.top .bar.main i, .choice.top .bar.main i {
  box-shadow: inset -3px 0 0 color-mix(in srgb, var(--c) 30%, #fff), 0 0 6px color-mix(in srgb, var(--type-glow) 45%, transparent);
}
.bar i.riichi-part { position: absolute; top: 0; background: linear-gradient(180deg, #ff9aab, #ff4d6d 45%, #d92f50) !important; box-shadow: none !important; border-radius: 0 6px 6px 0; }
/* ウロボロス（黒）: 塗りは黒のまま、塗った部分だけを銀色で縁取り、先端に明るい銀の線を付ける（溝は他のタイプと同じ） */
.bar.black i {
  background: linear-gradient(180deg, #5a5e70 0%, #1b1c25 40%, #050508 100%) !important;
  box-shadow: inset 0 0 0 1px #c9cedc, inset -3px 0 0 #f4f6fb !important;
}
.bar.other.black i { box-shadow: inset 0 0 0 1px #c9cedc, inset -2px 0 0 #f4f6fb !important; }
.bar.black i.riichi-part { background: linear-gradient(180deg, #ff9aab, #ff4d6d 45%, #d92f50) !important; box-shadow: none !important; }
.cand .pct { text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; }
.cand .tags { grid-column: 2 / 4; display: flex; gap: 6px; margin-top: -2px; }
.tag { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 5px; border: 1px solid currentColor; }
.tag.actual { color: #fff; }
.tag.naga { color: var(--type-text); }
.decision-verdict { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; font-weight: 800; font-size: 12px; }
.decision-verdict img { height: 30px; border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); vertical-align: middle; }
.decision-verdict span { display: inline-flex; align-items: center; gap: 4px; }
.verdict { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 8px; font-size: 12px; }
.verdict i {
  display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 4px; margin-left: -4px;
  background: var(--c, currentColor); color: #141625; font-style: normal; font-size: 10px; font-weight: 900; line-height: 1;
}
.verdict.kind { background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); }
.verdict.match { background: rgba(61, 220, 151, 0.18); color: var(--good); }
.verdict.mild { background: rgba(255, 216, 77, 0.16); color: var(--mild); }
.verdict.warn { background: rgba(255, 159, 67, 0.18); color: var(--warn); }
.verdict.bad { background: rgba(255, 84, 112, 0.2); color: var(--bad); }
.empty { color: var(--faint); font-size: 12px; padding: 6px 0; line-height: 1.9; }
.empty img { height: 26px; vertical-align: middle; border-radius: 3px; margin: 0 2px; }
.choice-bars { display: grid; gap: 8px; }
.choice { display: grid; grid-template-columns: 64px 1fr 52px; gap: 10px; align-items: center; font-weight: 800; }
/* 鳴きで使う牌（大明槓は3枚）と実際の行動の ● が入るぶん、ラベルの列を広げる（同じ判断の行は揃える） */
.choice-bars.has-meld .choice { grid-template-columns: 92px 1fr 52px; }
.choice .pct { text-align: right; font-variant-numeric: tabular-nums; }
.choice .label { white-space: nowrap; }
.choice .label .meld { display: inline-flex; gap: 1px; margin-left: 3px; vertical-align: middle; }
.choice .label .meld img { height: 22px; border-radius: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
/* 予測のないタイプの棒: 場所だけ残し、点線の溝で「値が 0」と区別する */
.bar.none { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0 3px, transparent 3px 6px) !important; box-shadow: none !important; }
.choice-note { font-size: 11px; color: var(--faint); margin: -2px 0 8px; }
.choice.actual .label::after { content: " ●"; color: #fff; font-size: 10px; }

.machi { display: flex; align-items: center; flex-wrap: nowrap; gap: 3px; height: 30px; font-size: 12px; color: var(--faint); font-weight: 700; }
.machi img { height: 28px; width: auto; max-width: calc((100% - 24px) / 9); object-fit: contain; border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.stack { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.stack i { display: block; height: 100%; transition: width 0.4s; }
.legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; font-size: 11px; }
.legend div { display: grid; gap: 1px; }
.legend b { font-size: 15px; font-variant-numeric: tabular-nums; }
.legend span { white-space: nowrap; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; background: var(--c); }
.rank-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 14px; }
.rank-row .exp { font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-row .exp small { font-size: 11px; color: var(--muted); font-weight: 700; margin-left: 4px; }
.sub-h { font-size: 11px; color: var(--muted); font-weight: 800; margin: 0 0 6px; letter-spacing: 0.04em; }

/* ---- 下部: タイムラインと移動 ------------------------------------------ */
.dock {
  position: fixed; left: 50%; bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--dock-lift, 0px)); transform: translateX(-50%);
  width: min(1100px, calc(100vw - 24px)); height: var(--dock-h); z-index: 15;
  /* 広い画面では、卓と解説パネルの下に、その左右の端（main.js の applyDock が --dock-l・--dock-r に入れる）にそろえて置く */
  display: grid; grid-template-rows: 1fr auto; gap: 6px; padding: 7px 12px 6px; container-type: inline-size;
  border-radius: 20px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); box-shadow: var(--shadow);
}
@media (width > 900px) and (aspect-ratio > 9/10) {
  /* 卓のまとまりに合わせて寄せるのは、main.js の applyDock が --dock-l・--dock-r を入れたとき（dock-hug）だけ。
     消したとき（自分で視点を動かしたあとの resize など）は、上の .dock の中央寄せのまま残す */
  body.dock-hug:is(.layout-side, .layout-top) .dock {
    left: var(--dock-l, 50%); width: calc(100vw - var(--dock-l, 0px) - var(--dock-r, 0px)); transform: none;
    transition: left 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  /* 中央寄せから寄せ直す 1 回（dock-instant）は動きを付けない。transform はすぐ外れるので、left だけ動くと右へはみ出す */
  body.dock-hug.dock-instant:is(.layout-side, .layout-top) .dock { transition: none; }
}
.timeline { position: relative; min-height: 0; }
.timeline canvas { width: 100%; height: 100%; display: block; cursor: pointer; }
.timeline-tip {
  position: absolute; bottom: calc(100% + 8px); transform: translateX(-50%); pointer-events: none;
  padding: 6px 10px; border-radius: 10px; background: var(--glass-strong); border: 1px solid var(--line-strong);
  font-size: 12px; white-space: nowrap; box-shadow: var(--shadow);
}
.nav { display: flex; justify-content: center; gap: 6px; }
/* 違いの種類のバッジ（タイムラインのキャンバス・凡例・ツールチップ・判断パネルで同じ形） */
.tl-kind { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.tl-kind i {
  display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 4px; flex: none;
  background: var(--c); color: #141625; font-style: normal; font-size: 10px; font-weight: 900; line-height: 1;
}
/* 字を四角の上下の真ん中へずらす（--kind-dy・--kind-dy-legend は timeline.js の centerKindGlyphs が、フォントの字の形を測って入れる） */
.tl-kind i > span { transform: translateY(var(--kind-dy, 0px)); }
.tl-legend .tl-kind i > span { transform: translateY(var(--kind-dy-legend, var(--kind-dy, 0px))); }
.timeline-tip .tl-kind { color: var(--c); font-weight: 800; }
.tl-legend {
  /* 2 段（打牌 / 副露・リーチ）にして、移動のボタンと同じ高さに収める（3 段だとタイムラインのグラフに重なる） */
  position: absolute; left: 14px; bottom: 6px; height: 34px; display: grid; grid-template-columns: auto auto; align-content: center; gap: 2px 8px;
  font-size: 10px; font-weight: 700; color: var(--muted); pointer-events: auto;
}
.tl-legend .tl-kind:first-child { grid-column: 1 / -1; }
.tl-legend .tl-kind i { width: 12px; height: 12px; font-size: 9px; border-radius: 3px; }
.tl-legend .sev { display: inline-flex; gap: 1px; margin-left: 3px; }
.tl-legend .sev s { width: 6px; height: 6px; border-radius: 1.5px; background: var(--c); }
/* 移動のボタンは下のバーの真ん中に並ぶので、凡例との間はバーの幅だけで決まる（バーの幅 ÷ 2 − 438px ほど）。
   バーは画面の幅だけでなく、卓に寄せるとき（dock-hug）にも狭まるので、バーの幅で決める。
   876px は .dock の左右の padding を引いた中身の幅（padding 12px ならバー 900px、1023px 以下の 8px ならバー 892px）。
   この幅より狭いときは出さない（実測では、出すときの間はいちばん狭くて 14px。padding を変えたら測り直す） */
@container (max-width: 876px) { .tl-legend { display: none; } }
.nav button {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 34px; min-width: 64px; padding: 0 10px;
  border-radius: 11px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); cursor: pointer;
  font-weight: 800; font-size: 13px; transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.nav button:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--line-strong); }
.nav button:active { transform: translateY(1px); }
.nav button:disabled { opacity: 0.35; cursor: default; }
.nav button.step { min-width: 76px; background: rgba(166, 122, 224, 0.16); border-color: rgba(190, 150, 255, 0.35); }
.nav button.diff { color: #ffd0d8; }
.nav button.play { width: 46px; min-width: 46px; border-radius: 50%; background: linear-gradient(180deg, #b58cff, #7e4fd0); border: 0; box-shadow: 0 6px 18px rgba(126, 79, 208, 0.5); }
.nav button.play svg { fill: #fff; stroke: none; width: 20px; height: 20px; }
.nav .i-pause { display: none; }
.nav button.play[aria-pressed="true"] .i-play { display: none; }
.nav button.play[aria-pressed="true"] .i-pause { display: block; }

/* ---- ツールチップ ------------------------------------------------------- */
.tile-tip {
  position: fixed; z-index: 30; pointer-events: none; min-width: 200px; padding: 10px 12px; border-radius: 12px;
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 12px;
}
.tile-tip h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.tile-tip h3 img { height: 34px; border-radius: 4px; }
.tile-tip table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.tile-tip td { padding: 2px 0; }
.tile-tip td:last-child { text-align: right; font-weight: 800; }
.tile-tip .sec { color: var(--muted); font-weight: 800; font-size: 11px; padding-top: 6px; }
.type-tip {
  position: fixed; z-index: 30; pointer-events: none; padding: 7px 11px; border-radius: 10px; display: grid; gap: 2px;
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 11px; color: var(--muted);
}
.type-tip b { font-size: 14px; font-weight: 900; }

/* ---- 設定 --------------------------------------------------------------- */
.drawer { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.35); }
/* 設定は縦に長くしてスクロールさせないよう、幅に応じて複数の列に流し込む（列は 290px 以上、最大 3 列） */
.drawer-inner {
  position: absolute; right: 12px; top: 12px; max-height: calc(var(--app-h) - 24px); width: min(1060px, calc(100vw - 24px)); overflow-y: auto;
  padding: 16px 18px; border-radius: 20px; background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  animation: slide 0.25s ease-out;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer header, .modal-card > header { display: flex; align-items: center; justify-content: space-between; }
.drawer h2, .modal-card h2 { margin: 0; font-size: 17px; }
.close { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 20px; line-height: 1; }
#settings-body { columns: 290px 3; column-gap: 26px; }
.set-group { margin-top: 0; padding-top: 12px; }
.set-group h3 { break-after: avoid; }
.set-row { break-inside: avoid; }
.set-group h3 { margin: 0 0 8px; font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.set-row { flex-wrap: wrap; }
.set-row label { font-weight: 700; flex: 1 1 140px; min-width: 0; }
.set-row > :not(label) { margin-left: auto; }
.set-row small { display: block; color: var(--faint); font-weight: 500; font-size: 11px; }
.set-row.disabled { opacity: 0.4; }
.set-row.disabled .switch { pointer-events: none; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.15); transition: background 0.2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + span { background: var(--naga); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.set-row .seg { flex: none; }
.set-row .seg button { height: 28px; padding: 0 10px; font-size: 12px; white-space: nowrap; }
/* スライダー（牌の明るさ）。両端に意味を書き、つまみはスマートフォンでも押せる大きさにする */
.set-range { display: flex; align-items: center; gap: 8px; flex: none; }
.set-range small { display: inline; white-space: nowrap; }
.set-range input { -webkit-appearance: none; appearance: none; width: 118px; height: 24px; margin: 0; background: transparent; cursor: pointer; }
.set-range input::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.set-range input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -8px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.set-range input::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.set-range input::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.set-range input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 12px; }
.set-row.disabled .set-range { pointer-events: none; }
select {
  background-color: #17204a; color: var(--text); border: 1px solid var(--line-strong); border-radius: 8px; padding: 5px 8px; font: inherit; font-weight: 700;
}
select option { background-color: #10183a; color: #eef2ff; }
select option:checked { background-color: #6c43a8; color: #ffffff; }

/* ---- モーダル ----------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(2, 4, 14, 0.45); }
.modal[hidden] { display: none; }
.modal-card {
  width: min(560px, 100%); max-height: calc(var(--app-h) - 32px); overflow-y: auto; padding: 20px 22px; border-radius: 22px;
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); animation: rise-in 0.35s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes rise-in { from { transform: translateY(18px) scale(0.98); opacity: 0; } }
/* 局の結果は卓の見える領域の中央に固定する（位置は main.js の placeResultCard）。
   左の情報の列や右の解説を隠さず、カメラや卓上の文字が動いても位置を変えない */
#result-modal { background: transparent; pointer-events: none; display: block; padding: 0; }
#result-modal .modal-card {
  position: absolute; left: calc(50% - 190px); top: calc(var(--top-h) + 12px); pointer-events: auto;
  width: min(410px, calc(100vw - 16px)); max-height: calc(var(--app-h) - var(--top-h) - var(--dock-h) - 28px); padding: 16px 16px 14px;
}
/* 見出しとボタンは常に見せ、収まらないときは間の内容（.result-body）だけをスクロールさせる */
#result-modal .modal-card { display: flex; flex-direction: column; overflow: hidden; }
#result-modal .modal-card > header, #result-modal .modal-actions { flex: none; }
.result-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#result-modal .modal-actions { margin-top: 12px; }
.result .headline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; margin: 0 0 4px; }
.result .headline .kind { font-size: 26px; font-weight: 900; letter-spacing: 0.08em; }
.result .headline .kind.win { background: linear-gradient(90deg, #ffe38a, #ffb52e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result .headline .who { font-weight: 800; color: var(--muted); }
/* 和了・聴牌の手牌。純手牌と副露 1 組ずつを改行しないまとまりにし、まとまりの間でだけ折り返す */
.result { container-type: inline-size; }
/* 牌の大きさは結果画面の幅から決め、純手牌 13 枚 + 和了牌（14 枚）が必ず 1 行に収まるようにする */
.result .hand { --tw: min(24.5px, calc((100cqw - 40px) / 14)); --th: calc(var(--tw) / 0.7209); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-end; margin: 6px 0 6px; }
.result .hand .closed, .result .hand .meld { display: inline-flex; flex-wrap: nowrap; align-items: flex-end; gap: 2px; }
.result .hand img { height: var(--th); width: var(--tw); border-radius: 3px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
.result .hand img.win-tile { margin-left: 10px; box-shadow: 0 0 0 2px var(--gold), 0 4px 12px rgba(255, 201, 77, 0.5); }
/* 横向きの牌（鳴いた牌）。加槓は横向きの牌を 2 枚重ねる */
.result .hand .side { display: inline-flex; flex-direction: column; gap: 2px; }
.result .hand .rot { position: relative; display: block; width: var(--th); height: var(--tw); }
.result .hand .rot img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-90deg); }
.yaku { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin: 8px 0; font-weight: 700; }
/* 役と翻数（流局の聴牌）の組を 2 組ずつ横に並べる */
.yaku.cols { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 3px 10px; margin: 6px 0; font-size: 13px; }
.yaku.cols > span:not(.han) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yaku.cols .han:nth-child(4n + 2) { padding-right: 8px; border-right: 1px solid var(--line); }
.yaku .han { text-align: right; color: var(--gold); font-variant-numeric: tabular-nums; }
/* 和了の役と翻数: PC では 3 組、狭い画面では 4 組ずつ横に並べる（長い組は 2 マス分） */
.yaku4 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px 4px; margin: 6px 0; font-size: 12px; font-weight: 700; }
.yaku4 .yk { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; min-width: 0; padding: 2px 4px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); }
.yaku4 .yk.wide3 { grid-column: span 2; }
.yaku4 .yk > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yaku4 .han { color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.result .headline .points { margin-left: auto; font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result .headline .points small { font-size: 14px; font-weight: 800; }
.dora-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 6px 0 2px; font-size: 12px; font-weight: 800; color: var(--muted); }
.dora-line span { display: inline-flex; align-items: center; gap: 4px; }
.dora-line img { height: 26px; border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.deltas { width: 100%; border-collapse: separate; border-spacing: 0 3px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.deltas th, .deltas td { padding: 3px 8px; white-space: nowrap; background: rgba(255, 255, 255, 0.05); }
.deltas th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 700; border-radius: 10px 0 0 10px; }
.deltas td:last-child { border-radius: 0 10px 10px 0; }
.deltas tr.viewer th, .deltas tr.viewer td { background: rgba(166, 122, 224, 0.18); }
.deltas .sc { width: 100%; font-size: 11px; color: var(--muted); font-weight: 700; }
.deltas .d { text-align: right; font-weight: 900; font-size: 16px; }
.deltas .pt { text-align: right; font-size: 12px; font-weight: 800; }
.deltas .pt small { font-size: 9px; }
.deltas .d.plus { color: var(--good); }
.deltas .d.minus { color: var(--bad); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn { height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.06); cursor: pointer; font-weight: 800; }
.btn.primary { background: linear-gradient(180deg, #b58cff, #7e4fd0); border: 0; }
.summary { width: min(980px, 100%); }
.sum-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-variant-numeric: tabular-nums; }
.sum-table th, .sum-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.sum-table th:first-child, .sum-table td:first-child { text-align: left; }
.sum-table th { color: var(--muted); font-size: 11px; font-weight: 800; }
.sum-table td.rank { font-size: 20px; font-weight: 900; }
.sum-table tr.viewer td { background: rgba(166, 122, 224, 0.12); }
.sum-table th.sim { color: #ffd65a; }
.sum-table td.sim b { font-size: 16px; }

/* 対局のまとめ: プレイヤーの切り替え */
.sum-types { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 10px 0 2px; }
.sum-types .lbl { color: var(--muted); font-size: 11px; font-weight: 800; }
.sum-types .type-tabs button { font-size: 12px; padding: 3px 10px; }
.sum-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.sum-tabs button {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--muted); font-weight: 800; font-size: 13px;
}
.sum-tabs button .r { color: var(--faint); font-size: 11px; }
.sum-tabs button small { color: var(--naga); font-size: 10px; }
.sum-tabs button[aria-selected="true"] { color: var(--text); border-color: var(--line-strong); background: rgba(166, 122, 224, 0.22); }

/* 対局のまとめ: 主役のプレイヤー */
.sum-hero {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 24px; align-items: center;
  margin-top: 10px; padding: 18px 20px; border-radius: 18px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
}
.sum-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.sum-rank { font-size: 46px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.sum-rank small { font-size: 16px; margin-left: 2px; color: var(--muted); }
.sum-who { min-width: 0; }
.sum-name { font-size: 22px; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-meta { color: var(--muted); font-size: 13px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sum-metrics { display: flex; align-items: center; gap: 18px; }
.sum-sim {
  position: relative; overflow: hidden; display: grid; justify-items: center; padding: 8px 18px 6px; border-radius: 16px;
  border: 1px solid transparent;
}
.sum-sim .lbl { font-size: 12px; font-weight: 900; letter-spacing: 0.12em; color: var(--muted); }
.sum-sim .val { font-size: 60px; line-height: 1.05; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sum-subm { display: grid; gap: 6px; }
.sum-subm div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; font-weight: 800; }
.sum-subm b { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; }
.sum-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0; }
.sum-stats div { padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.sum-stats dt { font-size: 11px; color: var(--muted); font-weight: 800; }
.sum-stats dd { margin: 2px 0 0; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 類似度の金色: 90 から 97 まで 1 ごとに演出を 1 つずつ足す（クラス g2〜g8 は到達した段階に累積で付く。--g: 0 = 90、1 = 97 以上）。
   数字はどの段階でもくっきりした金属の金色（ぼかした光で光らせると読みにくくなるため、影はぼかさない浮き彫りだけ）。
   90: 金の文字と金の細い枠 / 91: 文字の上を光のすじが流れる / 92: 金の二重枠と温かい地 / 93〜: きらめきが増えていく /
   94: 主役の欄の枠も金に / 95: 文字をより明るい白金寄りの金に / 96: 回る金の縁 / 97: 縁が速く回り、きらめきに虹色が混ざる */
.sum-sim.gold .val, td.sim.gold b {
  --metal: linear-gradient(180deg, #fffbe8 0%, #ffe7a0 20%, #f5c542 40%, #b47605 54%, #eab52f 66%, #fff1b8 84%, #d39412 100%);
  background-image: var(--metal);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 0 #5c3900) drop-shadow(0 2px 1px rgba(0, 0, 0, 0.45));
}
.sum-sim.gold .val { font-size: calc(60px + 6px * var(--g)); position: relative; z-index: 1; }
.sum-sim.g6 .val, td.sim.g6 b {
  --metal: linear-gradient(180deg, #ffffff 0%, #fff4c8 14%, #ffd75c 36%, #a06400 52%, #f8c83e 62%, #fffbe2 80%, #e2a322 100%);
}
/* 91〜: 光のすじ（文字の形に切り抜いた細い白い帯）が、少し間をおいて流れる */
.sum-sim.g2 .val, td.sim.g2 b {
  background-image: linear-gradient(110deg, transparent 44%, rgba(255, 255, 255, 0.95) 50%, transparent 56%), var(--metal);
  background-size: 300% 100%, 100% 100%; background-repeat: no-repeat;
  animation: sim-glint 4.6s 0.8s ease-in-out infinite;
}
.sum-sim.g6 .val, td.sim.g6 b { animation-duration: 3.2s; }
@keyframes sim-glint { 0% { background-position: 100% 0, 0 0; } 40%, 100% { background-position: 0% 0, 0 0; } }
.sum-sim.gold { border-color: rgb(255 214 90 / calc(0.45 + 0.4 * var(--g))); isolation: isolate; }
.sum-sim.gold .lbl { color: #e9c56a; }
.sum-sim.g3 {
  background: radial-gradient(120% 100% at 50% 0%, rgb(255 214 90 / 0.2), rgb(120 80 10 / 0.12) 60%, transparent);
  box-shadow: inset 0 0 0 1px rgb(255 236 170 / 0.35), inset 0 0 0 4px rgb(0 0 0 / 0.25), inset 0 0 0 5px rgb(255 214 90 / 0.55);
}
.sum-sim.g5 { box-shadow: inset 0 0 0 1px rgb(255 236 170 / 0.35), inset 0 0 0 4px rgb(0 0 0 / 0.25), inset 0 0 0 5px rgb(255 214 90 / 0.7), 0 6px 22px rgb(255 180 30 / 0.28); }
.sum-sim.g5 .lbl { color: #ffd65a; letter-spacing: 0.24em; }
/* 96〜: 回る金の縁（円錐グラデーションを回し、内側を地で覆って縁だけ見せる） */
.sum-sim.g7 { border-color: transparent; }
.sum-sim.g7::before {
  content: ""; position: absolute; inset: -80%; z-index: -2;
  background: conic-gradient(from 0deg, #6b4500, #ffe9a3, #c98a0b, #fff8dc, #7a4f00, #ffd34d, #fff1b8, #6b4500);
  animation: sim-ring 7s linear infinite;
}
.sum-sim.g7::after {
  content: ""; position: absolute; inset: 2px; z-index: -1; border-radius: 14px;
  background: radial-gradient(120% 100% at 50% 0%, #4a3710, #221a0a 60%, #15110a);
  box-shadow: inset 0 0 0 1px rgb(255 236 170 / 0.3), inset 0 0 0 4px rgb(0 0 0 / 0.25), inset 0 0 0 5px rgb(255 214 90 / 0.6);
}
.sum-sim.g8::before { animation-duration: 3.6s; }
@keyframes sim-ring { to { transform: rotate(1turn); } }
.sum-hero.gold { border-color: rgb(255 214 90 / calc(0.2 + 0.3 * var(--g))); }
.sum-hero.g5 {
  border-color: rgb(255 214 90 / 0.7);
  background: radial-gradient(90% 120% at 85% 50%, rgb(255 200 60 / 0.12), transparent 60%), rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 1px rgb(255 236 170 / 0.12) inset, 0 10px 34px rgb(255 180 30 / 0.16);
}
/* 開いたときに 1 回だけ、枠の中を光が横切る */
.sum-sim .shine {
  position: absolute; inset: -20% -40%; pointer-events: none; z-index: 2; opacity: calc(0.4 + 0.5 * var(--g, 0));
  background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, 0.55) 50%, transparent 58%);
  transform: translateX(-70%); animation: sum-shine 1.4s 0.35s ease-out 1 both;
}
@keyframes sum-shine { to { transform: translateX(70%); } }
/* きらめき: 4 方向に光る星形が、ひとつずつ間をおいて瞬く。光の芯は輪郭をはっきりさせ、周りにだけ淡い光を付ける
   （星形の切り抜きは ::before、光は外側の i に付ける。同じ要素だと光まで切り抜かれるため） */
.sparkles { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.sparkles i {
  position: absolute; left: var(--x); top: var(--y); width: calc(var(--s) * 1.5); height: calc(var(--s) * 1.5);
  transform: translate(-50%, -50%) scale(0); opacity: 0;
  filter: drop-shadow(0 0 2px rgb(255 240 190 / 0.95)) drop-shadow(0 0 5px rgb(255 200 70 / 0.6));
  animation: sparkle 3s var(--d) ease-in-out infinite;
}
.sparkles i::before {
  content: ""; position: absolute; inset: 0;
  clip-path: polygon(50% 0, 57% 43%, 100% 50%, 57% 57%, 50% 100%, 43% 57%, 0 50%, 43% 43%);
  background: radial-gradient(circle, #ffffff 0 20%, #fff3c4 38%, #ffd34d 72%);
}
.g8 .sparkles i:nth-child(3n + 1)::before { background: radial-gradient(circle, #ffffff 0 20%, #ffe0f6 42%, #a9e4ff 80%); }
.g8 .sparkles i:nth-child(3n + 2)::before { background: radial-gradient(circle, #ffffff 0 20%, #e6ffd9 42%, #ffd34d 80%); }
@keyframes sparkle {
  0%, 100% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  10% { transform: translate(-50%, -50%) scale(1) rotate(25deg); opacity: 1; }
  28% { transform: translate(-50%, -50%) scale(0.8) rotate(55deg); opacity: 0.9; }
  42% { transform: translate(-50%, -50%) scale(0) rotate(90deg); opacity: 0; }
}
.sum-hero.g8 { box-shadow: 0 0 0 1px rgb(255 236 170 / 0.18) inset, 0 12px 40px rgb(255 180 30 / 0.22); }
@media (prefers-reduced-motion: reduce) {
  .sum-sim .val, td.sim b, .sum-sim::before, .sparkles i, .sum-sim .shine { animation: none !important; }
  .sparkles i { transform: translate(-50%, -50%) scale(0.8); opacity: 0.9; }
}
.sum-subm span { white-space: nowrap; }
@media (max-width: 700px) {
  .sum-hero { grid-template-columns: 1fr; padding: 14px; }
  .sum-metrics { justify-content: space-between; flex-wrap: wrap; gap: 12px; }
  .sum-sim .val { font-size: 48px; }
  .sum-sim.gold .val { font-size: calc(48px + 5px * var(--g)); }
  .sum-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* グラフは画面の高さに合わせて縮め、まとめ全体が画面に収まるようにする（スクロールさせない） */
.sum-chart { width: 100%; height: clamp(120px, calc(var(--app-h) - 610px), 240px); margin-top: 12px; display: block; }
.sum-table-wrap { overflow-x: auto; }
@media (max-width: 860px) { .sum-table .opt1 { display: none; } }
@media (max-width: 480px) {
  .sum-table .opt2 { display: none; }
  .sum-table th, .sum-table td { padding: 6px 5px; }
  .deltas th, .deltas td { padding: 3px 5px; }
  .deltas .d { font-size: 14px; }
}
/* 小さいスマホ（幅 380px 以下）: 結果の点数の表を詰める（opt3: まとめの表のウマオカ込の列も省く） */
@media (max-width: 380px) {
  .sum-table .opt3 { display: none; }
  .deltas th, .deltas td { padding: 3px 4px; }
  .deltas .sc { font-size: 10px; }
  .deltas .d { font-size: 13px; }
}
/* スマホ幅のまとめ: 詰め込まず、画面いっぱいのシートにして縦にスクロールさせる（スマホでは縦のスクロールが自然なので）。
   タブは読める大きさのまま 1 段に並べ、入りきらない分は横にスワイプ（右端を薄くして続きがあることを示す） */
@media (max-width: 700px) {
  #summary-modal { padding: 0; }
  .modal-card.summary {
    width: 100%; height: var(--app-h); max-height: none; border-radius: 0; border: 0;
    padding: calc(10px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  }
  .sum-types { margin-top: 8px; }
  .sum-types .lbl { display: none; }
  .sum-types .type-tabs, .sum-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; padding: 2px 0; }
  .sum-types .type-tabs::-webkit-scrollbar, .sum-tabs::-webkit-scrollbar { display: none; }
  .sum-types .type-tabs.more, .sum-tabs.more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
  .sum-types .type-tabs button { flex: none; font-size: 12px; padding: 4px 10px; }
  .sum-tabs { margin-top: 8px; }
  .sum-tabs button { flex: none; white-space: nowrap; font-size: 12px; padding: 6px 10px; }
  .sum-hero { padding: 12px; gap: 12px; }
  .sum-metrics { flex-wrap: nowrap; justify-content: flex-start; gap: 16px; }
  .sum-sim { padding: 6px 14px 4px; }
  .sum-sim .val { font-size: 44px; }
  .sum-sim.gold .val { font-size: calc(44px + 4px * var(--g)); }
  .sum-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-chart { height: 200px; }
  #sum-mode { display: flex; width: 100%; }
  #sum-mode button { flex: 1 1 auto; min-width: 0; padding: 0 6px; font-size: 12px; white-space: nowrap; }
}
/* 操作方法: 操作と 3D の注釈を横に並べ、縦に長くしない */
.modal-card.help { width: min(1080px, 100%); }
.help-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 0 32px; }
.help-h { margin: 12px 0 0; font-size: 15px; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 0; font-size: 13px; }
.help dt { font-weight: 800; }
.help dd { margin: 0; color: var(--muted); }
kbd { font: 700 12px/1 ui-monospace, monospace; padding: 3px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); }

/* ---- ホーム（report_id なしで開いたとき）と解析一覧（library.js） ----------------------------------
   ホームの後ろでは卓と NAGA が回る（main.js の attract）。NAGA を写す所は --focus-x・--focus-y（画面に対する割合）で指す。
   一覧が使えるとき（has-lib）は、広い画面で左に開く欄、右に一覧を置き、NAGA は左の空いた所に写す */
.loader.home { --focus-x: 0.5; --focus-y: 0.2; overflow-y: auto; }
.home-grid { width: min(520px, 100%); display: grid; gap: 16px; }
.home-open {
  width: 100%; padding: 20px 22px; border-radius: 22px; text-align: center;
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); animation: rise-in 0.35s cubic-bezier(.2, 1.2, .4, 1);
}
.home-open .drop strong { font-size: 13px; }
@media (max-width: 480px) {
  /* スマホ幅: 説明とドロップの文を 1 行に収める（語の途中で折り返さないように） */
  .home-open .load-lead { font-size: 13px; }
  .home-open .drop strong { font-size: 12px; }
}
.home-lib { display: none; }
.loader.home.has-lib .home-lib { display: flex; min-height: 0; animation: rise-in 0.45s 0.05s both cubic-bezier(.2, 1.2, .4, 1); }
@media (min-width: 1100px) {
  .loader.home.has-lib {
    --focus-x: 0.25; --focus-y: 0.3; place-items: stretch; padding: 22px 26px;
    background: linear-gradient(90deg, rgba(2, 4, 14, 0.04) 0%, rgba(2, 4, 14, 0.2) 38%, rgba(2, 4, 14, 0.72) 100%);
  }
  .loader.home.has-lib .home-grid {
    width: 100%; height: calc(var(--app-h) - 44px); grid-template-columns: minmax(360px, 420px) minmax(600px, 900px);
    grid-template-rows: minmax(0, 1fr); justify-content: space-between; align-items: end; gap: 28px;
  }
  .loader.home.has-lib .home-lib { align-self: stretch; }
}
@media (max-width: 1099px) {
  /* 1 列: 上に NAGA、開く欄、一覧の順。ページごとスクロールする（一覧の中ではスクロールしない） */
  .loader.home.has-lib { --focus-y: 0.16; place-items: start center; padding: 30vh 12px 24px; }
  .loader.home.has-lib .home-grid { width: min(760px, 100%); }
  .loader.home.has-lib .lib-body { overflow: visible; }
  /* 一覧の後ろを NAGA が通るので、ほとんど透かさない（ぼかした NAGA の牌が四角く透けて見えないように） */
  .loader.home.has-lib .lib { background: rgba(8, 14, 34, 0.97); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* 一覧の部品 */
.lib-host { min-width: 0; min-height: 0; }
.lib {
  --r1: #ffc94d; --r2: #d3dbee; --r3: #e39a62; --r4: #8892ae;
  --plus: #5fe3b0; --minus: #ff8a9b;
  position: relative; display: flex; flex-direction: column; width: 100%; min-height: 0; flex: 1;
  border-radius: 22px; overflow: hidden; text-align: left;
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
/* 上の縁の光（NAGA の紫から淡い紫へ） */
.lib::before {
  content: ""; position: absolute; left: 22px; right: 22px; top: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(166, 122, 224, 0.9), rgba(215, 184, 255, 0.9), transparent);
}
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 4px; }
.lib-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.lib-title h2 { margin: 0; font-size: 19px; font-weight: 900; letter-spacing: 0.06em; white-space: nowrap; }
.lib-who { color: var(--muted); font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-site { color: var(--muted); font-size: 12px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.lib-site:hover { color: var(--text); }
.lib-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 8px 20px 12px; border-bottom: 1px solid var(--line); }
.lib-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); }
.lib-tabs button {
  height: 32px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; transition: background 0.2s, color 0.2s;
}
.lib-tabs button:hover { color: var(--text); }
.lib-tabs button[aria-selected="true"] {
  color: #fff; background: linear-gradient(180deg, rgba(166, 122, 224, 0.62), rgba(108, 67, 168, 0.62));
  box-shadow: inset 0 0 0 1px rgba(214, 184, 255, 0.35), 0 4px 14px rgba(108, 67, 168, 0.35);
}
.lib-month { display: flex; align-items: center; gap: 4px; }
.lib-mbtn {
  width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
  color: var(--text); font: inherit; font-size: 18px; line-height: 1; cursor: pointer;
}
.lib-mbtn:hover:not(:disabled) { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.1); }
.lib-mbtn:disabled { opacity: 0.28; cursor: default; }
.lib-mlabel { min-width: 106px; text-align: center; font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.lib-now {
  height: 28px; margin-left: 4px; padding: 0 10px; border-radius: 9px; border: 1px solid rgba(166, 122, 224, 0.45);
  background: rgba(166, 122, 224, 0.14); color: #e2d3ff; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
}
.lib-now[hidden] { display: none; }
.lib-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 22px; scrollbar-width: thin; scrollbar-color: rgba(200, 210, 255, 0.22) transparent; }
.n { font-variant-numeric: tabular-nums; }

/* この月の成績 */
.lib-stats { display: grid; grid-template-columns: auto auto minmax(150px, 1.2fr) auto auto; gap: 8px; margin: 0 0 6px; }
.lib-stat {
  display: flex; flex-direction: column; justify-content: center; gap: 5px; min-width: 0; padding: 9px 12px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)); border: 1px solid var(--line);
}
.lib-stat .k { font-size: 10.5px; font-weight: 800; color: var(--muted); letter-spacing: 0.06em; white-space: nowrap; }
.lib-stat .k small { font-weight: 700; color: var(--faint); letter-spacing: 0; }
.lib-stat > b { font-size: 23px; font-weight: 900; line-height: 1; white-space: nowrap; }
.lib-stat > b small { font-size: 11px; margin-left: 2px; color: var(--muted); }
.lib-stat > b.plus { color: var(--plus); }
.lib-stat > b.minus { color: var(--minus); }
.lib-dist { display: flex; gap: 2px; height: 10px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.lib-dist i { display: block; min-width: 4px; transform-origin: left; animation: lib-grow 0.7s 0.15s both cubic-bezier(.2, .9, .3, 1); }
.lib-dist .r1 { background: var(--r1); }
.lib-dist .r2 { background: var(--r2); }
.lib-dist .r3 { background: var(--r3); }
.lib-dist .r4 { background: var(--r4); }
.lib-dist-l { display: flex; gap: 10px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lib-dist-l b { margin-right: 3px; font-size: 10px; }
.lib-dist-l .r1 b { color: var(--r1); }
.lib-dist-l .r2 b { color: var(--r2); }
.lib-dist-l .r3 b { color: var(--r3); }
.lib-dist-l .r4 b { color: var(--r4); }
.lib-spark { display: block; width: 168px; height: 44px; overflow: visible; }
.lib-spark .up { fill: rgba(61, 220, 151, 0.22); }
.lib-spark .down { fill: rgba(255, 84, 112, 0.22); }
.lib-spark .zero { stroke: rgba(255, 255, 255, 0.28); stroke-width: 1; stroke-dasharray: 3 3; }
.lib-spark .line { fill: none; stroke: #eef2ff; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: lib-draw 1.1s 0.2s ease-out forwards; }
.lib-spark .dot { fill: #eef2ff; stroke: rgba(2, 4, 14, 0.9); stroke-width: 1.5; }
.lib-spark .dot.plus { fill: var(--plus); }
.lib-spark .dot.minus { fill: var(--minus); }
.lib-hint { margin: 0 2px 4px; padding: 10px 12px; border-radius: 12px; background: rgba(166, 122, 224, 0.1); border: 1px solid rgba(166, 122, 224, 0.25); color: #dcd0f5; font-size: 12px; }

/* 日付の見出し */
.lib-day { display: flex; align-items: center; gap: 10px; margin: 16px 4px 8px; font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: 0.04em; }
.lib-day small { font-size: 11px; color: var(--faint); font-weight: 700; margin-left: -6px; }
.lib-day::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }
.lib-list > .lib-day:first-child { margin-top: 4px; }

/* 対局のカード */
.lib-list { display: grid; gap: 8px; }
.lib-card {
  position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto 12px; align-items: center; gap: 14px;
  padding: 11px 14px 11px 12px; border-radius: 16px; overflow: hidden; cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02)); border: 1px solid var(--line);
  transition: transform 0.18s ease, border-color 0.18s, background 0.18s, box-shadow 0.18s;
  animation: lib-in 0.45s calc(var(--i, 0) * 35ms) both cubic-bezier(.2, .9, .3, 1);
}
.lib.quiet .lib-card, .lib.quiet .lib-dist i, .lib.quiet .lib-spark .line { animation: none; }
.lib.quiet .lib-spark .line { stroke-dashoffset: 0; }
/* 着順の色の縁（左） */
.lib-card::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent, transparent); }
.lib-card.r1 { --accent: var(--r1); }
.lib-card.r2 { --accent: var(--r2); }
.lib-card.r3 { --accent: var(--r3); }
.lib-card.r4 { --accent: var(--r4); }
.lib-card[tabindex]:hover, .lib-card[tabindex]:focus-visible {
  transform: translateY(-1px); border-color: rgba(190, 160, 255, 0.45); outline: none;
  background: linear-gradient(180deg, rgba(166, 122, 224, 0.16), rgba(255, 255, 255, 0.03));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.lib-card[tabindex]:focus-visible { box-shadow: 0 0 0 2px var(--naga), 0 10px 28px rgba(0, 0, 0, 0.35); }
.lib-card.is-current { border-color: rgba(166, 122, 224, 0.65); background: linear-gradient(90deg, rgba(166, 122, 224, 0.2), rgba(255, 255, 255, 0.03)); }
.lib-card.is-pending, .lib-card.is-fail { cursor: default; }
.lib-card.is-fail { background: linear-gradient(180deg, rgba(255, 84, 112, 0.07), rgba(255, 255, 255, 0.02)); }
.lib-go { width: 9px; height: 9px; border-top: 2px solid var(--faint); border-right: 2px solid var(--faint); transform: rotate(45deg); opacity: 0.55; transition: transform 0.18s, opacity 0.18s, border-color 0.18s; }
.lib-card:hover .lib-go, .lib-card:focus-visible .lib-go { opacity: 1; border-color: #fff; transform: translateX(3px) rotate(45deg); }

/* 自分の着順のメダル */
.lib-medal {
  position: relative; display: flex; align-items: baseline; justify-content: center; gap: 1px; width: 52px; height: 52px;
  padding-top: 11px; border-radius: 50%; font-family: "Hiragino Mincho ProN", "Noto Serif JP", serif; line-height: 1;
}
.lib-medal b { font-size: 27px; font-weight: 900; }
.lib-medal small { font-size: 11px; font-weight: 900; }
.lib-medal.r1 { color: #3a2600; background: radial-gradient(circle at 34% 28%, #fff6cf, #ffc94d 46%, #b07818); box-shadow: 0 0 0 2px rgba(255, 201, 77, 0.35), 0 6px 20px rgba(255, 201, 77, 0.28); }
.lib-medal.r2 { color: #1b2233; background: radial-gradient(circle at 34% 28%, #ffffff, #d3dbee 46%, #8a95b2); box-shadow: 0 0 0 2px rgba(211, 219, 238, 0.28); }
.lib-medal.r3 { color: #2e1405; background: radial-gradient(circle at 34% 28%, #ffe0c4, #e39a62 46%, #8f5226); box-shadow: 0 0 0 2px rgba(227, 154, 98, 0.28); }
.lib-medal.r4 { color: #e4e8f5; background: radial-gradient(circle at 34% 28%, #a9b2c9, #66708c 50%, #3c4359); box-shadow: 0 0 0 2px rgba(136, 146, 174, 0.25); }
/* 1 位のメダルには光が流れる */
.lib-medal.r1::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.75) 50%, transparent 65%); background-size: 250% 100%;
  animation: lib-sheen 3.2s 0.6s ease-in-out infinite; mix-blend-mode: soft-light;
}
.lib-medal.unknown { align-items: center; padding: 0; color: var(--muted); background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--line-strong); }
.lib-medal.x { align-items: center; padding: 0; color: #ff9aab; background: rgba(255, 84, 112, 0.14); border: 1px solid rgba(255, 84, 112, 0.4); font-family: inherit; }
.lib-medal.spin { align-items: center; padding: 0; }
.lib-medal.spin i { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(166, 122, 224, 0.22); border-top-color: #c9a8ff; animation: lib-spin 0.9s linear infinite; }

.lib-main { min-width: 0; }
.lib-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; font-size: 12px; color: var(--muted); }
.lib-time { font-weight: 900; color: var(--text); }
.lib-rule { padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 10.5px; font-weight: 800; color: #cfd6ef; }
.lib-cur { padding: 1px 8px; border-radius: 999px; background: var(--naga); color: #fff; font-size: 10.5px; font-weight: 900; }
.lib-types { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.lib-ver { font-size: 11px; font-weight: 900; color: #d9c8ff; }
.lib-ver.self { color: #9fe8d9; font-size: 10.5px; white-space: nowrap; }
.lib-faces { display: inline-flex; align-items: center; padding-left: 4px; }
.lib-face {
  position: relative; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: -4px; border-radius: 50%; overflow: hidden;
  background: #1a2040; box-shadow: 0 0 0 2px var(--c, var(--line-strong)), 0 0 0 3.5px rgba(5, 8, 22, 0.95);
}
.lib-face i { display: block; width: 100%; height: 100%; background-size: 800% 100%; background-position: 0 0; background-repeat: no-repeat; }
.lib-face.more { color: var(--muted); font-size: 9.5px; font-weight: 900; }
.lib-players { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 12px; margin: 7px 0 0; padding: 0; }
.lib-players li { display: flex; align-items: baseline; gap: 5px; min-width: 0; font-size: 12.5px; color: #d5dcf5; }
.lib-players i { flex: none; font-style: normal; font-size: 10px; font-weight: 900; color: var(--faint); }
.lib-players .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-players .pt { margin-left: auto; font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.lib-players li.me { color: #fff; font-weight: 900; }
.lib-players li.me .nm { text-decoration: underline 2px rgba(190, 160, 255, 0.8); text-underline-offset: 3px; }
.pt.plus { color: var(--plus); }
.pt.minus { color: var(--minus); }
.lib-side { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.lib-mypt { font-size: 22px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.lib-mypt small { font-size: 11px; margin-left: 1px; color: var(--muted); }
.lib-mypt.plus { color: var(--plus); }
.lib-mypt.minus { color: var(--minus); }
.lib-acts { display: flex; gap: 5px; }
.lib-acts a, .lib-more {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 800; text-decoration: none; cursor: pointer;
}
.lib-acts a:hover, .lib-more:hover, .lib-more[aria-expanded="true"] { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.1); }
.lib-note { margin-top: 6px; font-size: 12px; color: var(--muted); }
.lib-status { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 900; white-space: nowrap; }
.lib-status.s0 { background: rgba(61, 220, 151, 0.15); color: #7debbd; }
.lib-status.s1 { background: rgba(255, 255, 255, 0.08); color: #cfd6ef; }
.lib-status.s2 { background: rgba(166, 122, 224, 0.24); color: #e5d6ff; }
.lib-status.s3, .lib-status.s4 { background: rgba(255, 84, 112, 0.18); color: #ff9aab; }
/* 局面逆再生の状態: 0 完了 / 1 試行中 / 2 失敗 / 3 解析待ち / 4 候補過多 */
.lib-status.pb.s1 { background: rgba(166, 122, 224, 0.24); color: #e5d6ff; }
.lib-status.pb.s2 { background: rgba(255, 84, 112, 0.18); color: #ff9aab; }
.lib-status.pb.s3 { background: rgba(255, 255, 255, 0.08); color: #cfd6ef; }
.lib-status.pb.s4 { background: rgba(255, 159, 67, 0.18); color: #ffc58f; }
/* 解析待ち・解析中: カードの下の縁を光が流れる */
.lib-flow {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--naga), #e2d0ff, transparent) no-repeat; background-size: 45% 100%;
  animation: lib-flow 1.8s linear infinite;
}
/* 同じ牌譜のほかの版・タイプ */
.lib-others { display: grid; gap: 6px; margin: -4px 0 2px 66px; padding: 9px 12px; border-radius: 0 0 14px 14px; border: 1px solid var(--line); border-top: 0; background: rgba(0, 0, 0, 0.2); }
.lib-other { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }

/* 局面逆再生のカード */
.lib-card.pb { grid-template-columns: 52px minmax(0, 1fr) auto 12px; }
.lib-pbface { display: grid; place-items: center; }
.lib-pbface .lib-face { width: 44px; height: 44px; margin: 0; }
.lib-kyoku { font-family: "Hiragino Mincho ProN", "Noto Serif JP", serif; font-size: 16px; font-weight: 900; color: #fff; }
.lib-tname { font-weight: 800; color: #d9c8ff; }
.lib-prog { height: 6px; margin-top: 8px; border-radius: 4px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.lib-prog i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--naga-deep), #c9a8ff); transition: width 0.6s ease; }
.lib-prog.s0 i { background: linear-gradient(90deg, #26a77c, var(--plus, #5fe3b0)); }
.lib-prog.s2 i { background: #ff5470; }

/* 知らせ（ログイン・使えない・空・エラー）とボタン */
.lib-notice { display: grid; justify-items: center; gap: 8px; padding: 48px 20px; text-align: center; }
.lib-notice .lib-face { width: 68px; height: 68px; margin: 0 0 8px; box-shadow: 0 0 0 3px var(--c), 0 10px 30px rgba(0, 0, 0, 0.4); }
.lib-notice h3 { margin: 0; font-size: 16px; }
.lib-notice p { margin: 0; color: var(--muted); font-size: 13px; }
.lib-notice-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.lib-btn {
  display: inline-flex; align-items: center; height: 36px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.06); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 800; text-decoration: none; cursor: pointer;
}
.lib-btn:hover { background: rgba(255, 255, 255, 0.12); }
.lib-btn.primary { background: var(--naga); border-color: transparent; color: #fff; }
.lib-btn.primary:hover { background: #b78cf0; }
.lib-btn.small { height: 26px; padding: 0 10px; border-radius: 8px; font-size: 11.5px; }

/* 読み込み中の形だけのカード */
.lib-skel { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 14px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.lib-skel i { display: block; border-radius: 6px; background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.13) 50%, rgba(255, 255, 255, 0.05) 100%); background-size: 200% 100%; animation: lib-shimmer 1.3s linear infinite; }
.lib-skel i.m { width: 52px; height: 52px; border-radius: 50%; }
.lib-skel span { display: grid; gap: 9px; }
.lib-skel span i:first-child { width: 42%; height: 11px; }
.lib-skel span i:last-child { width: 88%; height: 14px; }

@keyframes lib-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes lib-grow { from { transform: scaleX(0); } }
@keyframes lib-draw { to { stroke-dashoffset: 0; } }
@keyframes lib-spin { to { transform: rotate(360deg); } }
@keyframes lib-flow { from { background-position: -60% 0; } to { background-position: 160% 0; } }
@keyframes lib-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes lib-sheen { 0%, 55% { background-position: 150% 0; } 100% { background-position: -100% 0; } }

/* レポートの表示中の「開く」のシート（左に URL の欄、右に一覧） */
.modal-card.open-card { display: flex; flex-direction: column; width: min(1120px, 100%); height: min(840px, calc(var(--app-h) - 32px)); overflow: hidden; }
.open-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; margin-top: 10px; }
.open-side { display: flex; flex-direction: column; min-height: 0; }
.open-note { margin: 4px 0 0; color: var(--faint); font-size: 11.5px; line-height: 1.6; }
.home-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; margin-top: auto; border-radius: 12px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.06); color: var(--text); font: inherit; font-weight: 800; cursor: pointer;
}
.home-btn:hover { background: rgba(255, 255, 255, 0.12); }
.home-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#open-lib { display: flex; }
#open-lib .lib { background: rgba(0, 0, 0, 0.2); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }

@media (max-width: 1240px) {
  .lib-stats { grid-template-columns: repeat(4, auto) ; }
  .lib-stat.spark { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .lib-stat.spark .lib-spark { width: min(100%, 420px); }
}
@media (max-width: 900px), (max-aspect-ratio: 9/10) {
  .modal-card.open-card { height: calc(var(--app-h) - 24px); padding: 16px 14px; }
  .open-grid { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 12px; }
  .open-side .load-lead, .open-note { display: none; }
  .home-btn { margin-top: 8px; height: 34px; }
  .lib-head { padding: 14px 14px 2px; }
  .lib-bar { padding: 6px 14px 10px; }
  .lib-body { padding: 12px 10px 18px; }
  /* 対局・平均着順・合計を 1 行に、着順と推移はそれぞれ 1 行に（dense で、着順の行の前の空きに合計を詰める） */
  .lib-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-flow: dense; }
  .lib-stat.dist { grid-column: 1 / -1; }
  .lib-stat > b { font-size: 20px; }
  .lib-card, .lib-card.pb { grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; padding: 10px; }
  .lib-go { display: none; }
  .lib-medal { width: 42px; height: 42px; padding-top: 8px; }
  .lib-medal b { font-size: 22px; }
  .lib-pbface .lib-face { width: 38px; height: 38px; }
  .lib-players { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 10px; }
  .lib-side { gap: 6px; }
  .lib-mypt { font-size: 18px; }
  .lib-acts { flex-direction: column; align-items: stretch; }
  .lib-others { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .lib-card, .lib-dist i, .lib-medal.r1::after, .lib-flow, .lib-skel i, .loader.home.has-lib .home-lib { animation: none; }
  .lib-spark .line { animation: none; stroke-dashoffset: 0; }
  .lib-medal.spin i { animation-duration: 2.4s; }
}

/* 読み込み */
.loader { background: radial-gradient(120% 90% at 50% 20%, rgba(20, 16, 50, 0.1), rgba(2, 4, 14, 0.75)); place-items: end center; padding-bottom: 8vh; }
.load-card { width: min(520px, 100%); text-align: center; }
.load-logo { font-weight: 800; font-size: 20px; color: var(--muted); }
.load-logo span { font-weight: 900; font-size: 28px; letter-spacing: 0.08em; background: linear-gradient(90deg, #d7b8ff, var(--naga)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.load-lead { color: var(--muted); }
.drop {
  position: relative; display: grid; gap: 4px; padding: 26px 16px; margin: 14px 0; border-radius: 16px; cursor: pointer;
  border: 2px dashed rgba(190, 160, 255, 0.4); background: rgba(166, 122, 224, 0.08); transition: background 0.2s, border-color 0.2s;
}
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.over { background: rgba(166, 122, 224, 0.2); border-color: var(--naga); }
.drop span { color: var(--muted); font-size: 12px; }
.url-form { display: flex; gap: 8px; }
.url-form input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.05); color: var(--text); font: inherit; }
.url-form button, .sample-btn { height: 40px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--naga); color: #fff; font-weight: 800; cursor: pointer; }
.sample-btn { margin-top: 12px; width: 100%; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line-strong); }
/* 上部のボタン: 切り替え（他家の手牌）とメニュー（リンク） */
.icon-btn.toggle .i-off { display: none; }
.icon-btn.toggle[aria-pressed="false"] .i-on { display: none; }
.icon-btn.toggle[aria-pressed="false"] .i-off { display: inline; }
.icon-btn.toggle[aria-pressed="true"] { border-color: color-mix(in srgb, var(--naga) 60%, transparent); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 260px; display: grid; padding: 6px; border-radius: 12px;
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.menu[hidden] { display: none; }
.menu button {
  display: grid; gap: 1px; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text);
  font: inherit; font-weight: 800; font-size: 13px; cursor: pointer;
}
.menu button small { color: var(--muted); font-weight: 600; font-size: 11px; }
.menu button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.menu button:disabled { opacity: 0.4; cursor: default; }
.playback-card { width: min(520px, 100%); }
.playback-card a { color: var(--type-text); }
.pb-label { font-weight: 800; font-size: 13px; margin: 14px 0 6px; display: grid; gap: 2px; }
.pb-label small { color: var(--muted); font-weight: 600; font-size: 11px; }
.pb-seg { flex-wrap: wrap; }
.pb-seg button:disabled { opacity: 0.35; cursor: default; }
.load-hint { color: var(--faint); font-size: 11px; margin: 6px 0 14px; overflow-wrap: anywhere; }
.load-hint.ok { color: var(--good); }
.load-hint.bad { color: #ffb3c0; }
.load-error a { color: #fff; font-weight: 800; }
.load-error { color: #ffb3c0; background: rgba(255, 84, 112, 0.12); border-radius: 10px; padding: 8px 12px; }
/* ---- 読み込み画面 ----------------------------------------------------------
   NAGA のマーク（蛇の瞳のひし形）が 3.6 秒の周期でゆっくり呼吸する: 光のにじみが強まるのに合わせて、面を光がなで、瞳が細くなる。
   動きは変形と透明度だけで作る（3D の準備でページの処理が詰まっても止まらない）。すぐに読み終わるときは何も見せないよう、中身は少し遅れて現れる */
.splash { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: #02040c; transition: opacity 0.7s ease; }
.splash.done { opacity: 0; pointer-events: none; }
.splash-inner { display: grid; gap: 20px; justify-items: center; animation: splash-in 0.6s 0.25s both ease-out; transition: transform 0.7s ease; }
.splash.done .splash-inner { transform: scale(1.04); }
@keyframes splash-in { from { opacity: 0; } }
.splash-mark { position: relative; width: 60px; height: 60px; margin-bottom: 4px; }
.splash-mark > * { position: absolute; inset: 0; width: 100%; height: 100%; }
/* 画面のアイコン用の svg の線（全体の指定）を、マークでは引かない */
.splash-mark svg { stroke: none; }
.sm-glow {
  inset: -60%; width: auto; height: auto; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(150, 105, 255, 0.5), rgba(150, 105, 255, 0) 72%);
  animation: sm-glow 3.6s ease-in-out infinite;
}
@keyframes sm-glow { 0%, 100% { opacity: 0.35; transform: scale(0.9); } 50% { opacity: 0.9; transform: scale(1.06); } }
.sm-sheen { overflow: hidden; clip-path: polygon(50% 1%, 99% 50%, 50% 99%, 1% 50%); }
.sm-sheen i {
  position: absolute; top: -20%; bottom: -20%; left: 0; width: 45%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
  transform: translateX(-130%) skewX(-18deg); animation: sm-sheen 3.6s ease-in-out infinite;
}
@keyframes sm-sheen { 0%, 30% { transform: translateX(-130%) skewX(-18deg); } 70%, 100% { transform: translateX(260%) skewX(-18deg); } }
.sm-pupil { animation: sm-pupil 3.6s ease-in-out infinite; }
@keyframes sm-pupil { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(0.55); } }
.splash-text { color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; min-height: 1.5em; }
/* 進み具合は戻らず、滑らかに伸びる（幅ではなく横の拡大で描く） */
.splash-bar { position: relative; width: 168px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.splash-bar div {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, #7a4fe0, #c9a8ff); transition: transform 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) {
  .splash-inner, .sm-glow, .sm-sheen i, .sm-pupil { animation: none !important; }
  .sm-sheen { display: none; }
  .sm-glow { opacity: 0.6; }
}
.toast {
  position: fixed; left: 50%; top: calc(var(--top-h) + 14px); transform: translate(-50%, -10px); z-index: 70; pointer-events: none;
  padding: 8px 16px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--line-strong); font-weight: 800;
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 狭い画面 ----------------------------------------------------------- */
@media (max-width: 1180px) {
  :root { --panel-w: 330px; }
  /* パネルが狭いので、少し小さくして横 1 列に収める（2 段にすると吹き出しの上が高くなり、判断の内訳が上へ押し上げられる）。
     6 タイプで 6 × 34 + 5 × 2 = 214px（ワイプの右の 224px に収まる） */
  .type-picks { flex-wrap: nowrap; gap: 2px; --tp-face: 24px; --tp-tile: 19px; --tp-w: 34px; }
  .tpk-pick img { margin-left: -4px; }
  .left-col { width: 220px; }
  .round-chip .dora img { height: 38px; }
  .player .sub .dan { display: none; } /* 期待順位の数字を優先して見せる */
  /* 幅が足りないときは上部のボタンを記号だけにし、文字の縦の折り返しを防ぐ */
  .icon-btn span { display: none; }
  .icon-btn { padding: 0 9px; }
  .seg button { white-space: nowrap; padding: 0 9px; }
}
@media (max-width: 900px), (max-aspect-ratio: 9/10) {
  :root { --dock-h: 120px; --top-h: 50px; }
  .icon-btn span { display: none; }
  .icon-btn { padding: 0 9px; }
  /* 狭い画面では、局とドラ表示を 4 人と同じ段に置く（局の欄は中身の幅だけ。本場・供託・残りは局の下に短い表記で） */
  .left-col { left: 8px; right: 8px; width: auto; top: calc(var(--top-h) + 2px); gap: 4px; grid-template-columns: auto minmax(0, 1fr); align-items: stretch; }
  .round-chip {
    display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; align-items: center; align-content: center;
    gap: 2px 6px; padding: 4px 7px; border-radius: 12px;
  }
  .round-chip .rc-head { grid-column: 1; grid-row: 1; }
  .round-chip .round { font-size: 15px; line-height: 1.1; }
  .round-chip .meta { display: none; }
  .round-chip .meta-s { display: block; grid-column: 1; grid-row: 2; color: var(--muted); font-size: 9.5px; line-height: 1.2; font-variant-numeric: tabular-nums; }
  .round-chip .dora { grid-column: 2; grid-row: 1 / 3; display: grid; justify-items: center; gap: 1px; }
  .round-chip .dora .lbl { font-size: 8.5px; line-height: 1; }
  .round-chip .dora .tiles { gap: 2px; }
  .round-chip .dora img { height: 26px; border-radius: 3px; }
  /* プレイヤーカード（狭い画面）: 1 行目に名前と点数、2 行目に席（自家・下家など）と聴牌率。
     幅 600px 未満では 4 人を 2×2 に並べ、文字が重ならない幅を取る（局の欄は左で 2 段分の高さを使う） */
  .scoreboard { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .player { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; align-items: center; padding: 5px 8px; gap: 2px 8px; }
  .player .wind { display: none; }
  .player .name-row { grid-column: 1 / -1; }
  .player .name { font-size: 12px; }
  .player .score { font-size: 12px; }
  .player .sub { grid-column: 1; display: flex; gap: 4px; font-size: 10px; }
  .player .sub .wind-s, .player .sub .dan, .player .sub .ex { display: none; }
  .player .tp { grid-column: 2; grid-template-columns: minmax(0, 1fr) minmax(30px, auto); gap: 4px; }
  .player .tp > span:first-child { display: none; }
  .player .tp b { font-size: 10px; }
  .player .badges { left: 6px; top: -8px; } /* 右上は点数があるので左上に */
  .player .badge.you { display: none; } /* 視点のカードは紫の地と「自家」で分かるので、狭い画面では札を省く */
  .player .badge { font-size: 8.5px; padding: 0 4px; border-radius: 5px; }
  .naga-panel {
    left: 8px; right: 8px; width: auto; top: auto; bottom: calc(var(--dock-h) + 16px); max-height: 52vh; justify-content: flex-start;
  }
  /* スマホの解説シートは、吹き出しを上にして判断をその下に開く */
  .naga-head { order: 0; align-items: start; }
  /* ほかのタイプの選択は、狭い画面では置く場所がないので出さない */
  .type-picks { display: none; }
  .naga-head { grid-template-rows: auto; }
  .naga-head > .naga-avatar, .naga-head > .bubble, .naga-head > .sheet-toggle { grid-row: 1; }
  .naga-body { order: 1; }
  .naga-head { grid-template-columns: 64px 1fr auto; }
  .naga-avatar { width: 64px; height: 64px; border-radius: 16px; }
  .naga-avatar::after { font-size: 9px; bottom: 4px; padding: 0 5px; }
  .bubble { min-height: 44px; padding: 8px 10px; font-size: 13px; }
  .bubble::before { top: 14px; bottom: auto; }
  .sheet-toggle {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--glass); cursor: pointer; transition: transform 0.2s;
  }
  .naga-panel.collapsed .naga-body { display: none; }
  .naga-panel.collapsed .sheet-toggle svg { transform: rotate(180deg); }
  .dock { width: calc(100vw - 16px); padding: 8px; bottom: max(8px, env(safe-area-inset-bottom)); }
  .nav { gap: 3px; }
  .nav button { min-width: 0; flex: 1; padding: 0 4px; height: 36px; }
  .nav button span { display: none; }
  .nav button.step { min-width: 0; }
  .nav button.play { flex: none; width: 44px; height: 44px; }
  .yaku4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .yaku4 .yk.wide3 { grid-column: auto; }
  .yaku4 .yk.wide4 { grid-column: span 2; }
  #result-modal { display: grid; place-items: end stretch; padding: 8px 8px calc(var(--dock-h) + 16px); }
  #result-modal .modal-card { position: relative; left: auto; top: auto; width: 100%; max-height: calc(var(--app-h) * 0.6); padding: 14px 14px 12px; transition: none; }
  #result-modal .modal-card h2 { font-size: 15px; }
  #result-modal .modal-actions { margin-top: 10px; }
  .deltas { margin-top: 6px; border-spacing: 0 2px; }
  .deltas th, .deltas td { padding: 1px 6px; }
  .deltas .d { font-size: 15px; }
}
@media (max-width: 600px) {
  /* 4 人を局の欄と同じ 1 段に並べ、縦の場所を取らない（卓を大きく写す）。カードの幅が狭いので、中は 3 行にする:
     名前 / 席（自家・下家など）と点数 / 聴牌率。名前と点数を同じ行に置かないので、文字は重ならない */
  .scoreboard { gap: 3px; }
  .player { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto; align-content: center; padding: 4px 5px 4px 7px; gap: 1px 3px; border-radius: 10px; }
  .player::before { top: 6px; bottom: 6px; }
  .player .name-row { display: contents; }
  .player .name { grid-column: 1 / -1; grid-row: 1; font-size: 11px; line-height: 1.2; }
  .player .sub { grid-column: 1; grid-row: 2; font-size: 9.5px; line-height: 1.2; }
  .player .score { grid-column: 2; grid-row: 2; font-size: 11px; line-height: 1.2; }
  .player .tp { grid-column: 1 / -1; grid-row: 3; grid-template-columns: minmax(0, 1fr) auto; gap: 3px; }
  .player .tp b { font-size: 9px; }
  .round-chip { gap: 1px 4px; padding: 4px 6px; }
  .round-chip .round { font-size: 13px; }
  .round-chip .meta-s { font-size: 9px; }
  .round-chip .dora img { height: 24px; }
}
@media (max-width: 520px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .top-actions { gap: 4px; }
  .seg { padding: 2px; gap: 2px; }
  .seg button { padding: 0 7px; height: 30px; font-size: 12px; }
  .icon-btn { width: 34px; height: 34px; padding: 0; justify-content: center; }
  /* 入りきらないボタンは横にスクロールする。メニューはスクロールの枠で切れないように、画面に対して置く */
  .top-actions { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions > * { flex: none; }
  .top-actions .menu { position: fixed; right: 8px; top: calc(var(--top-h) + 2px); }
  .round-chip .meta { display: none; }
}
@media (max-width: 380px) {
  /* 1 段に並べたカードがさらに狭いときは、席を 1 文字（自・下・対・上）にして点数と並べる */
  .player .rel { font-size: 0; }
  .player .rel::before { content: attr(data-short); font-size: 9.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---- 復習（局面クイズ） ------------------------------------------------------
   指摘された局面だけを出題し、手牌から切る牌を選んでもらう。出題中はタイムラインと移動のボタンの代わりに、
   下のバーへ進み具合と答えるボタンを出す。答えたあとは解説パネルに答え合わせを出し、最後に結果の画面を卓の右に出す */
.icon-btn.quiz-btn { border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.icon-btn.quiz-btn svg { color: var(--gold); }
body.quiz-mode .icon-btn.quiz-btn { background: color-mix(in srgb, var(--gold) 22%, var(--glass)); }
/* 出題中は吹き出しを必ず出す（問いかけと答え合わせを NAGA が話すので） */
body.quiz-mode .bubble { visibility: visible !important; }
body.quiz-mode .dock > .timeline, body.quiz-mode .dock > .tl-legend, body.quiz-mode .dock > .nav { display: none; }
/* 結果の画面: 情報の列・解説・下のバーは隠し、結果のカードの外に解説席の NAGA たちを写す */
body.quiz-over .left-col, body.quiz-over .naga-panel, body.quiz-over .dock, body.quiz-over .labels, body.quiz-over .callouts { display: none; }

/* 下のバー */
.quiz-dock { grid-row: 1 / -1; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 4px; min-height: 0; }
.qd-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.qd-title { display: inline-flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; font-size: 12px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.qd-title b { padding: 1px 8px; border-radius: 6px; background: var(--gold); color: #221600; font-size: 11px; letter-spacing: 0.08em; }
.qd-set { overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.qd-progress { flex: 1 1 auto; display: flex; gap: 3px; margin: 0; padding: 0; list-style: none; min-width: 60px; }
.qd-progress li { flex: 1 1 0; max-width: 30px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); transition: background 0.3s; }
.qd-progress li.done { background: var(--g); }
.qd-progress li.now { box-shadow: 0 0 0 1.5px #fff; }
.qd-progress li.cur { background: rgba(255, 255, 255, 0.35); }
.qd-count { font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qd-count b { font-size: 15px; color: var(--text); }
.qd-quit { height: 26px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800; color: var(--muted); }
.qd-quit:hover { color: var(--text); border-color: var(--line-strong); }
.qd-main { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 0; }
.qd-prompt { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: baseline; gap: 0 8px; line-height: 1.3; }
.qd-q { grid-row: span 2; align-self: center; padding: 3px 9px; border-radius: 9px; background: rgba(255, 255, 255, 0.1); font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; }
.qd-where { font-size: 11px; color: var(--muted); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-ask { grid-column: 2; font-size: 17px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-prompt small { grid-column: 2; font-size: 11px; color: var(--faint); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 局面（1 行目）と問い（2 行目）。操作の案内は問いの右に並べて、下のバーに 2 行で収める */
.qd-where { grid-column: 2 / 4; grid-row: 1; }
.qd-ask { grid-row: 2; }
.qd-prompt small { grid-column: 3; grid-row: 2; }
.qd-pick { flex: none; display: grid; place-items: center; width: 36px; height: 48px; }
.qd-pick img { height: 46px; border-radius: 5px; box-shadow: 0 0 0 2px #fff, 0 4px 14px rgba(0, 0, 0, 0.5); animation: qd-pop 0.25s cubic-bezier(0.2, 1.6, 0.4, 1); }
.qd-slot { width: 32px; height: 44px; border-radius: 6px; border: 2px dashed rgba(255, 255, 255, 0.28); }
@keyframes qd-pop { from { transform: translateY(6px) scale(0.85); opacity: 0.4; } }
.qd-go { flex: none; height: 40px; padding: 0 18px; font-size: 14px; white-space: nowrap; }
.btn:disabled { opacity: 0.4; cursor: default; }
.qd-grade {
  flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--g) 16%, transparent); border: 1px solid color-mix(in srgb, var(--g) 55%, transparent);
  color: var(--g); font-weight: 900; font-size: 16px; white-space: nowrap; animation: qd-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.qd-grade i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--g); color: #141625; font-style: normal; font-size: 20px; line-height: 1; }
.qd-compare { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 14px; }
.qd-compare > span { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 12px; white-space: nowrap; }
.qd-compare em { font-style: normal; font-size: 11px; color: var(--muted); }
.qd-compare img { height: 40px; border-radius: 4px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); }
.qd-compare b { font-variant-numeric: tabular-nums; font-size: 14px; }
.qd-you img { box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.45); }
.qd-type em { color: var(--c-text); }
.qd-type img { box-shadow: 0 0 0 2px var(--c-edge), 0 2px 6px rgba(0, 0, 0, 0.45); }
.qd-then em { color: #ff6b85; }
.qd-then img { box-shadow: 0 0 0 2px #ff1238, 0 2px 6px rgba(0, 0, 0, 0.45); }

/* 答え合わせのカード（解説パネル） */
.quiz-card > header { margin-bottom: 8px; }
.quiz-card h2 { color: var(--text); font-size: 14px; }
.qc-q { font-size: 11px; color: var(--muted); font-weight: 800; }
.qc-grade { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, var(--g) 12%, transparent); border: 1px solid color-mix(in srgb, var(--g) 40%, transparent); }
.qc-grade .mark { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--g); color: #141625; font-size: 26px; font-weight: 900; line-height: 1; animation: qd-pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); }
.qc-grade b { display: block; font-size: 18px; color: var(--g); font-weight: 900; }
.qc-grade small { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.qc-rows { display: grid; gap: 6px; margin-top: 10px; }
.qc-row { display: grid; grid-template-columns: 52px 30px minmax(0, 1fr) 48px; gap: 8px; align-items: center; font-weight: 800; }
.qc-row:has(.qc-sev) { grid-template-columns: 52px 30px minmax(0, 1fr) 48px auto; }
.qc-row .who { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qc-row.you .who { color: #fff; }
.qc-row.type .who { color: var(--type-text); }
.qc-row.then .who { color: #ff6b85; }
.qc-row img { width: 30px; border-radius: 4px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); }
.qc-row.you img { box-shadow: 0 0 0 2px #fff, 0 2px 5px rgba(0, 0, 0, 0.4); }
.qc-row.type img { box-shadow: 0 0 0 2px var(--type-edge), 0 2px 5px rgba(0, 0, 0, 0.4); }
.qc-row.then img { box-shadow: 0 0 0 2px #ff1238, 0 2px 5px rgba(0, 0, 0, 0.4); }
.qc-row > b { text-align: right; font-variant-numeric: tabular-nums; }
.qc-bar { display: block; height: 12px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45); }
.qc-bar i {
  display: block; height: 100%; border-radius: inherit; animation: qc-grow 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 62%, #fff) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 80%, #000) 100%);
  box-shadow: inset -3px 0 0 color-mix(in srgb, var(--c) 30%, #fff);
}
@keyframes qc-grow { from { width: 0; } }
html[data-type-mono="black"] .qc-bar i { background: linear-gradient(180deg, #5a5e70 0%, #1b1c25 40%, #050508 100%); box-shadow: inset 0 0 0 1px #c9cedc, inset -3px 0 0 #f4f6fb; }
.qc-sev { font-size: 10px; font-weight: 900; color: var(--g); padding: 1px 6px; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--g) 60%, transparent); white-space: nowrap; }
.qc-cap { margin-top: 4px; font-size: 10.5px; color: var(--faint); text-align: right; }
/* この一打を対局で打てていたら、対局の類似度がどう変わったか */
.qc-impact { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 8px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); font-size: 12px; font-weight: 700; color: var(--muted); }
.qc-impact b { font-size: 16px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qc-impact.plus b { color: var(--good); }
.qc-impact.minus b { color: var(--bad); }
.qc-tops { margin-top: 10px; }
.qc-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.qc-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 7px; border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--c-edge) 45%, transparent); background: rgba(255, 255, 255, 0.03); opacity: 0.85;
}
.qc-chip em { font-style: normal; font-size: 10.5px; font-weight: 800; color: var(--c-text); }
.qc-chip img { height: 24px; border-radius: 3px; }
.qc-chip.sel { border-color: var(--c-edge); opacity: 1; }
.qc-chip.match { opacity: 1; background: rgba(255, 255, 255, 0.1); box-shadow: 0 0 0 1.5px #fff; }
.qc-note { margin-top: 10px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); font-size: 12px; font-weight: 700; color: var(--muted); }
.qc-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; font-size: 10.5px; color: var(--faint); font-weight: 700; }
.qc-legend span { display: inline-flex; align-items: center; gap: 4px; }
.qc-legend i { width: 10px; height: 13px; border-radius: 3px; }
.lg-you { box-shadow: 0 0 0 2px #fff; }
.lg-type { box-shadow: 0 0 0 2px var(--c-edge); }
.lg-then { box-shadow: 0 0 0 2px #ff1238; }
/* 判断の内訳の札（復習: あなたの答え・当時の打牌） */
.tag.you { color: #10132a; background: #fff; border-color: #fff; }
.tag.then { color: #ff6b85; }
.cand.pick img { box-shadow: 0 0 0 2px #fff, 0 2px 5px rgba(0, 0, 0, 0.4); }

/* 始める前の設定 */
.quiz-setup { width: min(620px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.quiz-setup > header, .quiz-setup > .modal-actions { flex: none; }
.qs-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px 2px; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.qs-body:hover { scrollbar-color: rgba(200, 210, 255, 0.28) transparent; }
.quiz-setup > .modal-actions { margin-top: 14px; }
.qs-lead { color: var(--muted); font-size: 13px; margin: 8px 0 4px; line-height: 1.6; }
.qs-label { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 6px; font-weight: 800; font-size: 13px; }
.qs-label small { color: var(--faint); font-weight: 600; font-size: 11px; }
.qs-seats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.qs-seats button { height: auto; min-height: 40px; display: grid; justify-items: center; align-content: center; gap: 0; padding: 4px 6px; min-width: 0; line-height: 1.25; }
.qs-seats .nm { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.qs-seats small { font-size: 10px; font-weight: 800; }
.qs-sets { display: grid; gap: 8px; }
.qs-set {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); transition: border-color 0.15s, background 0.15s;
}
.qs-set:hover { border-color: var(--line-strong); }
.qs-set.on { border-color: color-mix(in srgb, var(--gold) 70%, transparent); background: color-mix(in srgb, var(--gold) 9%, transparent); }
.qs-radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; }
.qs-set.on .qs-radio { border-color: var(--gold); }
.qs-set.on .qs-radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.qs-set-text { display: grid; gap: 2px; min-width: 0; }
.qs-set-text b { font-size: 14px; }
.qs-set-text small { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.qs-th { margin-top: 6px; justify-self: start; padding: 2px; }
.qs-th button { height: 24px; padding: 0 10px; font-size: 12px; }
.qs-n { display: flex; align-items: baseline; gap: 2px; white-space: nowrap; }
.qs-n b { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.qs-n small { font-size: 11px; color: var(--muted); font-weight: 800; }
.qs-set.none .qs-n { opacity: 0.4; }
.qs-empty { margin: 8px 0 0; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); color: var(--muted); font-size: 12px; font-weight: 700; }
.qs-types { gap: 4px; }
.qs-types button { font-size: 12px; padding: 4px 10px; }
.qs-opts { display: flex; flex-wrap: wrap; gap: 0 24px; }
.btn.qs-last { margin-right: auto; }
.btn.review { border-color: color-mix(in srgb, var(--gold) 55%, transparent); color: #ffe39a; }

/* 結果の画面: 卓の右に置き、左の空いた所に解説席の NAGA たちを写す（カメラは main.js が向ける） */
#quiz-result-modal { background: linear-gradient(90deg, transparent 40%, rgba(2, 4, 14, 0.35)); pointer-events: none; display: block; padding: 0; }
#quiz-result-modal[hidden] { display: none; }
.quiz-result {
  position: absolute; right: 14px; top: calc(var(--top-h) + 6px); bottom: max(14px, env(safe-area-inset-bottom)); pointer-events: auto;
  width: min(580px, calc(100vw - 28px)); max-height: none; padding: 16px 18px 14px; display: flex; flex-direction: column; overflow: hidden;
  animation: qr-in 0.5s cubic-bezier(0.2, 1, 0.3, 1);
}
@keyframes qr-in { from { transform: translateX(40px); opacity: 0; } }
.quiz-result > header, .quiz-result > .modal-actions { flex: none; }
.qr-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.qr-body:hover { scrollbar-color: rgba(200, 210, 255, 0.28) transparent; }
.qr-actions { margin-top: 12px; flex-wrap: wrap; }
.qr-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.qr-sub b { color: var(--text); }
.qr-type { margin-left: auto; padding: 1px 8px; border-radius: 6px; background: var(--c); color: var(--c-ink); border: 1px solid var(--c-edge); font-size: 11px; font-weight: 900; }
.qr-naga { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.qr-name { flex: none; padding: 2px 9px; border-radius: 7px; background: var(--c); color: var(--c-ink); border: 1px solid var(--c-edge); font-size: 11px; font-weight: 900; letter-spacing: 0.06em; }
.qr-say {
  position: relative; flex: 1 1 auto; padding: 9px 13px; border-radius: 14px; background: #faf7ff; color: #1d1540; font-weight: 700; font-size: 13.5px; line-height: 1.55;
}
.qr-say::before { content: ""; position: absolute; left: -7px; top: 50%; translate: 0 -50%; border: 7px solid transparent; border-right-color: #faf7ff; border-left: 0; }
.qr-say .em {
  color: #1d1540; font-weight: 900; padding: 0 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone;
  background: linear-gradient(transparent 58%, color-mix(in srgb, var(--type-mark, #b58cff) 60%, transparent) 58%);
}
.qr-hero {
  position: relative; display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 14px 18px;
  margin-top: 14px; padding: 16px 16px; border-radius: 18px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
}
.qr-hero.gold { border-color: rgb(255 214 90 / calc(0.2 + 0.3 * var(--g))); }
.qr-hero.g5 { border-color: rgb(255 214 90 / 0.7); background: radial-gradient(90% 120% at 30% 50%, rgb(255 200 60 / 0.12), transparent 60%), rgba(255, 255, 255, 0.04); }
.qr-cap { grid-column: 1 / -1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; font-weight: 900; color: var(--text); }
.qr-cap small { font-size: 11px; font-weight: 700; color: var(--faint); }
.qr-ring { position: relative; width: 112px; height: 112px; }
.qr-ring svg { width: 112px; height: 112px; transform: rotate(-90deg); stroke-width: 9; fill: none; }
.qr-ring .bg { stroke: rgba(255, 255, 255, 0.09); }
.qr-ring .fg { stroke: var(--good); stroke-linecap: round; filter: drop-shadow(0 0 6px rgb(61 220 151 / 0.45)); }
.qr-hero.perfect .qr-ring .fg { stroke: #ffd34d; filter: drop-shadow(0 0 8px rgb(255 200 60 / 0.6)); }
.qr-correct { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; line-height: 1; }
.qr-correct b { font-size: 38px; font-weight: 900; font-variant-numeric: tabular-nums; }
.qr-correct small { font-size: 12px; color: var(--muted); font-weight: 800; margin-top: 2px; }
.qr-correct span { font-size: 11px; color: var(--muted); font-weight: 900; letter-spacing: 0.12em; margin-top: 4px; }
.qr-sim.sum-sim { padding: 8px 14px 6px; }
.qr-gain-big { position: relative; z-index: 1; font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--muted); animation: qr-perfect 0.5s 1.25s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.qr-gain-big.plus { color: var(--good); }
.qr-gain-big.minus { color: var(--bad); }
.qr-sim.sum-sim .val { font-size: 52px; }
.qr-sim.sum-sim.gold .val { font-size: calc(52px + 6px * var(--g)); }
.qr-then { display: grid; gap: 5px; min-width: 0; }
.qr-then div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; font-weight: 800; color: var(--muted); }
.qr-then span { flex: none; white-space: nowrap; }
.qr-then b { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qr-then b small { font-size: 10px; color: var(--muted); margin-left: 3px; }
.qr-up.plus b { color: var(--good); }
.qr-up.minus b { color: var(--bad); }
.qr-perfect {
  position: absolute; left: 50%; top: -13px; translate: -50% 0; padding: 2px 16px; border-radius: 999px; z-index: 3;
  background: linear-gradient(180deg, #fff6d0, #ffd34d 45%, #c98a0b); color: #3a2600; font-weight: 900; font-size: 13px; letter-spacing: 0.32em;
  box-shadow: 0 4px 16px rgb(255 190 40 / 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.7); animation: qr-perfect 0.7s 0.9s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes qr-perfect { from { transform: scale(0.3); opacity: 0; } }
.qr-grades { margin-top: 12px; }
.qr-bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; }
.qr-bar i { background: var(--g); transform-origin: left; animation: qr-bar 0.8s 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes qr-bar { from { transform: scaleX(0); } }
.qr-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 7px; font-size: 12px; font-weight: 800; color: var(--muted); }
.qr-legend span { display: inline-flex; align-items: center; gap: 5px; }
.qr-legend i { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--g); color: #141625; font-style: normal; font-size: 11px; line-height: 1; }
.qr-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.qr-legend .zero { opacity: 0.4; }
.qr-legend .qr-any { margin-left: auto; font-size: 11px; color: var(--faint); }
.qr-list-h { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; margin: 14px 0 6px; font-size: 12px; font-weight: 800; color: var(--muted); }
.qr-list-h small { margin-left: 8px; font-size: 10.5px; font-weight: 700; color: var(--faint); }
.qr-keys { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--faint); }
.qr-keys i { width: 9px; height: 12px; border-radius: 2px; margin-left: 6px; }
.qr-keys i.you { box-shadow: 0 0 0 2px #fff; }
.qr-keys i.type { box-shadow: 0 0 0 2px var(--c-edge); }
.qr-keys i.then { box-shadow: 0 0 0 2px #ff1238; }
.qr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.qr-row {
  display: grid; grid-template-columns: 34px 22px minmax(0, 1fr) auto 50px auto; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); border-left: 3px solid var(--g, var(--line)); animation: qr-row 0.4s calc(0.5s + min(var(--d), 14) * 0.05s) ease-out both;
}
@keyframes qr-row { from { transform: translateX(12px); opacity: 0; } }
.qr-row.skip { grid-template-columns: 34px minmax(0, 1fr) auto auto; opacity: 0.65; }
.qr-gain { text-align: right; font-size: 12px; font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qr-gain.plus { color: var(--good); }
.qr-gain.minus { color: var(--bad); }
.qr-no { font-size: 11px; font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; }
.qr-mark { font-size: 18px; font-weight: 900; color: var(--g); text-align: center; line-height: 1; }
.qr-where { font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-skip { font-size: 11px; color: var(--faint); font-weight: 800; }
.qr-tiles { display: flex; gap: 8px; }
.qr-t { display: grid; justify-items: center; gap: 2px; }
.qr-t img { height: 30px; border-radius: 3px; }
.qr-t small { font-size: 9.5px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.qr-t.you img { box-shadow: 0 0 0 2px #fff; }
.qr-t.type img { box-shadow: 0 0 0 2px var(--c-edge); }
.qr-t.then img { box-shadow: 0 0 0 2px #ff1238; }
.qr-see { height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800; color: var(--muted); }
.qr-see:hover { color: var(--text); border-color: var(--line-strong); }

@media (max-width: 1180px) {
  .qd-set { max-width: 160px; }
}
@media (max-width: 900px), (max-aspect-ratio: 9/10) {
  .quiz-dock { gap: 6px; }
  .qd-title .qd-set { display: none; }
  .qd-main { gap: 8px; }
  .qd-q { font-size: 13px; padding: 2px 7px; }
  .qd-ask { font-size: 15px; }
  .qd-prompt small { display: none; }
  .qd-pick { width: 32px; height: 44px; }
  .qd-pick img { height: 42px; }
  .qd-slot { width: 28px; height: 40px; }
  .qd-go { height: 42px; padding: 0 12px; font-size: 13px; }
  .qd-grade { font-size: 13px; padding: 3px 10px 3px 4px; gap: 6px; }
  .qd-grade i { width: 28px; height: 28px; font-size: 16px; }
  .qd-compare { gap: 8px; justify-content: flex-start; }
  .qd-compare > span { gap: 3px; }
  .qd-compare img { height: 34px; }
  .qd-compare b { font-size: 11px; }
  /* 結果: 下のシートにして、上の空いた所に NAGA たちを写す */
  #quiz-result-modal { background: linear-gradient(180deg, transparent 30%, rgba(2, 4, 14, 0.35)); }
  .quiz-result {
    left: 8px; right: 8px; top: auto; bottom: max(8px, env(safe-area-inset-bottom)); width: auto; max-height: calc(var(--app-h) * 0.66); padding: 12px 12px 10px;
    animation-name: qr-up;
  }
  @keyframes qr-up { from { transform: translateY(40px); opacity: 0; } }
  .quiz-result h2 { font-size: 15px; }
  .qr-hero { grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; padding: 12px; }
  .qr-then { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 14px; }
  .qr-then b { font-size: 14px; }
  .qr-ring, .qr-ring svg { width: 92px; height: 92px; }
  .qr-correct b { font-size: 30px; }
  .qr-sim.sum-sim { justify-self: start; }
  .qr-sim.sum-sim .val { font-size: 44px; }
  .qr-sim.sum-sim.gold .val { font-size: calc(44px + 4px * var(--g)); }
  .qr-actions .btn { flex: 1 1 auto; padding: 0 10px; }
}
@media (max-width: 600px) {
  .qs-seats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qs-set { padding: 10px 12px; gap: 10px; }
  .qd-compare em { display: none; }
  .qr-row { grid-template-columns: 30px 18px minmax(0, 1fr) auto 42px; gap: 6px; }
  .qr-gain { font-size: 11px; }
  .qr-list-h small { display: block; margin: 1px 0 0; }
  .qr-row .qr-see { display: none; }
  .qr-row.skip { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .qr-t img { height: 26px; }
  .qr-tiles { gap: 5px; }
  .qr-type { margin-left: 0; }
}
@media (max-width: 420px) {
  .qd-compare b { display: none; }
  .qd-go { padding: 0 10px; }
  .qr-where { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .qr-row, .qr-bar i, .qr-perfect, .qr-gain-big, .qc-bar i, .qd-grade, .qc-grade .mark, .qd-pick img, .quiz-result { animation: none !important; }
}

/* ---- もしも局面（WHATIF.md） ------------------------------------------------
   今の局面の河・手牌・ドラ表示・点数を変えて、NAGA に聞く。変えている間はタイムラインと移動のボタンの代わりに、
   変更の数と NAGA に聞くボタンを下のバーに出す。変えた牌は卓で水色に光らせ、変えた所と比べた推奨は解説パネルのカードに出す */
:root { --whatif: #62d8ff; }
body.whatif-mode .dock > .timeline, body.whatif-mode .dock > .tl-legend, body.whatif-mode .dock > .nav { display: none; }
body.whatif-mode .bubble { visibility: visible !important; }
/* もしも局面: 左上の「ドラ表示」の牌もクリックして変えられる（山を表示しないときは卓に王牌がないため）。変えた牌は水色で囲む */
body.whatif-mode .round-chip .dora .tiles img { cursor: pointer; transition: box-shadow 0.15s; }
body.whatif-mode .round-chip .dora .tiles img:hover { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 2px 6px rgba(0, 0, 0, 0.5); }
body.whatif-mode .round-chip .dora .tiles img.whatif-changed { box-shadow: 0 0 0 2px var(--whatif), 0 0 10px var(--whatif); }
.whatif-dock { grid-row: 1 / -1; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 4px; min-height: 0; }
.wd-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wd-title { display: inline-flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; font-size: 12px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.wd-title b { padding: 1px 8px; border-radius: 6px; background: var(--whatif); color: #04202b; font-size: 11px; letter-spacing: 0.08em; }
.wd-where { overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.wd-count { flex: none; padding: 1px 9px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--whatif) 45%, transparent); font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wd-count b { font-size: 14px; color: var(--whatif); }
.wd-count.over { border-color: var(--bad); }
.wd-count.over b { color: var(--bad); }
.wd-msg { flex: 1 1 auto; min-width: 0; font-size: 11.5px; font-weight: 700; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wd-msg.bad { color: var(--bad); }
.wd-main { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 0; }
.wd-tools { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.wd-tool { height: 32px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); cursor: pointer; font-size: 12px; font-weight: 800; color: var(--text); white-space: nowrap; }
.wd-tool:hover:not(:disabled) { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.08); }
.wd-tool:disabled { opacity: 0.4; cursor: default; }
.wd-tool .s { display: none; }
.wd-go { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 18px; font-size: 14px; white-space: nowrap; color: inherit; text-decoration: none; }
.wd-go small { padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.22); font-size: 11px; font-weight: 800; }
.wd-np { flex: none; font-size: 11px; font-weight: 700; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wd-np b { font-size: 13px; color: var(--text); }
.wd-msg.note { color: var(--whatif); }

/* 解説パネルのカード */
.whatif-card { border-color: color-mix(in srgb, var(--whatif) 40%, var(--line)); }
.whatif-card h2 { color: var(--whatif); }
.wc-from { font-size: 11px; color: var(--faint); font-weight: 700; }
.wc-edits { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.wc-edits li { position: relative; padding-left: 14px; font-size: 12px; font-weight: 700; }
.wc-edits li::before { content: ''; position: absolute; left: 2px; top: 0.55em; width: 6px; height: 6px; border-radius: 50%; background: var(--whatif); }
.wc-empty { margin: 0; font-size: 12px; color: var(--faint); font-weight: 600; }
.wc-pat { margin-left: 8px; padding: 1px 7px; border-radius: 6px; background: color-mix(in srgb, var(--whatif) 22%, transparent); color: var(--text); font-size: 11px; letter-spacing: 0; }
/* 元の局面と、NAGA に聞いたパターンを横に並べる（多いときは横にスクロール） */
.wc-compare { display: grid; gap: 4px; margin-top: 10px; overflow-x: auto; }
.wc-row { display: grid; grid-template-columns: minmax(64px, 1fr) repeat(var(--wc-cols, 2), 62px); align-items: center; gap: 4px; padding: 2px 6px; border-radius: 8px; opacity: 0.8; }
.wc-head { font-size: 10.5px; color: var(--faint); font-weight: 800; opacity: 1; }
.wc-col { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-col[data-act] { cursor: pointer; }
.wc-col[data-act]:hover { color: var(--text); }
.wc-col.cur { color: var(--whatif); }
.wc-row.sel { background: rgba(255, 255, 255, 0.06); opacity: 1; }
.wc-row em { font-style: normal; font-size: 12px; font-weight: 800; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-cell { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-variant-numeric: tabular-nums; }
.wc-cell img { height: 26px; border-radius: 3px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); }
.wc-cell.changed img { box-shadow: 0 0 0 2px var(--whatif), 0 2px 5px rgba(0, 0, 0, 0.4); }
.wc-cell .none { color: var(--faint); }
/* 反応局面（鳴き・ロン）: 推奨の行動と推奨度、チーは使う 2 枚を下に */
.wc-compare.react .wc-row { grid-template-columns: minmax(64px, 1fr) repeat(var(--wc-cols, 2), 84px); }
.wc-cell.act { flex-wrap: wrap; row-gap: 2px; }
.wc-cell.act .a { font-size: 12px; }
.wc-cell.act .tl { flex-basis: 100%; display: inline-flex; gap: 2px; }
.wc-cell.act .tl img { height: 26px; }
.wc-cell.act.changed { border-radius: 4px; box-shadow: 0 0 0 2px var(--whatif); padding: 0 3px; }
/* 下のバーのパターンの切り替え */
.wd-pats { flex: none; display: inline-flex; align-items: center; gap: 3px; }
.wd-pats-l { font-size: 11px; font-weight: 800; color: var(--faint); margin-right: 2px; }
.wd-pat { position: relative; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 7px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; font-variant-numeric: tabular-nums; }
.wd-pat:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
.wd-pat.cur { background: color-mix(in srgb, var(--whatif) 30%, transparent); border-color: var(--whatif); color: var(--text); }
/* NAGA に聞いたパターンには点を付ける */
.wd-pat.asked::after { content: ''; position: absolute; right: 2px; top: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--whatif); }
.wd-pat.add, .wd-pat.del { color: var(--faint); }
.wd-pat:disabled { opacity: 0.35; cursor: default; }
.wc-note { margin: 8px 0 0; font-size: 10.5px; color: var(--faint); font-weight: 600; }

/* 牌を選ぶ小さい画面・点数などの入力 */
.tile-picker {
  position: fixed; z-index: 45; padding: 8px 10px 10px; border-radius: 14px; max-width: calc(100vw - 16px);
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.tile-picker[hidden] { display: none; }
.tp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 12px; }
.tp-x { width: 26px; height: 26px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; }
.tp-x:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.tp-grid { display: grid; gap: 3px; }
.tp-row { display: flex; gap: 3px; }
.tp-tile { padding: 2px; border-radius: 6px; border: 0; background: transparent; cursor: pointer; line-height: 0; }
.tp-tile img { height: 34px; aspect-ratio: 124 / 172; border-radius: 3px; } /* 縦横比を決めておく（画像を読む前に画面の大きさを測って置くので、読んだあとで幅が広がって画面からはみ出さないように） */
.tp-tile:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.tp-tile.cur { box-shadow: inset 0 0 0 2px var(--whatif); }
.tp-tile.orig:not(.cur) { box-shadow: inset 0 0 0 1px var(--line-strong); }
.tp-tile:disabled { opacity: 0.25; cursor: default; }
.tp-flags { display: flex; gap: 0; margin-top: 8px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); width: fit-content; }
.tp-flags button { height: 28px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); font-weight: 800; font-size: 12px; cursor: pointer; }
.tp-flags button[aria-pressed="true"] { background: color-mix(in srgb, var(--whatif) 28%, transparent); color: var(--text); }
.tp-flags button:disabled { opacity: 0.35; cursor: default; }
.tp-reset { display: block; margin-top: 8px; height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }
.tp-reset:hover { color: var(--text); border-color: var(--line-strong); }
/* 副露の候補の一覧。縦スクロールで、1 回押すと決まる。牌は卓と同じ並べ方（横向きは縦の牌を左へ 90 度倒す） */
.meld-picker { display: flex; flex-direction: column; width: 270px; max-height: calc(var(--app-h) - 16px); --th: 42px; --tw: calc(var(--th) * 124 / 172); }
.meld-picker[hidden] { display: none; }
.mp-tools { display: flex; align-items: center; gap: 2px; }
.mp-list { display: grid; grid-auto-rows: max-content; gap: 4px; min-height: 0; max-height: min(360px, calc(var(--app-h) - 72px)); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 2px; }
.mp-opt { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 4px 8px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.mp-opt:hover { background: rgba(255, 255, 255, 0.12); }
.mp-opt.cur { background: color-mix(in srgb, var(--whatif) 22%, transparent); border-color: var(--whatif); }
.mp-tiles { display: flex; align-items: flex-end; gap: 1px; min-width: 0; line-height: 0; }
.mp-col { display: flex; flex: none; flex-direction: column; gap: 1px; }
.mp-tile { position: relative; display: block; flex: none; width: var(--tw); height: var(--th); }
.mp-tile img { display: block; width: 100%; height: 100%; border-radius: 3px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.mp-tile.side { width: var(--th); height: var(--tw); }
.mp-tile.side img { position: absolute; left: 50%; top: 50%; width: var(--tw); height: var(--th); transform: translate(-50%, -50%) rotate(-90deg); }
.mp-mark { flex: none; margin-left: auto; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); font-size: 11px; font-weight: 800; line-height: 18px; white-space: nowrap; }
.mp-mark[hidden] { display: none; }
.mp-mark + .mp-mark { margin-left: 0; }
.mp-mark.warn { color: var(--bad); border-color: var(--bad); }
.whatif-numbers { width: 320px; }
.wn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.wn-grid label { display: grid; gap: 3px; font-size: 11px; font-weight: 800; color: var(--muted); min-width: 0; }
.wn-grid label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wn-grid input, .wn-grid select { height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.06); color: var(--text); font: inherit; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 0; }
.wn-grid .wn-score { display: flex; align-items: center; gap: 4px; min-width: 0; }
.wn-grid .wn-score input { flex: 1; width: 0; text-align: right; appearance: textfield; -moz-appearance: textfield; }
.wn-grid .wn-score input::-webkit-inner-spin-button, .wn-grid .wn-score input::-webkit-outer-spin-button { appearance: none; -webkit-appearance: none; margin: 0; }
/* 「00」だけ細く・薄く（入力欄は font: inherit なので、親に付けると欄の数字まで細くなり本場・供託の欄とそろわない） */
.wn-grid .wn-score > span { flex: none; overflow: visible; font-size: 13px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px), (max-aspect-ratio: 9/10) {
  .whatif-dock { gap: 6px; }
  .wd-where { display: none; }
  .wd-msg { display: none; }
  .wd-top .qd-quit { margin-left: auto; } /* 広い画面では伝言の欄が押し出す。狭い画面は伝言を出さないので、右端へ寄せる */
  .wd-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 5px; }
  .wd-tools::-webkit-scrollbar { display: none; }
  .wd-tool { height: 34px; padding: 0 9px; }
  .wd-tool .l { display: none; }
  .wd-tool .s { display: inline; }
  .wd-go { height: 42px; padding: 0 12px; font-size: 13px; }
  /* パターンを増やしても「もしも」・変更の数・「終わる」を押しつぶさない。入りきらないパターンのボタンは横にスクロールする */
  .wd-title { flex: none; }
  .wd-pats { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .wd-pats::-webkit-scrollbar { display: none; }
  .wd-pats > * { flex: none; }
  .wd-top .qd-quit { flex: none; white-space: nowrap; }
  .tp-tile img { height: 30px; }
  .meld-picker { --th: 36px; }
}
/* スマホの幅では、下のバーを 3 段にする: 上の段（もしも・パターン・変更・終わる）、道具の 4 つ（幅いっぱいに等分）、残りの NP と「NAGA に聞く」。
   道具と「NAGA に聞く」を 1 段に並べると（入るのは 560px くらいから）、390px の幅では道具に使えるのが 106px しかなく、
   「元に戻す」が途中で切れ、「エディタ」「コピー」は横にスクロールしないと見えなかった。そのぶん下のバーを 12px 高くする */
@media (max-width: 600px) {
  body.whatif-mode { --dock-h: 132px; }
  .wd-main { flex-wrap: wrap; align-content: center; row-gap: 6px; }
  .wd-tools { flex: 1 1 100%; } /* 320px より狭くて入りきらないときだけ、横にスクロールする */
  .wd-tool { flex: 1 1 auto; padding: 0 6px; }
  .wd-np { margin-right: auto; }
  .wd-go { flex: 1 1 auto; justify-content: center; }
}
/* 縦長のスマホでは、パターンのボタンを上の段（もしも・変更・終わる）の下の段に置く。最大の 8 個（＋・× を入れて 10 個）を
   320px の幅でも 1 段に収めるため、ボタンを少し詰める。そのぶん下のバーを 30px 高くする（縦長なので卓は小さくならない） */
@media (max-width: 600px) and (min-height: 500px) {
  body.whatif-mode { --dock-h: 162px; }
  .wd-top { flex-wrap: wrap; row-gap: 6px; }
  .wd-pats { order: 1; flex: 1 1 100%; gap: 2px; }
  .wd-pat { min-width: 22px; padding: 0 4px; }
}
/* まだ NAGA に聞いていないもしも局面では、判断の内訳と状況（聴牌率・順位の予測）を出さない（元の局面の値ではないため） */
body.whatif-pending #decision-card { display: none; }
body.whatif-pending #situation-card { visibility: hidden; }

/* ---- 段位pt分析（DANPT.md。danpt_ui.js） ---- */
.modal-card.danpt { width: min(1120px, 100%); padding: 18px 22px 16px; }
.danpt h2 { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: 20px; }
.dp-where { color: var(--muted); font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dp-sticks { margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11px; color: #ffe39a; background: rgba(255, 201, 77, 0.14); border: 1px solid rgba(255, 201, 77, 0.4); }
.dp-lead { margin: 6px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.dp-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--c); vertical-align: 1px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.danpt h3 { display: flex; align-items: center; margin: 0; font-size: 13px; font-weight: 900; }
.dp-sec-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 8px; }
.dp-hint { margin: 0; color: var(--faint); font-size: 11px; font-weight: 700; }
.danpt .plus { color: var(--good); }
.danpt .minus { color: var(--bad); }

/* 状況（局の開始・リーチ棒が出たあと）の切り替え */
.dp-sits { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.dp-sits button {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--muted); font-weight: 800; font-size: 12px;
}
.dp-sits button small { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.dp-sits button em { font-style: normal; font-size: 10px; padding: 0 6px; border-radius: 999px; color: var(--type-ink); background: var(--gold); }
.dp-sits button[aria-selected="true"] { color: var(--text); border-color: var(--line-strong); background: rgba(166, 122, 224, 0.22); }

/* 4 人の今の見通し */
.dp-players { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dp-player {
  display: grid; gap: 6px; padding: 10px 12px 9px; border-radius: 14px; cursor: pointer; text-align: left;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); border-top: 3px solid var(--c);
}
.dp-player:hover { background: rgba(255, 255, 255, 0.07); }
.dp-player.on { background: rgba(166, 122, 224, 0.2); border-color: rgba(200, 170, 255, 0.55); border-top-color: var(--c); box-shadow: 0 0 0 1px rgba(200, 170, 255, 0.35) inset; }
.dp-who { display: flex; align-items: baseline; gap: 6px; min-width: 0; font-size: 12px; font-weight: 800; color: var(--muted); }
.dp-who .rel { color: var(--c); }
.dp-who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--text); }
.dp-wind { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); color: var(--text); font-size: 12px; flex: none; }
.dp-wind.oya { background: #d63a3a; }
.dp-score { display: flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.dp-rc { font-style: normal; font-size: 10px; padding: 0 6px; border-radius: 999px; color: #ffe39a; border: 1px solid rgba(255, 201, 77, 0.55); }
.dp-ev { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.dp-ev b { font-size: 22px; font-weight: 900; }
.dp-ev small { color: var(--muted); font-size: 11px; font-weight: 800; }
.dp-ev .er { margin-left: auto; font-weight: 800; color: var(--muted); }
.dp-ev .er small { margin-left: 1px; }

/* 最終順位の確率の帯（1 位〜4 位を左から） */
.dp-bar { display: flex; height: 18px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.dp-bar i { display: grid; place-items: center; font-style: normal; font-size: 10px; font-weight: 900; color: #1a1030; font-variant-numeric: tabular-nums; overflow: hidden; }
.dp-bar i:nth-child(n + 3) { color: #fff; }
.dp-bar.empty { opacity: 0.5; }
.dp-bar.mini { height: 4px; border-radius: 2px; margin-top: 3px; }
.dp-bar.before { height: 5px; border-radius: 3px; margin-bottom: 3px; opacity: 0.8; }
/* 対局が終わって決まった着順: 帯ではなく、着順の色の縁取りの札（ほぼ 100% の帯と見分ける） */
.dp-fixed {
  display: flex; align-items: center; justify-content: center; gap: 4px; height: 18px; border-radius: 6px;
  border: 1.5px solid var(--rc); background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--rc) 22%, transparent) 0 4px, transparent 4px 8px);
  color: var(--text); font-size: 10px; font-weight: 900; white-space: nowrap;
}
.dp-fixed b { color: color-mix(in srgb, var(--rc) 55%, #fff); font-size: 11px; }
.dp-fixed.mini { height: 15px; margin-top: 2px; border-width: 1px; border-radius: 4px; font-size: 9px; gap: 1px; }
.dp-fixed.mini b { font-size: 10px; }
.dp-key .dp-fixed.mini { display: inline-flex; width: 42px; margin: 0 4px 0 6px; }

.dp-status { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; color: var(--muted); font-weight: 800; }
.dp-status.error { color: #ffb3bf; }
.dp-status a { color: var(--gold); }
.dp-status .btn { height: 30px; }
.dp-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: var(--naga); animation: dp-spin 0.8s linear infinite; }
@keyframes dp-spin { to { transform: rotate(360deg); } }
.dp-mock { margin: 10px 0 0; padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 800; color: #ffe39a; background: rgba(255, 159, 67, 0.12); border: 1px dashed rgba(255, 159, 67, 0.5); }

/* この局が終わったときの着順の条件（広い画面では、点差と表を左右に並べる） */
.dp-ends, .dp-map { padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); }
.dp-ends { margin-top: 12px; }
.dp-now { margin-left: 10px; padding: 1px 8px; border-radius: 999px; font-size: 11px; color: var(--text); background: rgba(166, 122, 224, 0.3); }
/* 右の表（局の終わり方ごとの条件）は縮めると数字が折り返して読みにくいので、中身の幅を取り、左の点差の列が残りを使う。
   横に並べると収まらない幅（下の 1100px 以下）では縦に並べ、それでも収まらなければ包みの中で表を横にスクロールさせる（切らない）。
   表そのものに display: block を付けると、縦に並べたときに表が欄の幅まで広がらず、スマホ幅の table-layout: fixed も効かなくなるので、包みでスクロールさせる */
.dp-ends-body { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 16px; align-items: center; }
.dp-goal-wrap { min-width: 0; overflow-x: auto; }
.dp-chain { display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.dp-gp { display: grid; grid-template-columns: 22px auto minmax(0, 1fr); align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); font-size: 12px; font-weight: 800; }
.dp-gp .rk { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-style: normal; font-size: 11px; color: #10142a; background: #fff; }
.dp-gp b { justify-self: end; font-size: 15px; }
.dp-gp.on { background: rgba(166, 122, 224, 0.22); box-shadow: inset 0 0 0 1px rgba(200, 170, 255, 0.45); }
.dp-gap { justify-self: center; padding: 0 8px; font-size: 11px; font-weight: 800; color: var(--faint); border-left: 2px solid var(--line-strong); }
.dp-cond { display: inline-flex; align-items: baseline; gap: 3px; padding: 2px 8px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; font-weight: 800; }
.dp-cond:hover { border-color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.06); }
.dp-goal-table td.some { color: var(--mild); }
/* その和了のあと対局が終わるか: 終局・飛び終了は金、西入・連荘は控えめ */
.dp-game { margin-left: 5px; padding: 0 5px; border-radius: 4px; font-style: normal; font-size: 10px; font-weight: 900; color: var(--muted); border: 1px solid var(--line-strong); }
.dp-game.end { color: #10142a; background: var(--gold); border-color: var(--gold); }
.dp-goal-table tr.draw th, .dp-goal-table tr.draw td { border-top: 1px solid var(--line); }
.dp-goal-table { width: 100%; border-collapse: separate; border-spacing: 0 3px; font-variant-numeric: tabular-nums; }
.dp-goal-table th, .dp-goal-table td { padding: 4px 8px; white-space: nowrap; }
.dp-goal-table thead th { color: var(--muted); font-size: 11px; font-weight: 900; text-align: center; }
.dp-goal-table thead th small { display: block; color: var(--faint); font-size: 10px; font-weight: 700; }
.dp-goal-table tbody th { text-align: left; font-size: 12px; font-weight: 800; color: var(--muted); background: rgba(255, 255, 255, 0.04); border-radius: 8px 0 0 8px; }
.dp-goal-table td { text-align: center; background: rgba(255, 255, 255, 0.04); font-weight: 800; }
.dp-goal-table td:last-child { border-radius: 0 8px 8px 0; }
.dp-goal-table td b { font-size: 14px; }
.dp-goal-table td small { margin-left: 2px; color: var(--faint); font-size: 10px; }
.dp-goal-table td.any { color: var(--good); }
.dp-goal-table td.no { color: var(--faint); font-weight: 700; }

/* 条件マップ */
.dp-map { margin-top: 12px; }
.dp-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; color: var(--faint); font-size: 11px; font-weight: 800; }
.dp-scale { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.dp-scale i { width: 96px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--bad), rgba(255, 255, 255, 0.08), var(--good)); }
.dp-key { display: inline-flex; align-items: center; gap: 4px; }
.dp-key i { display: inline-block; width: 10px; height: 6px; margin-left: 6px; border-radius: 2px; }
.dp-scroll { overflow-x: auto; scrollbar-width: thin; }
.dp-grid { border-collapse: separate; border-spacing: 2px; font-variant-numeric: tabular-nums; }
.dp-grid:not(.dp-grid--draw) { width: 100%; }
.dp-grid th { font-size: 11px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.dp-grid thead th { padding: 2px 0 4px; text-align: center; min-width: 50px; }
.dp-grid thead th.lim { color: var(--gold); }
.dp-grid .corner { text-align: left; min-width: 0; }
.dp-grid .corner small { display: block; color: var(--faint); font-size: 10px; }
.dp-grid .grp th { padding: 10px 0 4px; text-align: left; color: var(--text); font-size: 12px; font-weight: 900; }
.dp-grid .rh { position: sticky; left: 0; z-index: 1; padding: 0 10px 0 2px; text-align: left; background: rgba(12, 18, 40, 0.96); }
.dp-grid td { padding: 0; }
.dp-cell {
  position: relative; display: block; width: 100%; min-width: 50px; padding: 5px 4px 4px; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; background: rgba(255, 255, 255, 0.05); color: var(--text); font-size: 12px; font-weight: 800; text-align: center;
}
.dp-cell.plus { background: color-mix(in srgb, var(--good) calc(var(--a) * 62%), rgba(255, 255, 255, 0.04)); color: var(--text); }
.dp-cell.minus { background: color-mix(in srgb, var(--bad) calc(var(--a) * 62%), rgba(255, 255, 255, 0.04)); color: var(--text); }
.dp-cell:hover { border-color: rgba(255, 255, 255, 0.5); }
.dp-cell.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 12px rgba(255, 201, 77, 0.35); }
.dp-cell .v { display: block; line-height: 1.2; }
/* この局の実際の終わり方 */
.dp-cell.act { border-color: rgba(255, 255, 255, 0.85); }
.dp-cell .act { position: absolute; top: -7px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 9px; line-height: 13px; padding: 0 5px; border-radius: 999px; white-space: nowrap; color: #10142a; background: #fff; }
.dp-actual { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; font-size: 12px; font-weight: 800; }
.dp-actual .l { color: var(--muted); }
.dp-actual-item { display: inline-flex; align-items: baseline; gap: 8px; padding: 4px 12px; border-radius: 999px; cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.06); font-weight: 800; }
.dp-actual-item small { color: var(--faint); font-size: 11px; }
.dp-actual-item b { font-variant-numeric: tabular-nums; }
.dp-draw-title { margin: 10px 0 0; font-size: 12px; font-weight: 900; }
.dp-grid--draw { margin-top: 2px; }
.dp-grid--draw thead th { min-width: 64px; }
.dp-more { margin: 6px 0 2px; padding: 3px 10px; border-radius: 8px; border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }

/* 選んだ終わり方の 4 人の変化 */
#dp-detail { margin-top: 10px; min-height: 64px; }
.dp-detail { padding: 10px 14px; border-radius: 14px; background: rgba(255, 201, 77, 0.05); border: 1px solid rgba(255, 201, 77, 0.3); }
.dp-detail-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 6px; font-weight: 900; }
.dp-detail-title small { color: var(--faint); font-size: 11px; }
.dp-endtag { padding: 0 8px; border-radius: 999px; font-size: 11px; color: var(--type-ink); background: var(--gold); }
/* 4 人の変化（左）と打点ごとのグラフ（右） */
.dp-detail-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.dp-cap { margin: 0 0 6px; color: var(--faint); font-size: 11px; font-weight: 800; }
.dp-drow { display: grid; grid-template-columns: 158px minmax(0, 1fr) 92px; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.dp-drow.on { background: rgba(166, 122, 224, 0.16); }
.dp-drow .nm { display: grid; gap: 2px; font-weight: 900; font-size: 12px; min-width: 0; }
.dp-drow .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-drow .who small { margin-left: 6px; color: var(--muted); font-weight: 700; }
.dp-drow .sc { color: var(--muted); font-weight: 800; font-size: 11px; white-space: nowrap; }
.dp-drow .sc b { color: var(--text); font-size: 13px; }
.dp-drow .sc small { margin-left: 5px; font-size: 11px; }
.dp-chart-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 4px; }
.dp-chart-head .dp-cap { margin: 0; }
.dp-chart-sw button { height: 24px; padding: 0 10px; font-size: 11px; font-weight: 800; cursor: pointer; }
.dp-svg { display: block; width: 100%; height: auto; overflow: visible; stroke: none; stroke-width: 1; font-variant-numeric: tabular-nums; }
.dp-svg text { fill: var(--faint); stroke: none; font-size: 11px; font-weight: 800; }
.dp-svg .xl text.sel { fill: var(--gold); }
.dp-svg .grid line { stroke: rgba(255, 255, 255, 0.08); }
.dp-svg .grid line.zero { stroke: rgba(255, 255, 255, 0.35); }
.dp-svg .area { stroke: none; }
.dp-svg .area.pos { fill: rgba(61, 220, 151, 0.28); }
.dp-svg .area.neg { fill: rgba(255, 84, 112, 0.28); }
.dp-svg .line { fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.dp-svg .pt { fill: #1a2040; stroke: #fff; stroke-width: 1.5; }
.dp-svg .pt.plus { stroke: var(--good); }
.dp-svg .pt.minus { stroke: var(--bad); }
.dp-svg .pt.sel { fill: var(--gold); stroke: #fff; }
.dp-svg .val { font-size: 14px; font-weight: 900; paint-order: stroke; stroke: #0b1024; stroke-width: 3px; }
.dp-svg text.val.plus { fill: var(--good); }
.dp-svg text.val.minus { fill: var(--bad); }
.dp-svg .now { stroke: var(--gold); stroke-width: 2; }
.dp-svg .areas path { stroke: rgba(11, 16, 36, 0.6); stroke-width: 1; }
.dp-svg .start rect { stroke: rgba(11, 16, 36, 0.6); stroke-width: 1; }
.dp-svg .dp-hit { fill: transparent; stroke: none; cursor: pointer; }
.dp-svg .fixed { fill: var(--gold); stroke: none; }
.dp-svg .pt.fixed { stroke-width: 1.5; }
.dp-fixed-key { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; }
.dp-fixed-key i { width: 18px; height: 4px; border-radius: 2px; background: var(--gold); }
.dp-svg .dp-hit:hover { fill: rgba(255, 255, 255, 0.06); }
.dp-drow .ev { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
.dp-drow .ev b { font-size: 16px; }
.dp-drow .ev small { font-size: 12px; font-weight: 800; }

/* 段位ptの配分と閉じる */
.dp-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.dp-pt { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 12px; font-weight: 800; }
.dp-pt .l { color: var(--muted); }
.dp-pt select, .dp-custom input {
  height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.3); color: var(--text); font: inherit;
}
.dp-custom { display: inline-flex; gap: 6px; }
.dp-custom label { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); }
.dp-custom input { width: 64px; font-variant-numeric: tabular-nums; }
.dp-pt-text { color: var(--faint); font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .dp-ends-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px), (max-aspect-ratio: 9/10) {
  .dp-detail-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .modal-card.danpt { padding: 14px 12px; }
  .dp-players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dp-score { font-size: 17px; }
  .dp-ev b { font-size: 18px; }
  .dp-cell { min-width: 44px; font-size: 11px; }
  .dp-ev .lbl { display: none; }
  .dp-ends, .dp-map { padding: 10px; }
  .dp-goal-table { table-layout: fixed; }
  .dp-goal-table thead th:first-child { width: 72px; }
  .dp-goal-table th, .dp-goal-table td { padding: 4px 3px; white-space: normal; line-height: 1.25; }
  .dp-goal-table td b { font-size: 12px; }
  .dp-goal-table td small { display: block; margin: 0; }
  .dp-goal-table td { font-size: 11px; }
  .dp-cond { display: inline-grid; justify-items: center; gap: 0; padding: 2px 4px; }
  .dp-game { margin: 2px 0 0; display: inline-block; }
  .dp-drow { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .dp-drow .bars { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { .dp-spin { animation-duration: 2s; } }
