/* 画面の高さ。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: 108px; /* タイムライン（約 40px）と移動のボタン。低いほど卓を大きく写せる（狭い画面は下の指定） */
  --top-h: 56px;
  --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; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#scene:focus { outline: none; }

.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; }

.prob-label {
  font-weight: 800; font-size: calc(12px * var(--depth, 1)); color: #fff; padding: 1px 5px; border-radius: 6px;
  background: rgba(20, 10, 40, 0.7); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); font-variant-numeric: tabular-nums;
}
.prob-label.top { background: var(--type); color: var(--type-ink); text-shadow: none; box-shadow: 0 0 0 1px var(--type-edge), 0 0 14px var(--type-glow); }
.prob-label.actual { box-shadow: 0 0 0 2px #fff; }
/* 発声（リーチ・チー・ポン・カン・ツモ・ロン）: 発声した席の側に大きく出し、その局面にいる間は出し続ける */
.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） */
.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: 36px; 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: 3px; gap: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.seg button { height: 30px; 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) + 6px); 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) + 18px); max-height: calc(var(--app-h) - var(--top-h) - var(--dock-h) - 24px); }
/* 卓の左右が空いているときは、左に縦に並べた情報の列と右の解説パネルを、牌のすぐ外まで中央へ寄せる（量は 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.layout-side .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 { 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; }

body.layout-top .round-chip { flex-wrap: nowrap; gap: 8px; padding: 6px 10px; }
body.layout-top .round-chip .round { font-size: 17px; }
body.layout-top .round-chip .dora { gap: 6px; }
body.layout-top .round-chip .dora img { height: 34px; }
body.layout-top .player { grid-template-columns: 22px minmax(0, 1fr); gap: 1px 6px; padding: 5px 8px 5px 7px; }
body.layout-top .player .wind { width: 22px; height: 22px; font-size: 13px; border-radius: 6px; }
body.layout-top .player .sub .dan, body.layout-top .player .tp > span:first-child { display: none; }
body.layout-top .player .tp { grid-template-columns: 1fr minmax(32px, auto); }
body.layout-top .player .name { padding-right: 0; }
body.layout-top .sit-card { padding: 6px 9px; display: grid; align-content: center; }
body.layout-top .sit-leg { display: none; }
body.layout-top .sit-leg + .sit-row { margin-top: 3px; }
/* 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); }
  body.layout-top .player .wind { display: none; }
  body.layout-top .player .tp { grid-column: 1; }
  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) + 6px); bottom: calc(var(--dock-h) + 18px); 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); }
.cand .bars { display: grid; gap: 2px; }
.bar { position: relative; }
.cand .bars, .choice .bars { display: grid; gap: 2px; }
/* 棒は、太い棒（選択中のタイプ）も細い棒（他のタイプ）も、打牌候補・選択肢のどちらでも同じ規則で描く。
   溝はどのタイプも同じ暗い色（溝を塗りに近い色にすると 0% でも満ちて見えるため）。
   塗りは上から光を当てたような立体の帯にし、先端に明るい線を付けて、細い棒でも長さと終わりの位置を読めるようにする */
.cand .bar, .choice .bar.main {
  height: 11px; 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: 14px; border-radius: 7px; }
.cand .bar.main { margin: 1px 0; }
.cand .bar.other, .choice .bar.other { height: 5px; border-radius: 3px; }
.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; }
.choice .pct { text-align: right; font-variant-numeric: tabular-nums; }
.choice .label { white-space: nowrap; }
.choice .label .chi { display: inline-flex; gap: 1px; margin-left: 3px; vertical-align: middle; }
.choice .label .chi img { height: 18px; 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: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(1100px, calc(100vw - 24px)); height: var(--dock-h); z-index: 15;
  display: grid; grid-template-rows: 1fr auto; gap: 8px; padding: 10px 12px 10px;
  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);
}
.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;
}
.timeline-tip .tl-kind { color: var(--c); font-weight: 800; }
.tl-legend {
  position: absolute; left: 14px; bottom: 10px; height: 38px; display: grid; align-content: center; gap: 1px;
  font-size: 10px; font-weight: 700; color: var(--muted); pointer-events: auto;
}
.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); }
@media (max-width: 960px) { .tl-legend { display: none; } }
.nav button {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 38px; 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: 52px; min-width: 52px; 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); }

/* 読み込み */
.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; }
.open-card { width: min(560px, 100%); }
.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; }
  /* パネルが狭いので、小さくせずに 2 段に分ける（半分ずつ。数は hud.js が --half に入れる） */
  .type-picks { max-width: calc(var(--half, 3) * (var(--tp-w) + 3px)); }
  .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) {
  :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; }
  #btn-help { display: none; }
  .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: 8px; 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 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; }
.qd-where { grid-column: 2; grid-row: 1; }
.qd-ask { grid-row: 2; }
.qd-prompt small { grid-row: 3; }
.qd-pick { flex: none; display: grid; place-items: center; width: 40px; height: 54px; }
.qd-pick img { height: 52px; 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: 36px; height: 50px; 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: 44px; 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) {
  .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; }
}
