/* 書体の指定は index.html の先頭で、今の言語の分だけ読み込む。
   中国語の書体：日本語の3書体と同じ役割・雰囲気のものを選ぶ。
   簡体字と繁体字は同じ書体（または同じ書体の繁体字版）にそろえ、ゲームで使う字がすべて入っている書体だけを使う（字が欠けた書体を無理に使わない）
   見出し・テロップ（Kaisei Decol の明朝）→ 汇文明朝体（Huiwen-mincho。日本の明朝体の活字をもとにした、古い印刷物の味のある明朝。簡体字・繁体字とも持つ）
   本文（Zen Maru Gothic の丸ゴシック）→ 昭源圓體（Chiron GoRound TC。簡体字の字も持つ）
   ひとこと（Klee One の手書き風）→ Klee One から作られた霞鹜文楷：簡体字は LXGW WenKai、繁体字はその繁体字版 LXGW WenKai TC
   韓国語の書体：同じく日本語の3書体の役割・雰囲気に合わせる
   見出し・テロップ → 송명（Song Myung。筆の丸みが残る装飾的な明朝）、本文 → 해바라기（Sunflower。やわらかいゴシック）、
   ひとこと → 서툰 이야기（Poor Story。読みやすい手書き風） */
/* ============================================================
   城壁工場都市 — 画面デザイン
   明るい紙色のパネルに、会社の色（紅・蒼）と黄色の操作色。
   押せるものは下に厚みのある「つまみ」、読むものは平らな面。
   ============================================================ */
:root {
  --ink: #1d2430;
  --ink-2: #485263;
  --muted: #687080;
  --paper: #ffffff;
  --paper-2: #f4f1ea;
  --paper-3: #ebe6db;
  --line: #e2dccf;
  --lip: #d3ccbd;
  --p1: #e2513a;
  --p1-d: #b33822;
  --p1-t: #fdebe7;
  --p2: #2e7be0;
  --p2-d: #1d5bb0;
  --p2-t: #e6f0fc;
  --sun: #ffc93c;
  --sun-d: #d99b0c;
  --danger: #e2513a;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(24, 34, 52, 0.16), 0 2px 6px rgba(24, 34, 52, 0.08);
  /* 読む文字は判読性の高いUDゴシック、見出しと数字は丸ゴシックでポップに */
  --font: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-pop: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", var(--font);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #b9c9d6;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  /* ページ自体の拡大（ピンチ・2回タップ）を止める。指でなぞるスクロールは残す。
     ページが拡大された状態だと、iPhone の Safari はタップの座標と描画面の位置を別の基準で返し、タップした区画がずれる */
  touch-action: pan-x pan-y;
}
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; touch-action: none; }
.hidden { display: none !important; }
b { font-weight: 900; }
button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- ボタン ---------- */
button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--lip);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
button:hover { background: #fffaf0; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lip); }
button:disabled { opacity: 0.38; cursor: default; transform: none; box-shadow: 0 3px 0 var(--lip); }
button:focus-visible { outline: 3px solid rgba(46, 123, 224, 0.45); outline-offset: 2px; }
button.big, #dialogYes, #btnAgain, #btnRuleNext {
  background: var(--sun);
  border-color: var(--sun-d);
  box-shadow: 0 4px 0 var(--sun-d);
}
button.big:hover, #dialogYes:hover, #btnAgain:hover, #btnRuleNext:hover { background: #ffd35e; }
button.big:active, #dialogYes:active, #btnAgain:active, #btnRuleNext:active { box-shadow: 0 1px 0 var(--sun-d); }
/* 対局を始めるボタン：押してから盤ができるまで、沈んだままにして「押した」ことを見せる */
button.starting { transform: translateY(2px); box-shadow: 0 1px 0 var(--lip); cursor: progress; }
button.big.starting, #btnAgain.starting { box-shadow: 0 1px 0 var(--sun-d); }
button.big { font-size: 18px; padding: 15px 24px; border-radius: 14px; }
/* 続きから：途中の対局があるときだけ、いちばん上に。新しく始めるボタンと見分けられるよう、縁を太く */
button.big.resume { border: 2.5px solid var(--sun-d); }
button.big.alt { background: var(--paper); border-color: var(--line); box-shadow: 0 4px 0 var(--lip); }
button.big.alt:active { box-shadow: 0 1px 0 var(--lip); }
button.ghost { background: var(--paper-2); border-color: transparent; box-shadow: none; color: var(--ink-2); }
button.ghost:hover { background: var(--paper-3); }
button.ghost:active { box-shadow: none; }
button.big.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-2); font-size: 16px; padding: 10px; }
/* タイトルの「ルール」：塗らずに細い縁と本・矢印の印だけで、押せることを控えめに示す */
#btnRules, #btnFeedback, #btnHistory { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); padding: 10px 14px 10px 16px; }
#btnRules span, #btnFeedback span, #btnHistory span { flex: 1; }
#btnRules svg, #btnFeedback svg, #btnHistory svg { width: 20px; height: 20px; opacity: 0.75; }
#btnRules .chev, #btnFeedback .chev, #btnHistory .chev { width: 18px; height: 18px; transition: transform 0.15s; }
#btnRules:hover, #btnFeedback:hover, #btnHistory:hover { background: var(--paper-2); }
#btnRules:hover .chev, #btnFeedback:hover .chev, #btnHistory:hover .chev { transform: translateX(3px); }
/* 対局の記録：ルールと同じ形で、ご意見と同じく一段控えめに */
#btnHistory { border-width: 1px; font-size: 15px; padding: 8px 14px 8px 16px; }
#btnHistory svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* ご意見は、字は小さめのまま黄色で塗って目立たせる（声を集めたいので、ルールより目に留まるように） */
#btnFeedback { border-width: 1px; font-size: 14px; padding: 8px 14px 8px 16px; background: var(--sun); border-color: var(--sun-d); color: var(--ink); box-shadow: 0 3px 0 var(--sun-d); }
#btnFeedback:hover { background: color-mix(in srgb, var(--sun) 80%, #fff); }
#btnFeedback:active { box-shadow: 0 1px 0 var(--sun-d); transform: translateY(2px); }
#btnFeedback svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 1; }
/* 「ルール」ボタンの上の説明：枠で囲って目立たせ、囲碁が初めての方（工場の言葉）と囲碁を知っている方（中国ルールとの違い）をタブで切り替える */
.rule-box { --rule-tab-on: color-mix(in srgb, var(--sun) 60%, var(--paper)); margin: 0 0 12px; }
/* 選んだタブと同じ色の枠で中身を囲み、タブと中身をひとつの形に見せる（もう一方のタブは枠の外に離れて見える） */
.rule-box > [role="tabpanel"] { border: 3px solid var(--rule-tab-on); border-radius: 0 0 12px 12px; background: color-mix(in srgb, var(--sun) 12%, var(--paper)); overflow: hidden; position: relative; }
/* 選んだタブは枠とつながる濃い色、もう一方は淡い色で、押せば替わると分かるようにする */
.rule-tabs { display: flex; gap: 6px; }
.rule-tabs button.rule-tab { flex: 1 1 0; min-width: 0; margin: 0; padding: 7px 4px; border: 0; border-radius: 10px 10px 0 0; box-shadow: none; background: color-mix(in srgb, var(--sun-d) 16%, var(--paper)); color: var(--muted); font-size: 13px; font-weight: 700; transform: none; justify-content: center; text-align: center; cursor: pointer; }
.rule-tabs button.rule-tab:hover { background: color-mix(in srgb, var(--sun) 30%, var(--paper)); color: var(--ink); }
.rule-tabs button.rule-tab[aria-selected="true"] { background: var(--rule-tab-on); color: var(--ink); font-weight: 800; cursor: default; }
.rule-note { font-size: 14px; line-height: 1.7; color: var(--ink-2); margin: 0; text-align: center; padding: 8px 10px; }
/* 終了時に爆発する（取られる）決まりは、両方のタブとも紅の字に紅の蛍光ペンで、ほかの要点より強く */
.rule-note b.danger { color: var(--p1-d); background: linear-gradient(transparent 58%, color-mix(in srgb, var(--p1) 30%, transparent) 58%); }
.rule-note a { color: var(--p2); font-weight: 700; text-underline-offset: 2px; }
/* ファクトリ囲碁への案内（日本語だけ）：下の説明とひと続きに見せる */
/* ゲームの紹介（トップ画面。閉じておき、開いた人にだけ見せる） */
.about { margin-top: 10px; font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.about summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.about p { margin: 8px 0; }
.about ul { margin: 8px 0; padding-left: 1.3em; }
.about li { margin-bottom: 6px; }
.about-shot { display: block; width: 100%; height: auto; border-radius: 8px; }
.about-old { color: var(--muted); }
.about-old:empty { display: none; }
#menu:has(#setup:not(.hidden)) .about { display: none; }
.rule-src { padding-bottom: 0; }
.rule-src + .rule-note { padding-top: 0; }
:root:not(:lang(ja)) .rule-src { display: none; }
:root:not(:lang(ja)) .rule-src + .rule-note { padding-top: 8px; }
.rule-note span { display: inline-block; } /* 狭い画面でも、言葉のまとまりの切れ目でだけ折り返す */
/* 要点は、濃いインクの太字に、はちみつ色の蛍光ペンを下半分だけ引く */
.rule-note b, .watch-note { color: var(--ink); font-weight: 700; background: linear-gradient(transparent 58%, color-mix(in srgb, var(--sun) 55%, transparent) 58%); padding: 0 1px; }
/* 両方のタブ：説明の下の「▶ 実際の画面で見る」と、押すと枠の中で流れる見るだけのチュートリアル（src/demo.js） */
#demoText .rule-note, #demoTextGo .rule-note:last-of-type { padding-bottom: 4px; }
/* 塗りつぶしの大ボタンほど強くせず、青の縁と淡い地、丸に抜いた再生の印で、押せることが目に入るようにする */
button.demo-play { display: flex; align-items: center; gap: 7px; margin: 2px auto 10px; padding: 4px 16px 4px 5px; border-radius: 999px; font-size: 14px; font-weight: 800; color: var(--p2); background: color-mix(in srgb, var(--p2) 9%, var(--paper)); border: 1.5px solid var(--p2); box-shadow: 0 2px 0 color-mix(in srgb, var(--p2) 35%, transparent); transform: none; }
button.demo-play:hover { background: color-mix(in srgb, var(--p2) 18%, var(--paper)); }
button.demo-play:active { box-shadow: none; transform: translateY(2px); }
button.demo-play svg { width: 22px; height: 22px; padding: 3px; flex: none; border-radius: 50%; background: var(--p2); fill: #fff; }
.demo { position: relative; }
/* 動画の盤を作っている間は、説明文の上に透明で重ねておく（説明文は出したまま。最初の1コマが描けたら demo.js が説明文と入れ替えて、ふわっと出す） */
.demo.preparing { position: absolute; top: 0; left: 0; right: 0; opacity: 0; pointer-events: none; }
.demo.shown { animation: demoShow 0.35s ease-out; }
@keyframes demoShow { from { opacity: 0; } to { opacity: 1; } }
/* 盤の高さは、押す前の説明文と同じにする（demo.js が測って入れる。押しても枠の高さが変わらない） */
.demo-view { position: relative; height: 200px; overflow: hidden; }
.demo-stage { position: absolute; inset: 0; overflow: hidden; background: #1d2430; pointer-events: none; }
.demo-stage canvas { display: block; }
button.demo-close { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 0; background: rgba(20, 24, 32, 0.55); box-shadow: none; transform: none; }
button.demo-close svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
/* テロップ：盤の下の端に重ねる帯。下ほど濃い黒のぼかしに、白の太字。ふちと影で明るい盤の上でも読めるように */
.demo-cap { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 26px 12px 9px; text-align: center; font-size: 15px; line-height: 1.45; font-weight: 800; color: #fff; letter-spacing: 0.02em; background: linear-gradient(to bottom, transparent, rgba(12, 14, 20, 0.55) 38%, rgba(12, 14, 20, 0.82)); text-shadow: 0 0 2px #000, 0 1px 3px rgba(0, 0, 0, 0.9); pointer-events: none; }
.demo-cap:empty { display: none; }
.demo-cap span { display: inline-block; }
/* 英語は語が長く行が増えやすいので、字を少し小さくして2行に収める */
:root:lang(en) .demo-cap { font-size: 13.5px; letter-spacing: 0; }
.demo-cap .demo-cap-in { display: block; }
/* 要点は明るい黄色、旗のない工場の爆発は明るい赤（暗い帯の上では蛍光ペンが見えにくいので、字の色で） */
.demo-cap b { color: #ffd84a; font-weight: 900; }
.demo-cap b.danger { color: #ff7a66; }
.demo-cap.in { animation: demoCap 0.35s ease-out; }
@keyframes demoCap { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* 左上の点数の札（工場と煙突の数。蒼にはハンデ）。冒頭の勝ち方のテロップのあいだは光らせる */
.demo-score { position: absolute; top: 6px; left: 6px; display: flex; gap: 10px; padding: 4px 10px; border-radius: 999px; background: rgba(12, 14, 20, 0.62); color: #fff; font-size: 13px; font-weight: 800; line-height: 1.3; text-shadow: 0 1px 2px #000; pointer-events: none; transition: box-shadow 0.3s; }
.demo-score b { display: inline-block; min-width: 1.2em; font-size: 15px; font-weight: 900; }
.demo-score .ds-r b { color: #ff8a73; }
.demo-score .ds-b b { color: #7fb8ff; }
.demo-score i { font-style: normal; }
.demo-score small { font-size: 11px; opacity: 0.85; margin-left: 1px; }
.demo-score.glow { box-shadow: 0 0 0 2px #ffd84a, 0 0 14px rgba(255, 216, 74, 0.8); animation: demoGlow 1s ease-in-out infinite alternate; }
@keyframes demoGlow { to { box-shadow: 0 0 0 2px #ffd84a, 0 0 4px rgba(255, 216, 74, 0.3); } }
.demo-score b.up { animation: demoUp 0.45s ease-out; }
@keyframes demoUp { 40% { transform: scale(1.45); } }
/* 終わったら、盤のまん中に重ねて出す（下のテロップには重ねない） */
.demo-actions { position: absolute; left: 0; right: 0; top: 34%; transform: translateY(-50%); display: flex; justify-content: center; gap: 8px; }
.demo-actions.hidden { display: none; }
.demo-actions button { display: flex; align-items: center; gap: 5px; padding: 6px 15px 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); transform: none; }
.demo-actions button svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.demo-actions #btnDemoAgain { color: var(--p2); border-color: color-mix(in srgb, var(--p2) 45%, transparent); }
/* 「CPU同士の対戦を観る」のボタンの中、題の下に添える、はじめての人への一言 */
.watch-note { display: block; width: fit-content; margin-top: 3px; font-size: 12px; } /* 色・太さ・蛍光ペンは注記の要点と同じ */
button.icon { padding: 7px; border-radius: 10px; display: grid; place-items: center; box-shadow: none; }

/* ---------- 画面（メニュー・ダイアログの土台） ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  padding: 16px;
  z-index: 20;
  overflow-y: auto;
}
/* 結果の画面の上に重ねる確認（ヒントが使えない対局を始める前など） */
#dialog.over-result { z-index: 21; }
#rules, #dialog, #choice, #result, #editor, #feedback, #ruleSheet, #history, #online, #rated, #invite { background: rgba(29, 36, 48, 0.42); backdrop-filter: blur(4px); }
/* スマホでは後ろの3D画面をぼかすと毎回の描画が重くなるので、ぼかさずに少し濃くする */
body.dev-phone #rules, body.dev-phone #dialog, body.dev-phone #choice, body.dev-phone #result, body.dev-phone #editor, body.dev-phone #feedback, body.dev-phone #ruleSheet, body.dev-phone #history, body.dev-phone #online, body.dev-phone #rated, body.dev-phone #invite { background: rgba(29, 36, 48, 0.58); backdrop-filter: none; }

.panel, .menu-card {
  background: var(--paper);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 24px 26px;
  max-width: 560px;
  width: 100%;
}

/* タイトル：左に1枚のカード、奥に街 */
#menu { align-items: flex-start; padding-left: max(16px, 6vw); background: linear-gradient(90deg, rgba(29, 36, 48, 0.28), rgba(29, 36, 48, 0) 46%); }
.menu-card { max-width: 440px; padding: 30px 30px 26px; }
.title-block { margin-bottom: 22px; }
.subtitle { font-size: 12px; letter-spacing: 0.3em; color: #b07a00; font-family: var(--font-pop); font-weight: 900; }
h1 {
  margin: 6px 0 0;
  font-size: clamp(34px, 4.2vw, 46px);
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink);
}
h1::after { content: ""; display: block; width: 56px; height: 6px; border-radius: 3px; margin-top: 12px; background: linear-gradient(90deg, var(--p1) 50%, var(--p2) 50%); }
.tagline { color: var(--ink-2); margin: 14px 0 0; font-size: 15px; line-height: 1.75; font-weight: 400; }
.tagline .gap { display: block; height: 0.7em; } /* 舞台の2行と、ルールの2行のあいだを少しあける */
.menu-buttons { display: flex; flex-direction: column; gap: 12px; }
.menu-buttons button { width: 100%; text-align: left; }
/* 読み込み中の表示：背景の街と遊ぶボタンの動きを読み込み終わるまで（html.booting）、遊ぶボタンを薄くして押せなくし、いちばん上のボタンの右側に札を重ねる（高さの真ん中は index.html のスクリプトが合わせる）。
   すぐ読み込めるときにちらつかないよう、0.3秒たってから出す。終わったら街を空色からふわっと出す */
.menu-buttons { position: relative; }
.boot-line { display: none; }
html.booting .boot-line { position: absolute; z-index: 1; right: 10px; top: 28px; display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 20px); box-sizing: border-box; padding: 7px 14px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper); box-shadow: var(--shadow); color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.35; transform: translateY(-50%); animation: boot-in 0.2s 0.3s both; }
html.booting .boot-line.slow { max-width: min(calc(100% - 20px), 300px); flex-wrap: wrap; justify-content: center; row-gap: 2px; border-radius: 18px; text-align: center; }
.boot-ring { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; animation: boot-spin 0.9s linear infinite; }
.menu-buttons .boot-line button.boot-reload { width: auto; padding: 2px 10px; border: 0; border-radius: 999px; box-shadow: none; background: transparent; color: var(--ink-2); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.menu-buttons .boot-line button.boot-reload:hover { background: var(--paper-2); }
#mainButtons > button { transition: opacity 0.3s; }
html.booting #mainButtons > button:not(.ghost) { pointer-events: none; animation: boot-dim 0.2s 0.3s both; }
#stage { transition: opacity 0.6s; }
html.booting #stage { opacity: 0; }
/* 街ができるまでは、開いた直後の街を撮った写真を出しておく（右側が白いまま待たせない）。街が出るのと入れ替わりに消す */
#bootShot { position: fixed; inset: 0; background: #a9bd8c url(images/boot-city.webp) center / cover no-repeat; opacity: 0; pointer-events: none; transition: opacity 0.6s; }
html.booting #bootShot { opacity: 1; transition: none; }
/* 起動できないとき（3D の表示が使えない・プログラムが読み込めない）：輪を消して理由を出し、ルール・ご意見のボタンも押せない見た目にする（どれも動かないため） */
/* 札はボタンに重ねず、ボタンの並びの頭に1段として置く（文が長いので） */
html.boot-failed .boot-ring { display: none; }
html.booting.boot-failed .boot-line { position: static; width: auto; max-width: none; transform: none; animation: none; }
html.booting.boot-failed #mainButtons > button, html.booting.boot-failed #btnDemoGo { pointer-events: none; opacity: 0.4; animation: none; }
@keyframes boot-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes boot-dim { from { opacity: 1; } to { opacity: 0.4; } }
@keyframes boot-spin { to { transform: rotate(360deg); } }
@keyframes boot-blink { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .boot-ring { animation: boot-blink 1.6s ease-in-out infinite; } }

.setup h2 { margin: 0 0 16px; font-size: 20px; font-weight: 900; }
.row { margin-bottom: 14px; }
.row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.04em; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; background: var(--paper-2); padding: 4px; border-radius: 12px; }
.seg button {
  flex: 1;
  min-width: 64px;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 6px;
  border-radius: 9px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-2);
}
.seg button:hover { background: rgba(255, 255, 255, 0.6); }
.seg button:active { transform: none; box-shadow: none; }
/* CPUの強さは、パソコンでも折り返さず1段に並べる */
.seg[data-key^="level"] { flex-wrap: nowrap; }
.seg[data-key^="level"] button { min-width: 0; padding: 9px 2px; white-space: nowrap; }
/* 強さは Lv.0〜Lv.9 の10個を、5個ずつ2段に並べる（1段だとスマホ幅でボタンが細くなりすぎる）。左の「Lv.」は2段ぶんの高さに置く */
.seg[data-key^="level"] { display: grid; grid-template-columns: auto repeat(5, minmax(0, 1fr)); }
.seg[data-key^="level"] .seg-prefix { grid-row: span 2; }
/* CPUと対戦の強さ：Lv.0〜Lv.9 を5個ずつ2段。勝ち負けで開いた中間の強さ（4.5 など）は整数の間に細めのボタンで差し込み、
   段（1d〜8d）は3段目に並べる（段は「Lv.」を付けずに読むので、左の「Lv.」の外に置く）。src/unlock.js */
.seg.seg-level { display: flex; flex-direction: column; gap: 4px; }
.seg-level .lv-main { display: flex; align-items: center; gap: 4px; }
.seg-level .lv-rows { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.seg-level .lv-row { display: flex; gap: 4px; min-width: 0; }
.seg-level .lv-row button { flex: 1 1 0; }
.seg-level .lv-row button.lv-half { flex: 0.62 1 0; font-size: 12px; color: var(--muted); }
.seg-level .lv-row button.lv-half.on { color: var(--ink); }
.seg-level .lv-dan-row { padding-top: 4px; border-top: 1px dashed rgba(24, 34, 52, 0.14); }
.seg-level .lv-dan-row button { flex: 0 0 calc((100% - 28px) / 8); }
.seg-level button.lv-new { box-shadow: inset 0 0 0 2px var(--sun-d); animation: lv-new 1.4s ease-in-out 3; }
@keyframes lv-new { 50% { background: rgba(255, 214, 102, 0.55); } }
@media (prefers-reduced-motion: reduce) { .seg-level button.lv-new { animation: none; } }
.seg[data-key="size"] { flex-wrap: nowrap; } /* 土地の広さの5つを1段に並べる */
.seg[data-key="size"] button { min-width: 0; white-space: nowrap; }
/* 強さは「Lv.」を頭に1回だけ置き、ボタンには数字だけを並べる */
.seg-prefix { align-self: center; padding: 0 4px 0 8px; font-size: 14px; font-weight: 700; color: var(--muted); }
.seg .wakaba, .seg .sprout { width: 0.75em; height: 0.9em; margin-left: 3px; vertical-align: -0.1em; } /* 0 の右の印：日本語は初心者マーク、ほかの言語は新芽（初心者マークは日本の外では通じない） */
.seg .sprout, :root:not(:lang(ja)) .seg .wakaba { display: none; }
:root:not(:lang(ja)) .seg .sprout { display: inline; }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(24, 34, 52, 0.16), 0 2px 0 var(--lip); }
/* 土地の形は、字数に合わせて幅を分ける（かぼちゃのボタンは絵の分だけ広い） */
.seg[data-key="shape"] { flex-wrap: nowrap; }
.seg[data-key="shape"] button { flex: 1 1 auto; min-width: 0; white-space: nowrap; padding-inline: 4px; letter-spacing: 0; }
/* ハロウィーンの日だけ出る、かぼちゃの形のボタン：夜空の紫に星をちらし、選ぶとかぼちゃ色に灯る */
.seg button.seg-pumpkin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  color: #ffb547;
  background:
    radial-gradient(circle at 18% 28%, rgba(255, 240, 200, 0.9) 0 1px, transparent 1.5px),
    radial-gradient(circle at 84% 22%, rgba(255, 240, 200, 0.75) 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 80%, rgba(255, 240, 200, 0.6) 0 0.8px, transparent 1.3px),
    linear-gradient(160deg, #3b2a5c, #23193a);
}
.seg button.seg-pumpkin:hover { background-color: #23193a; filter: brightness(1.12); }
.seg button.seg-pumpkin.on {
  color: #3a1d05;
  background:
    radial-gradient(circle at 18% 28%, rgba(255, 255, 230, 0.9) 0 1px, transparent 1.5px),
    radial-gradient(circle at 84% 22%, rgba(255, 255, 230, 0.75) 0 1px, transparent 1.5px),
    linear-gradient(160deg, #ffb13b, #f07a12);
  box-shadow: 0 0 0 1.5px #5a3a8a, 0 0 10px rgba(255, 140, 30, 0.55), 0 2px 0 #b8560a;
}
.pumpkin-icon { width: 1.25em; height: 1.25em; flex: none; }
/* 飾り：左上の角にクモの巣、右上からはみ出すコウモリ、右下にぶら下がって揺れる灯りのランタン */
.seg button.seg-pumpkin { position: relative; overflow: visible; }
.seg button.seg-pumpkin::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 17px;
  height: 17px;
  border-top-left-radius: 9px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><g fill='none' stroke='%23fff' stroke-width='.7' stroke-linecap='round'><path d='M0 0l19 7M0 0l14 14M0 0l7 19'/><path d='M6.6 2.4q-1 3-4.2 4.2M12.2 4.5Q10 9.5 4.5 12.2M17.3 6.3Q14 14 6.3 17.3'/></g></svg>") no-repeat 0 0 / 100% 100%;
  opacity: 0.5;
  pointer-events: none;
}
.seg button.seg-pumpkin.on::before { opacity: 0.55; filter: brightness(0.25); }
.seg button.seg-pumpkin::after {
  content: '';
  position: absolute;
  right: -10px;
  top: -15px;
  width: 38px;
  height: 21px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 22'><g fill='%23221433'><path d='M24 9l-.8-2.2-.6 2C20.5 7.6 18 6.4 13 6.8c2.2 1.4 2.8 3.2 2.3 5 1.8-.9 3.6-.5 4.5 1.3.9-1.3 2.2-1.7 4.2-.1 2-1.6 3.3-1.2 4.2.1.9-1.8 2.7-2.2 4.5-1.3-.5-1.8.1-3.6 2.3-5-5-.4-7.5.8-9.6 2.2l-.6-2-.8 2.2z'/><path d='M7 2.5l-.5-1.3-.4 1.2C4.8 1.6 3.3 1 .4 1.2c1.3.8 1.6 1.9 1.4 2.9 1-.5 2.1-.3 2.6.8.5-.8 1.3-1 2.6-.1 1.3-.9 2-.7 2.6.1.5-1.1 1.6-1.3 2.6-.8-.2-1 .1-2.1 1.4-2.9-2.9-.2-4.4.4-5.7 1.2l-.4-1.2z'/></g></svg>") no-repeat center / contain;
  pointer-events: none;
  animation: pk-bat 2.4s ease-in-out infinite;
}
.pk-lantern {
  position: absolute;
  right: 10px;
  top: 100%;
  width: 13px;
  height: 25px;
  pointer-events: none;
  transform-origin: 50% -4px;
  animation: pk-swing 3.2s ease-in-out infinite;
}
.pk-lantern::before { content: ''; position: absolute; left: 6px; top: -4px; width: 1px; height: 8px; background: rgba(60, 40, 80, 0.6); }
.pk-lantern::after {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 13px;
  height: 18px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 28'><circle cx='10' cy='2.6' r='1.9' fill='none' stroke='%23221433' stroke-width='1.2'/><rect x='5' y='4.5' width='10' height='3' rx='1' fill='%23221433'/><rect x='3' y='7' width='14' height='15' rx='6' fill='%23ff9a2a'/><rect x='6' y='9' width='8' height='11' rx='4' fill='%23ffe08a'/><path d='M7 7.5v14M10 7v15M13 7.5v14' stroke='%23c4560c' stroke-width='.8'/><rect x='5' y='21.5' width='10' height='3' rx='1' fill='%23221433'/><path d='M10 24.5v3' stroke='%23221433' stroke-width='1.2' stroke-linecap='round'/></svg>") no-repeat center / contain;
  filter: drop-shadow(0 0 3px rgba(255, 160, 40, 0.85));
  animation: pk-glow 1.6s ease-in-out infinite;
}
@keyframes pk-bat { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-2px) rotate(4deg) scaleY(0.82); } }
@keyframes pk-swing { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes pk-glow { 0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 160, 40, 0.85)); } 50% { filter: drop-shadow(0 0 5px rgba(255, 190, 70, 1)); } }
@media (prefers-reduced-motion: reduce) { .seg button.seg-pumpkin::after, .pk-lantern, .pk-lantern::after { animation: none; } }
.pumpkin-icon .body { fill: #f58a1f; stroke: #b4520c; stroke-width: 1; }
.pumpkin-icon .mid { fill: #ff9d2e; }
.pumpkin-icon .stem { fill: #5c8a2e; }
.pumpkin-icon .face { fill: #3a1d05; }
.note { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.size-note { margin: -8px 0 14px; } /* ハンデの注記は土地の広さのすぐ下に置き、下の固定のボタンに隠れないようにする */
/* 対戦の準備の「その他の設定」：押すと時間帯・得点などの行が下に開く */
.more-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 2px 0 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 0;
  border-radius: 12px;
  box-shadow: none;
}
.more-toggle:hover { background: var(--paper-3); }
.more-toggle:active { transform: none; box-shadow: none; }
.more-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; }
.more-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
/* 開いたときに送る位置：最後の行が、下に留めた開始のボタン（高さ約70px）に隠れない所まで */
.setup-more { scroll-margin-bottom: 96px; }
.settings-reset { display: block; margin: 12px 0 0 auto; padding: 8px 14px; font-size: 13px; }
.setup-buttons, .dialog-buttons { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.setup-buttons .big { min-width: 160px; }
/* 設定が画面に収まらないときも、開始のボタンは画面の下に留めて、スクロールせずに押せるようにする */
.setup-buttons {
  position: sticky;
  bottom: -16px;
  z-index: 1;
  margin: 18px -14px 0; /* 上の影（紙の色）が最後の行の字にかからないよう、少しあける */
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  border-radius: 14px;
  background-color: var(--paper);
  background-image: var(--grain);
  box-shadow: 0 -10px 12px -6px var(--paper);
}
#menu:has(#setup:not(.hidden)) .tagline { display: none; }
#menu:has(#setup:not(.hidden)) .credit { display: none; }
/* 問い合わせ先：タイトル画面とルールの下に小さく */
.credit { font-size: 12px; color: var(--muted); margin: 14px 0 0; text-align: center; }
.credit a { color: inherit; }
.credit.updated { font-size: 11px; }
#menu .credit.updated { margin-top: 2px; }
.credit.updated:empty { display: none; }
.credit .nw { white-space: nowrap; }
.credit .x-logo { width: .85em; height: .85em; vertical-align: -.08em; margin-right: .2em; fill: currentColor; }
/* アクセス解析の利用のお知らせ：クレジットの下に、さらに小さく */
.credit.analytics-note { font-size: 10px; margin-top: 2px; opacity: .6; }
#menu:has(#setup:not(.hidden)) .title-block { margin-bottom: 14px; }
/* ルールの説明は題字のすぐ下にあり、対局の準備を開いているあいだは、ボタンと一緒に隠す */
#menu:has(#setup:not(.hidden)) .rule-box { display: none; }

/* ---------- ルール ---------- */
.rules-panel { display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 32px); }
.rules-head { display: flex; align-items: center; gap: 12px; }
.rules-head h2 { margin: 0; font-size: 20px; font-weight: 900; }
.rules-head span { color: var(--muted); font-size: 13px; margin-left: auto; }
.rules-figure {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #2a3140;
  border-radius: 14px;
  min-height: 200px;
  padding: 12px;
  flex: none;
}
.rules-figure svg { width: 100%; max-width: 280px; height: auto; }
.rules-text { line-height: 1.9; font-size: 16px; font-weight: 400; min-height: 120px; overflow-y: auto; flex: 1 1 auto; color: var(--ink-2); }
.rules-text b { color: var(--ink); background: linear-gradient(transparent 62%, rgba(255, 201, 60, 0.55) 62%); }
.rules-text .p1 { color: var(--p1); font-weight: 900; }
.rules-text .p2 { color: var(--p2); font-weight: 900; }
.rules-nav { display: flex; align-items: center; gap: 10px; }
.dots-nav { flex: 1; display: flex; justify-content: center; gap: 6px; }
.dots-nav i { width: 8px; height: 8px; border-radius: 4px; background: var(--paper-3); transition: width 0.2s, background 0.2s; }
.dots-nav i.on { width: 22px; background: var(--sun); }

.dialog-panel { max-width: 440px; }

/* ---------- ご意見・不具合の報告 ---------- */
.fb-panel { display: flex; flex-direction: column; gap: 12px; }
.fb-panel h3 { margin: 0; }
.dialog-panel .fb-lead { font-size: 14px; line-height: 1.7; }
.fb-kind { flex-wrap: nowrap; }
.fb-kind button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; padding: 9px 4px; white-space: nowrap; }
.fb-kind button svg { width: 18px; height: 18px; stroke-width: 1.9; } /* 種類の印：感想＝煙を上げる工場、不具合＝スパナ、要望＝これから建てる点線の工場 */
.fb-panel textarea { width: 100%; box-sizing: border-box; min-height: 120px; resize: vertical; font: inherit; font-size: 16px; line-height: 1.6; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); }
.fb-panel textarea:focus { outline: none; border-color: var(--sun-d); }
.fb-panel .fb-field { display: flex; align-items: center; gap: 8px; margin: 0 0 -6px; font-size: 14px; font-weight: 700; }
.fb-panel .fb-opt { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--paper-2); color: var(--muted); border: 1px solid var(--line); } /* 「任意」の札：必須ではないことを、欄の名前の横で示す */
.fb-panel .fb-name { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); }
.fb-panel .fb-name:focus { outline: none; border-color: var(--sun-d); }
.dialog-panel .fb-note { font-size: 12px; line-height: 1.6; color: var(--muted); }
.dialog-panel .fb-msg { min-height: 1.4em; font-size: 14px; font-weight: 700; color: #2f9e5b; text-align: center; }
.dialog-panel .fb-msg.bad { color: var(--danger); }
.fb-panel .dialog-buttons { margin-top: 0; }

/* ---------- 街の形 ---------- */
.shape-preview { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.mini, .editor-grid { display: grid; background: #6f7680; border-radius: 8px; padding: 3px; gap: 1px; }
.mini { width: 104px; height: 104px; flex: none; }
.mini i, .editor-grid i { border-radius: 2px; background: #8fcf6a; }
.mini i.wall, .editor-grid i.wall { background: #a39684; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.shape-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.shape-side span { font-size: 12px; color: var(--muted); white-space: pre-line; } /* 英語は「土地」と「城壁」を2行に分けて出す（文言の改行で折り返す） */
button.small { padding: 6px 12px; font-size: 13px; }
.editor-panel { max-width: 520px; display: flex; flex-direction: column; gap: 12px; }
.editor-help { margin: 0; font-size: 14px; line-height: 1.75; color: var(--ink-2); font-weight: 400; }
.editor-grid { width: min(100%, 440px, calc(100vh - 330px)); aspect-ratio: 1; margin: 0 auto; touch-action: none; user-select: none; cursor: pointer; padding: 4px; gap: 2px; }
.editor-grid i.star:not(.wall) { background: #6bb048; } /* 天元・星の位置 */
.mini i.star:not(.wall) { background: #3f8a2c; } /* 見取り図は区画が小さいので、もっと濃くして見分ける */
.editor-grid i:hover { filter: brightness(1.08); }
.editor-msg { margin: 0; min-height: 1.4em; text-align: center; font-size: 13px; color: var(--muted); }
.editor-msg.bad { color: var(--danger); font-weight: 700; }
.dialog-panel h3 { margin: 0 0 10px; font-size: 19px; font-weight: 900; }
.dialog-panel p { line-height: 1.8; margin: 0; font-size: 15px; font-weight: 400; color: var(--ink-2); }
.dialog-panel p b { color: var(--danger); }
/* 終了時に爆発する決まりは、トップ画面のルールの説明と同じ紅の蛍光ペンで強調する */
.dialog-panel p b.danger { background: linear-gradient(transparent 58%, color-mix(in srgb, var(--p1) 30%, transparent) 58%); padding: 0 1px; }
/* 選ぶダイアログ：選択肢は、見出しと一言の説明をもつ大きなつまみ。いちばん勧める選択肢を黄色に */
.choice-panel { max-width: 460px; }
.choice-list { display: grid; gap: 10px; margin-top: 16px; }
/* 選択肢の下の注意書き：どちらを選んでも、相手もパスすれば終わること（大型工場以外は爆発する）を知らせる */
.dialog-panel p.choice-note {
  position: relative;
  margin: 14px 0 0;
  padding: 10px 12px 10px 36px;
  border-radius: 12px;
  background: #fff3cf;
  color: #6b4a00;
  font-size: 13px;
  line-height: 1.6;
}
.dialog-panel p.choice-note::before { content: "!"; position: absolute; left: 11px; top: 10px; width: 18px; height: 18px; border-radius: 50%; background: var(--sun-d); color: #fff; font-weight: 900; font-size: 12px; line-height: 18px; text-align: center; }
.dialog-panel p.choice-note b { color: var(--danger); }
/* パスの確認：終局で爆発する工場が街の中で光るので、後ろをぼかさず、確認画面を盤の横（縦長の画面では下）へ寄せる */
#dialog.doom-view, #choice.doom-view, body.dev-phone #dialog.doom-view, body.dev-phone #choice.doom-view { background: rgba(29, 36, 48, 0.1); backdrop-filter: none; align-items: flex-end; }
@media (orientation: portrait) {
  #dialog.doom-view, #choice.doom-view, body.dev-phone #dialog.doom-view, body.dev-phone #choice.doom-view { align-items: center; justify-content: safe flex-end; }
}
/* 縦長のスマホでは、盤を映す場所を空けるため、選択肢の補足を隠して確認画面を低くする */
@media (orientation: portrait) and (max-width: 640px) {
  .doom-view button.choice small { display: none; }
  .doom-view button.choice { padding: 8px 12px 8px 8px; }
  .doom-view .choice-list { margin-top: 10px; gap: 8px; }
  .doom-view .dialog-buttons { margin-top: 10px; }
  .doom-view.screen .dialog-panel p.choice-note { margin-top: 10px; }
}
.doom-count { display: block; margin-top: 6px; font-weight: 700; color: var(--ink); }
.doom-count b { font-weight: 900; }
button.choice {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 16px 12px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  box-shadow: 0 3px 0 var(--lip);
}
button.choice .choice-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--paper-2); }
button.choice .choice-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--ink-2); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
button.choice b { display: block; font-family: var(--font-pop); font-size: 16px; font-weight: 800; letter-spacing: 0.04em; color: var(--ink); }
button.choice small { display: block; margin-top: 3px; font-size: 13px; line-height: 1.55; font-weight: 400; color: var(--muted); }
button.choice:hover { background: #fffaf0; border-color: var(--lip); }
button.choice.primary { background: #fff6dc; border-color: var(--sun-d); box-shadow: 0 3px 0 var(--sun-d); }
button.choice.primary:hover { background: #ffefc2; }
button.choice.primary .choice-icon { background: var(--sun); }
button.choice.primary .choice-icon svg { stroke: var(--ink); }
button.choice:active { box-shadow: 0 1px 0 var(--lip); }
button.choice.primary:active { box-shadow: 0 1px 0 var(--sun-d); }

/* ---------- 結果 ---------- */
.result-panel { max-width: 560px; text-align: center; }
.result-title { font-size: 32px; font-weight: 900; margin: 4px 0 16px; }
.result-title.p1 { color: var(--p1); }
.result-title.p2 { color: var(--p2); }
.result-table {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px 22px;
  text-align: left;
  margin: 0 auto;
  max-width: 360px;
  font-size: 15px;
  background: var(--paper-2);
  border-radius: 14px;
  padding: 14px 18px;
}
.result-table .h { color: var(--muted); font-size: 12px; }
/* 工房名の下に、打ったのは誰か（あなた／CPU Lv.N／先手・後手）を小さく */
.result-table .h small { display: block; margin-top: 1px; font-size: 11px; font-weight: 500; color: var(--muted); }
.result-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.result-table .total { font-size: 24px; font-weight: 900; border-top: 2px solid var(--line); padding-top: 8px; }
.result-table .c1 { color: var(--p1); }
.result-table .c2 { color: var(--p2); }
.result-panel .dialog-buttons { justify-content: center; gap: 8px; flex-wrap: nowrap; }
.result-panel .dialog-buttons button { white-space: nowrap; }
/* 1段目：もう一度（黄色）と振り返る（縁だけ）を同じ大きさで横に並べる。スマホ幅でも1段に収める */
.result-panel .result-main button { flex: 1 1 0; min-width: 0; max-width: 210px; padding: 13px 10px; font-size: 17px; border-width: 1.5px; border-radius: 14px; }
.result-panel .result-main button.ghost { border-color: var(--line); }
/* もう一度のボタン：「次の相手を探す」「相手を探しています…」のように長い文言でも、はみ出さずに折り返す。探しているあいだは字を小さく */
.result-panel .result-main #btnAgain { white-space: normal; line-height: 1.25; overflow-wrap: anywhere; }
.result-panel .result-main #btnAgain.seeking { font-size: 14px; letter-spacing: 0; }
/* CPU と対戦の「紅（先手）でもう一度」「蒼（後手）でもう一度」は、それぞれの工房の色で塗る。長い名前は2行に折り返す */
.result-panel .result-main button.again-side { white-space: normal; line-height: 1.25; color: #fff; border-width: 1.5px; }
.result-panel .result-main button.again-side.p1 { background: var(--p1); border-color: var(--p1-d); box-shadow: 0 4px 0 var(--p1-d); }
.result-panel .result-main button.again-side.p2 { background: var(--p2); border-color: var(--p2-d); box-shadow: 0 4px 0 var(--p2-d); }
.result-panel .result-main button.again-side.p1:hover { background: #ea6a54; }
.result-panel .result-main button.again-side.p2:hover { background: #4a8ee6; }
.result-panel .result-main button.again-side:active { box-shadow: 0 1px 0 var(--lip); }
/* 「おまかせでもう一度」は、紅・蒼の2つの下に、2つ分の幅で黄色く置く */
.result-panel .result-main.cpu { flex-wrap: wrap; max-width: 428px; margin-left: auto; margin-right: auto; }
.result-panel .result-main button.again-random { flex: 1 1 100%; max-width: none; padding: 10px; font-size: 15px; background: var(--sun); border-color: var(--sun-d); box-shadow: 0 4px 0 var(--sun-d); }
.result-panel .result-main button.again-random:hover { background: #ffd35e; }
.result-panel .result-main button.again-random:active { box-shadow: 0 1px 0 var(--sun-d); }
/* 2段目：景色をみる・トップへは、文字だけの小さなボタンで控えめに */
.result-panel .result-sub { margin-top: 10px; gap: 4px; }
.result-panel .result-sub button { padding: 6px 12px; font-size: 13px; background: transparent; color: var(--muted); }
.result-panel .result-sub button:hover { color: var(--ink); background: var(--paper-2); }
/* 振り返る・景色をみる・トップへの文字の左に付ける絵（文字と同じ色の線画） */
.result-panel .result-main button, .result-panel .result-sub button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.result-panel .ico { flex: none; width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* CPU と対戦：工房の格付け（称号・数字・増減と、次の相手のおすすめ） */
.result-rating { max-width: 428px; margin: 12px auto 0; padding: 10px 14px; background: var(--paper-2); border-radius: 14px; font-size: 14px; }
.result-rating p { margin: 0; }
.result-rating .rating-now { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: 4px 10px; font-size: 16px; }
.result-rating .rating-num { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.result-rating .rating-delta { font-weight: 800; color: #2d8a3e; font-variant-numeric: tabular-nums; }
.result-rating .rating-delta.down { color: var(--muted); }
.result-rating .rating-up { font-weight: 900; color: var(--sun-d); }
.result-rating .rating-muted { color: var(--muted); font-size: 12px; }
/* 新しい強さが開いた知らせ（段は称号が上がったときと同じ色、中間は控えめ） */
.result-unlock { max-width: 428px; margin: 12px auto 0; padding: 9px 14px; border-radius: 14px; font-size: 14px; font-weight: 800; text-align: center; }
.result-unlock.dan { background: rgba(255, 214, 102, 0.28); color: var(--sun-d); box-shadow: inset 0 0 0 1px rgba(214, 150, 20, 0.35); }
.result-unlock.half { background: var(--paper-2); color: var(--ink-2); font-weight: 700; }
.result-unlock small { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.result-rating .rating-next { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px 8px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.result-panel .result-rating .rating-next button { padding: 3px 10px; font-size: 12px; white-space: nowrap; }
.result-rating.rank-up { animation: rating-pop 0.6s ease-out; }
@keyframes rating-pop { 0% { transform: scale(0.92); } 45% { transform: scale(1.05); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .result-rating.rank-up { animation: none; } }
.setup-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
/* CPU と対戦：次の強さを選ぶ段。結果の表と「もう一度」のあいだに置く */
.result-level { max-width: 428px; margin: 14px auto 0; text-align: left; }
.result-level-label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.result-panel .result-level .seg button { font-size: 14px; }
.result-panel .result-fb { display: flex; align-items: center; gap: 6px; margin: 12px auto 0; padding: 6px 10px; background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); font-size: 13px; font-weight: 700; }
.result-panel .result-fb:hover { color: var(--ink); text-decoration: underline; }
.result-panel .result-fb > span { text-align: left; }
.result-panel .result-fb .nw { white-space: nowrap; } /* 狭い画面では「フィードバック」の直後で折り返す（括弧の中で切らない）。2行になっても印のすぐ右に左揃えで並べる */
.result-panel .result-fb svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 対局中のルール ---------- */
/* 得点板の「◯手目」の下に置く小さな札。押せると分かる程度に控えめに（操作パネルをしまっても残る） */
.turn-info .rules-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  padding: 4px 11px 4px 9px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow);
  white-space: nowrap;
  cursor: pointer;
}
.turn-info .rules-chip svg { flex: none; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .turn-info .rules-chip:hover { color: var(--ink); background: var(--paper-2); } }
.turn-info .rules-chip:active { transform: scale(0.95); box-shadow: none; }
/* 終局の集計が始まってから（結果・景色・振り返り）は出さない */
#hud.ending .rules-chip, #hud.finished .rules-chip, #hud.replaying .rules-chip, #hud.no-rules-chip .rules-chip { display: none; }

/* ---------- ヒントの札（ヒントモードの対局だけ。ルールの札の下／スマホでは横） ---------- */
/* 電球と「ヒント」の下に、残りの回数を3つの灯りで並べる。灯りは使うたびに1つずつ消える */
.turn-info .hint-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0;
  padding: 4px 11px 4px 8px;
  min-height: 34px;
  border: 1.5px solid color-mix(in srgb, var(--sun-d) 55%, var(--line));
  border-radius: 999px;
  background-color: #fff8e2;
  color: #7a5200;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
}
.hint-chip svg { flex: none; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.hint-chip svg .bulb { fill: color-mix(in srgb, var(--sun) 45%, transparent); }
.hint-chip svg .rays { opacity: 0; }
.hint-chip .hint-text { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.hint-chip .hint-pips { display: flex; gap: 3px; }
.hint-chip .hint-pips i { width: 6px; height: 6px; border-radius: 50%; border: 1.2px solid color-mix(in srgb, var(--sun-d) 60%, transparent); background: transparent; transition: background 0.3s, box-shadow 0.3s; }
.hint-chip .hint-pips i.lit { border-color: var(--sun-d); background: var(--sun); box-shadow: 0 0 4px color-mix(in srgb, var(--sun) 85%, transparent); }
@media (hover: hover) { .turn-info .hint-chip:not(:disabled):hover { background-color: #fff0c2; } }
.turn-info .hint-chip:not(:disabled):active { transform: scale(0.95); box-shadow: none; }
/* 自分の番でないとき・考え中・表示中は、押しても何も起きないので少し控えめに */
.turn-info .hint-chip[aria-disabled="true"]:not(.asking):not(.showing) { opacity: 0.72; }
/* 考え中：電球がゆっくり明るくなったり暗くなったりする */
.hint-chip.asking svg .bulb { animation: hintThink 1.1s ease-in-out infinite; }
@keyframes hintThink { 50% { fill: var(--sun); } }
/* 考え中の電球は、手番の工房の色（赤・青）で明滅する */
.hint-chip.asking.turn1 svg .bulb { animation-name: hintThink1; }
.hint-chip.asking.turn2 svg .bulb { animation-name: hintThink2; }
/* 黄色から移ると途中で色が濁る（青なら緑に見える）ので、その色の淡い色と濃い色のあいだで明滅させる */
@keyframes hintThink1 { 0%, 100% { fill: color-mix(in srgb, var(--p1) 22%, transparent); } 50% { fill: var(--p1); filter: drop-shadow(0 0 3px var(--p1)); } }
@keyframes hintThink2 { 0%, 100% { fill: color-mix(in srgb, var(--p2) 22%, transparent); } 50% { fill: var(--p2); filter: drop-shadow(0 0 3px var(--p2)); } }
/* 表示中：電球が灯り、光の線が出る */
.turn-info .hint-chip.showing { background-color: #ffe794; border-color: var(--sun-d); color: #5c3d00; }
.hint-chip.showing svg .bulb { fill: var(--sun); }
.hint-chip.showing svg .rays { opacity: 1; }
/* 使い切ったら薄くする */
.turn-info .hint-chip.empty:not(.showing) { opacity: 0.45; cursor: default; filter: saturate(0.4); }
#hud:not(.has-hint) .hint-chip, #hud.ending .hint-chip, #hud.finished .hint-chip, #hud.replaying .hint-chip, #hud.watching .hint-chip { display: none; }
/* 振り返り（7×7・9×9 だけ）：ヒントの札を対局中と同じ得点板の中央に出す。何度でも聞けるので、残りの回数の灯りは出さない */
#hud.replaying.replay-hint .turn-info .hint-chip { display: inline-flex; }
#hud.replaying .hint-chip .hint-pips { display: none; }
/* おすすめがパスのとき：パスのボタンを黄色く点滅させる */
.dock #btnPass.hint-pass { animation: hintPass 1s ease-in-out infinite; }
@keyframes hintPass { 0%, 100% { box-shadow: inset 0 0 0 2.5px #ffd21f; background-color: #fff3c4; } 50% { box-shadow: inset 0 0 0 2.5px transparent; } }

/* ---------- 結果の画面：次の対局でヒントをもらうか ---------- */
.result-hint { position: relative; display: flex; align-items: center; gap: 8px; max-width: 428px; margin: 14px auto 0; padding: 8px 10px 8px 12px; border: 1.5px dashed color-mix(in srgb, var(--sun-d) 55%, var(--line)); border-radius: 14px; background: #fffaea; text-align: left; }
.dialog-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); cursor: pointer; }
.dialog-check.hidden { display: none; }
.dialog-check input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--sun-d); cursor: pointer; }
.hint-opt { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: 700; color: var(--ink); }
.hint-opt input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--sun-d); cursor: pointer; }
.hint-opt .hint-ico { flex: none; width: 20px; height: 20px; fill: color-mix(in srgb, var(--sun) 45%, transparent); stroke: #7a5200; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hint-opt:has(input:checked) .hint-ico { fill: var(--sun); }
.hint-opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hint-opt-text small { font-size: 12px; font-weight: 400; color: var(--muted); }
.result-hint .hint-na { display: none; }
.result-hint.unavailable .hint-opt { cursor: default; color: var(--muted); }
.result-hint.unavailable .hint-opt input, .result-hint.unavailable .hint-ico { opacity: 0.5; }
.result-hint.unavailable .hint-opt-sub { display: none; }
.result-hint.unavailable .hint-na { display: block; color: #8a5a00; }
.result-panel .result-hint .hint-q { flex: none; width: 26px; height: 26px; min-width: 0; padding: 0; margin: 0; border: 1.5px solid color-mix(in srgb, var(--sun-d) 60%, var(--line)); border-radius: 50%; background: var(--paper); color: #7a5200; font-size: 14px; font-weight: 900; line-height: 1; box-shadow: none; cursor: pointer; }
.result-panel .result-hint .hint-q[aria-expanded="true"] { background: var(--sun); border-color: var(--sun-d); }
/* ［?］の吹き出し：欄の上に浮かべ、右端の［?］を指す */
.hint-help { position: absolute; right: 0; bottom: calc(100% + 10px); z-index: 5; width: min(320px, calc(100vw - 48px)); padding: 10px 14px; border: 1.5px solid var(--sun-d); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); font-size: 13px; line-height: 1.6; color: var(--ink-2); text-align: left; }
.hint-help p { margin: 0; }
.hint-help p + p { margin-top: 4px; }
.hint-help::after { content: ""; position: absolute; right: 16px; bottom: -7px; width: 12px; height: 12px; background: var(--paper); border-right: 1.5px solid var(--sun-d); border-bottom: 1.5px solid var(--sun-d); transform: rotate(45deg); }
/* 小窓：トップ画面の説明の枠をそのまま入れる */
.rule-sheet-panel { max-width: 460px; display: flex; flex-direction: column; gap: 12px; }
.rule-sheet-panel .rules-head .close { margin-left: auto; }
.rule-sheet-panel .rule-box { margin: 0; }
.rule-sheet-panel .dialog-buttons { justify-content: center; margin: 0; }
.rule-sheet-panel #btnRuleSheetBack { min-width: 200px; }
/* 札を出さないチェック：小さな灰色の字で控えめに、行のどこを押しても切り替わる */
.rule-sheet-opt { display: flex; align-items: center; justify-content: center; gap: 6px; margin: -4px auto 0; padding: 4px 8px; font-size: 13px; color: var(--muted); cursor: pointer; text-align: left; }
.rule-sheet-opt input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--ink-2); cursor: pointer; }

/* ---------- 対局中：上の得点板 ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.scoreboard {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(660px, calc(100vw - 24px)); /* 札の中の名前と得点が離れすぎないよう、札の幅を詰める */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: stretch;
  pointer-events: none;
}
/* 会社の札：左から 紋章｜会社名・役割・数｜得点。得点の欄は幅を決めておき、数が増えても札の形が変わらない */
.player {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  grid-template-areas: "emb name score" "emb role score" "emb stats stats"; /* 数の行は得点の下まで使い、桁が増えても切れない */
  column-gap: 12px;
  align-items: center;
  align-content: center;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 9px 14px 15px; /* 下の余白：手番・パスの札が数の行に重ならないように */
  min-width: 0;
  min-height: 70px;
  box-shadow: var(--shadow);
  outline: 3px solid transparent;
  transition: outline-color 0.25s, transform 0.25s;
}
.player.p2 { grid-template-columns: auto minmax(0, 1fr) 40px; grid-template-areas: "score name emb" "score role emb" "stats stats emb"; text-align: right; }
.player.active { transform: translateY(2px); }
.player.active.p1 { outline-color: var(--p1); }
.player.active.p2 { outline-color: var(--p2); }
.emblem {
  grid-area: emb;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  /* 画数の多い「紅」「蒼」がつぶれないよう、読みやすい書体の太字で大きめに */
  font-weight: 700;
  font-size: 23px;
  line-height: 1;
  padding-bottom: 2px;
  color: #fff;
}
.p1 .emblem { background: var(--p1); box-shadow: inset 0 -3px 0 var(--p1-d); }
.p2 .emblem { background: var(--p2); box-shadow: inset 0 -3px 0 var(--p2-d); }
.pname { grid-area: name; font-weight: 800; font-size: 15px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.prole { grid-area: role; font-size: 13px; font-weight: 700; line-height: 1.3; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstats { grid-area: stats; font-size: 11px; color: var(--muted); display: flex; gap: 10px; margin-top: 3px; white-space: nowrap; overflow: hidden; }
.pstats span { display: inline-flex; align-items: baseline; gap: 3px; }
.player.p2 .pstats { justify-content: flex-end; }
.pstats b { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.pscore { grid-area: score; display: flex; align-items: baseline; justify-content: flex-end; gap: 2px; line-height: 1; min-width: 3.4em; }
.p2 .pscore { justify-content: flex-start; }
.pscore b { font-size: 34px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pscore small { font-size: 12px; color: var(--muted); }
.no-unit .pscore small { display: none; }
.hide-score .pscore, .hide-score .pstats { display: none; }
.pscore .cap { font-size: 10px; font-weight: 700; color: var(--muted); margin-right: 3px; writing-mode: vertical-rl; letter-spacing: 0.05em; line-height: 1; align-self: center; }
.pstats span { white-space: nowrap; }
.p1 .pscore b { color: var(--p1); }
.p2 .pscore b { color: var(--p2); }
.turn-tag {
  position: absolute;
  bottom: -11px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
}
.p1 .turn-tag { left: 14px; background: var(--p1); }
.p2 .turn-tag { right: 14px; background: var(--p2); }
.player.active .turn-tag { opacity: 1; transform: none; }
/* 直前にパスした会社：次の手が打たれるまで札を出しておく */
.pass-tag {
  position: absolute;
  bottom: -11px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #5b6470;
  padding: 3px 10px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
}
.p1 .pass-tag { left: 14px; }
.p2 .pass-tag { right: 14px; }
.player.passed .pass-tag { opacity: 1; transform: none; animation: passPulse 1.6s ease-in-out infinite; }
@keyframes passPulse { 50% { background: #7d8794; } }
/* オートパス中：パスの札の代わりに、解除ボタンを兼ねた札を出す（相手の番でも押せる） */
.auto-tag {
  position: absolute;
  bottom: -13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  border: 0;
  padding: 3px 5px 3px 9px;
  border-radius: 999px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s, background 0.15s;
}
.p1 .auto-tag { left: 14px; }
.p2 .auto-tag { right: 14px; }
.auto-tag svg { width: 13px; height: 13px; fill: none; stroke: var(--sun); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; animation: autoSpin 2.4s linear infinite; }
.auto-tag i { font-style: normal; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); font-size: 11px; line-height: 1; }
.auto-tag:hover { background: #343d4c; }
.auto-tag:hover i { background: rgba(255, 255, 255, 0.3); }
.auto-tag:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.player.auto .auto-tag { opacity: 1; visibility: visible; transform: none; }
.player.auto .pass-tag, .player.auto .turn-tag { opacity: 0; }
@keyframes autoSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auto-tag svg { animation: none; } }
.dock button.endpass { background: #fff3cf; color: #8a5a00; }
/* オートパス中のパスのボタン：止めるためのボタンだとわかるよう、札の「オート ×」と同じ濃い色に */
.dock button.autostop { background: var(--ink); color: #fff; }
.dock button.autostop svg { stroke: var(--sun); }
@media (hover: hover) { .dock button.autostop:where(:not(.hover-off)):hover { background: #343d4c; } }
/* 中央：手数と「検討中」はそれぞれ別の札。手数の札は位置を固定し、検討中はその下に出る */
.turn-info {
  align-self: start;
  margin-top: 21px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 76px;
  white-space: nowrap;
}
#moveNo, #thinking {
  width: 100%;
  text-align: center;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 0;
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}
#moveNo { font-size: 13px; color: var(--ink-2); background: var(--paper); }
#thinking { font-size: 12px; padding: 4px 0; color: #8a5a00; background: #fff3cf; }
.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "・"; } 50% { content: "・・"; } 75% { content: "・・・"; } }

/* ---------- 対局中：下の操作 ---------- */
/* 説明文・再生バー・操作の案内は、下のメニューの実際の高さ（--dock-top、画面の下からメニューの上端まで）の上に積む。
   値は main.js がメニューの大きさを見張って入れる。入る前の一瞬だけ、ふつうの高さを予備値に使う */
#message {
  position: absolute;
  bottom: calc(var(--dock-top, 84px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(29, 36, 48, 0.86);
  color: #fff;
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 15px;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
#message:empty { display: none; }
.dock {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--paper);
  border-radius: 20px;
  padding: 6px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 16px);
  overflow-x: auto;
  scrollbar-width: none;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s;
}
/* メニューをしまう：メニューは画面の下へ沈み、代わりに小さな引き手が下から顔を出す */
#hud.dock-hidden .dock { transform: translate(-50%, calc(100% + 24px)); opacity: 0; pointer-events: none; }
#dockTab {
  position: absolute;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, calc(100% + 20px));
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 16px 5px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  background: rgba(253, 248, 236, 0.92);
  border: 0;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.3, 1.3, 0.5, 1), opacity 0.2s, background 0.15s;
}
#dockTab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; animation: tabNudge 2.4s ease-in-out 3; }
@keyframes tabNudge { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-3px); } 90% { transform: translateY(0); } }
#hud.dock-hidden #dockTab { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; transition-delay: 0.12s; }
#hud.dock-hidden #dockTab:hover { background: var(--paper); color: var(--ink); transform: translate(-50%, -2px); transition-delay: 0s; }
#hud.dock-hidden #dockTab:active { transform: translate(-50%, 0) scale(0.96); }
/* しまうボタンは控えめに、少し細く */
.dock .hide-btn { min-width: 52px; }
#message, .replay-bar, #camHint { transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
#btnMenu .lbl-short { display: none; } /* スマホの縦画面では幅が足りないので短い言い方にする */
.dock .sep { width: 1px; align-self: stretch; margin: 8px 4px; background: var(--line); flex: none; }
.dock button, .display-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 68px;
  padding: 7px 8px 6px;
  font-size: 12px;
  font-weight: 700;
  border: 0;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
  color: var(--ink-2);
  white-space: nowrap;
}
/* 矢印を載せたときの色：指で触る端末では押した後に残るので付けない。マウスでも押した直後は、矢印を一度離すまで付けない（hover-off は main.js が付け外しする） */
@media (hover: hover) { .dock button:where(:not(.hover-off)):hover, .display-grid button:hover { background: var(--paper-2); color: var(--ink); } }
/* 「設定」：吹き出しを開いている間は色を付けたままにする */
#btnDisplay[aria-expanded="true"] { background: var(--paper-2); color: var(--ink); }
.dock button:active, .display-grid button:active { transform: scale(0.95); box-shadow: none; }
.dock button:disabled { box-shadow: none; }
.dock button.on, .display-grid button.on { background: #fff3cf; color: #8a5a00; }
/* 切り替えボタン：右上の小札で今の状態（オン・オフ）を示す */
.dock button.toggle, .display-grid button.toggle { position: relative; }
.dock button.toggle::after, .display-grid button.toggle::after {
  content: 'OFF';
  position: absolute;
  top: 3px;
  right: 3px;
  padding: 0 4px;
  border-radius: 6px;
  font-size: 9px;
  line-height: 14px;
  background: var(--paper-2);
  color: var(--ink-2);
  opacity: 0.85;
}
.dock button.toggle.on::after, .display-grid button.toggle.on::after { content: 'ON'; background: #2f9e5b; color: #fff; opacity: 1; }
.dock button.toggle:not(.on) svg, .display-grid button.toggle:not(.on) svg { opacity: 0.4; }
/* 直前手のボタンの絵：工場の表示は区画の枠の中の工場、碁盤の表示は碁石の上の丸印 */
.mark-icon-go, html.go-look .mark-icon-city { display: none; }
html.go-look .mark-icon-go { display: block; }
/* 操作パネルのボタンで開く吹き出し（押したボタンの真上に出る） */
.time-pop { position: fixed; z-index: 13; display: flex; flex-direction: column; gap: 6px; width: max-content; max-width: calc(100vw - 16px); padding: 8px; background: var(--paper); border: 1.5px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); pointer-events: auto; }
.time-pop .seg { flex-wrap: nowrap; }
.time-pop .seg button { min-width: 44px; padding: 8px 10px; white-space: nowrap; }
/* 「表示」の吹き出し：上に時間帯、下に切り替えのボタンを3つずつ並べる。操作パネルの上に収まらないときは中だけスクロール */
.display-pop { width: 340px; max-height: calc(100vh - var(--dock-top, 84px) - 24px); max-height: calc(100dvh - var(--dock-top, 84px) - 24px); overflow-y: auto; }
/* 下へなぞると畳めることを示すつまみ（指で操作する端末だけ） */
/* 上の帯：閉じるボタンを右上の角に置き、つまみはその帯の真ん中に重ねる。下の時間帯の行とは高さを分ける */
.display-pop .pop-head { position: relative; display: flex; justify-content: flex-end; margin: -2px -2px -3px 0; }
.display-pop .pop-grip { display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
@media (pointer: coarse) { .display-pop .pop-grip { display: block; } }
/* 時間帯：左に時計のマーク、右に時間帯の段（右端に閉じるボタン）と速さの段。時計のマークは右の段全体の上下の真ん中に来る */
.display-pop .pop-time { display: flex; align-items: center; gap: 6px; }
.display-pop .pop-time-rows { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.display-pop .pop-time-row { display: flex; align-items: center; gap: 6px; }
.display-pop .pop-time-row .seg { flex: 1 1 auto; min-width: 0; }
.display-pop .pop-close { position: relative; flex: none; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 1.5px solid var(--line); border-radius: 6px; background: transparent; box-shadow: none; transform: none; color: var(--muted); cursor: pointer; }
.display-pop .pop-close:hover { background: rgba(0, 0, 0, 0.08); }
/* 見た目は小さいまま、指で押せる範囲だけ広げる */
.display-pop .pop-close::after { content: ''; position: absolute; inset: -6px; }
.display-pop .pop-close svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.display-pop .seg button { flex: 1 1 0; min-width: 0; padding: 8px 4px; }
/* 項目の名前の時計のマークは、選択肢の枠の外の左に、枠なしの薄い色で置く。
   変化の速さの段は、上の段と枠の幅をそろえる */
.display-pop .pop-label { flex: none; display: grid; place-items: center; width: 30px; color: var(--muted); }
.display-pop .pop-label svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* 朝・昼・夕・夜・変化はアイコンで並べる（下の切り替えボタンと同じ線の絵） */
.display-pop .seg-icons button { display: grid; place-items: center; padding: 7px 4px; }
.display-pop .seg-icons button svg { width: 22px; height: 22px; }
/* 変化の速さは時間帯の添え物なので、アイコンを小さく、段も低くして控えめにする */
.display-pop #displaySpeed .seg { padding: 3px; }
.display-pop #displaySpeed .seg button { padding: 3px 4px; }
.display-pop #displaySpeed .seg button svg { width: 15px; height: 15px; stroke-width: 2.2; }
/* 時間帯と速さのアイコンの名前を出す小さな吹き出し（マウスを載せる・指で押すと出る） */
.icon-tip { position: fixed; z-index: 14; left: 0; top: 0; padding: 3px 8px; border-radius: 8px; background: var(--ink); color: var(--paper); font-size: 12px; font-weight: 700; line-height: 1.4; white-space: nowrap; pointer-events: none; opacity: 0; transform: translateY(2px); transition: opacity 0.12s, transform 0.12s; }
.icon-tip.on { opacity: 0.94; transform: none; }
.display-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.display-grid button { min-width: 0; padding: 9px 4px 7px; white-space: normal; line-height: 1.2; text-align: center; }
#camHint {
  position: absolute;
  bottom: calc(var(--dock-top, 84px) + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  pointer-events: none;
  display: none;
}
/* 拡大縮小ボタン（画面の右端） */
#zoomCtl {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
#zoomCtl button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink-2);
  display: grid;
  place-items: center;
}
#zoomCtl button + button { border-top: 1px solid var(--line); }
#zoomCtl button:hover { background: var(--paper-2); color: var(--ink); }
#zoomCtl button:active { transform: none; background: var(--paper-2); }
#zoomCtl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
@media (hover: none) { #zoomCtl { display: none; } } /* 指で触る端末はピンチで足りる */
@media (hover: hover) { #camHint { display: block; } #message { bottom: calc(var(--dock-top, 84px) + 24px); } }
/* 指で触る端末：2本指の動かし方を、覚えるまで出す（覚えたら .done で消える）。狭い画面では2行に折り返す */
@media (hover: none) {
  #camHint.touch { display: block; white-space: normal; text-align: center; width: max-content; max-width: calc(100vw - 32px); line-height: 1.35; transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s; }
  #camHint.touch.done { opacity: 0; visibility: hidden; transition: opacity 0.5s, visibility 0s 0.5s; }
  #hud:not(.replaying):has(#camHint.touch:not(.done):not(.hidden)) #message { bottom: calc(var(--dock-top, 84px) + 12px + var(--cam-hint-h, 16px)); }
}

/* ---------- 演出 ---------- */
#fxLayer { position: fixed; inset: 0; pointer-events: none; z-index: 15; overflow: hidden; }
/* 終了時の番号は街の上の目印なので、得点板・下のボタン・画面より奥に出す */
#labelLayer { position: fixed; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }
.pop {
  position: absolute;
  font-weight: 900;
  font-size: clamp(20px, 5.8vw, 28px); /* スマホ（幅 375px）で約 22px、幅 483px 以上は 28px */
  transform: translate(-50%, -50%);
  animation: popUp 1.1s ease-out forwards;
  -webkit-text-stroke: 0.18em #fff; /* ふちも字の大きさに合わせる（28px のとき 5px） */
  paint-order: stroke fill;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.25));
  white-space: nowrap;
}
@keyframes popUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.4); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.25); }
  30% { transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}
/* 帯：画面を横切るリボン */
.banner {
  --c: #ffc93c;
  position: absolute;
  left: 0;
  right: 0;
  top: max(34%, var(--telop-top, 0px)); /* 持ち時間の時計を出しているときは、時計より下に */
  display: flex;
  justify-content: center;
  animation: bannerLife 4s forwards;
}
.banner .band {
  background: color-mix(in srgb, var(--c) 78%, transparent); /* 濃いめの半透明。字は透かさない */
  color: #fff;
  padding: 14px 48px 16px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(24, 34, 52, 0.28);
  border-radius: 6px;
  animation: bandIn 4s cubic-bezier(0.2, 1.2, 0.4, 1) forwards;
  max-width: calc(100vw - 24px);
}
.banner b { display: block; font-size: clamp(28px, 5.4vw, 52px); letter-spacing: 0.06em; line-height: 1.15; white-space: nowrap; }
.banner small { display: block; font-size: clamp(14px, 1.8vw, 17px); font-weight: 700; font-family: var(--font); margin-top: 4px; opacity: 0.95; }
@keyframes bannerLife { 0%, 90% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bandIn {
  0% { transform: scaleX(0.2) scaleY(0.6); opacity: 0; }
  7% { transform: scaleX(1.03) scaleY(1); opacity: 1; }
  11%, 90% { transform: none; }
  100% { transform: translateY(-16px); }
}
/* レーティング戦の対戦カード：左に自分、右に相手が滑り込み、中央に VS（対局の始めに一瞬だけ） */
.match-card {
  position: absolute;
  left: 0;
  right: 0;
  top: max(30%, var(--telop-top, 0px));
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 0 8px;
  animation: bannerLife 1.6s forwards;
}
.mc-side {
  --c: #ffc93c;
  flex: 0 1 min(40vw, 300px);
  min-width: 0;
  background: color-mix(in srgb, var(--c) 82%, transparent);
  color: #fff;
  padding: 12px 18px 14px;
  box-shadow: 0 12px 30px rgba(24, 34, 52, 0.28);
  text-align: center;
}
.mc-me { border-radius: 8px 0 0 8px; animation: mcFromLeft 1.6s cubic-bezier(0.2, 1.2, 0.4, 1) forwards; }
.mc-opp { border-radius: 0 8px 8px 0; animation: mcFromRight 1.6s cubic-bezier(0.2, 1.2, 0.4, 1) forwards; }
.mc-side b { display: block; font-size: clamp(18px, 4.6vw, 34px); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-side small { display: block; font-size: clamp(12px, 3.2vw, 16px); font-weight: 700; font-family: var(--font); margin-top: 4px; opacity: 0.95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-vs {
  flex: none;
  z-index: 1;
  margin: 0 -14px;
  width: clamp(44px, 11vw, 64px);
  height: clamp(44px, 11vw, 64px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1d2430;
  color: #ffc93c;
  font-weight: 900;
  font-size: clamp(16px, 4.4vw, 26px);
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 3px #fff, 0 10px 24px rgba(24, 34, 52, 0.35);
  animation: mcVs 1.6s ease-out forwards;
}
@keyframes mcFromLeft {
  0% { transform: translateX(-60vw); opacity: 0; }
  18% { transform: translateX(6px); opacity: 1; }
  24%, 88% { transform: none; }
  100% { transform: translateX(-24px); }
}
@keyframes mcFromRight {
  0% { transform: translateX(60vw); opacity: 0; }
  18% { transform: translateX(-6px); opacity: 1; }
  24%, 88% { transform: none; }
  100% { transform: translateX(24px); }
}
@keyframes mcVs {
  0%, 16% { transform: scale(0); opacity: 0; }
  26% { transform: scale(1.35); opacity: 1; }
  34%, 100% { transform: scale(1); opacity: 1; }
}
.flash { position: absolute; inset: 0; animation: flash 0.45s ease-out forwards; }
@keyframes flash { from { opacity: 0.6; } to { opacity: 0; } }

#toast {
  position: fixed;
  top: max(112px, var(--telop-top, 0px)); /* 持ち時間の時計を出しているときは、時計より下に */
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px;
  border-left: 5px solid var(--danger);
  box-shadow: var(--shadow);
  padding: 12px 20px;
  font-size: 15px;
  line-height: 1.65;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
  pointer-events: none;
  max-width: min(520px, calc(100vw - 32px));
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.info { border-left-color: var(--sun); }

/* 終了時の番号 */
.count-label {
  position: absolute;
  transform: translate(-50%, -100%);
  min-width: 30px;
  padding: 2px 9px;
  border-radius: 999px;
  text-align: center;
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  line-height: 1.35;
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(24, 34, 52, 0.3);
  animation: labelIn 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
  pointer-events: none;
}
.count-label.c1 { background: var(--p1); }
.count-label.c2 { background: var(--p2); }
.count-label.yard { border-color: var(--sun); }
.count-label small { display: block; font-size: 10px; font-weight: 800; color: #fff3cf; }
@keyframes labelIn { from { transform: translate(-50%, -60%) scale(0.2); opacity: 0; } }

/* 終了時の得点表 */
#tally {
  position: fixed;
  top: 116px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--paper);
  border-radius: 20px;
  padding: 12px 22px;
  z-index: 12;
  box-shadow: var(--shadow);
}
#tally .t { text-align: center; min-width: 130px; }
#tally .tn { font-size: 13px; font-weight: 700; }
#tally .c1 .tn, #tally .c1 b { color: var(--p1); }
#tally .c2 .tn, #tally .c2 b { color: var(--p2); }
#tally b { display: block; font-size: 44px; font-variant-numeric: tabular-nums; line-height: 1.1; transition: transform 0.15s; }
#tally small { font-size: 12px; color: var(--muted); }
#tally .vs { color: var(--muted); font-weight: 900; }
#tally[data-now="1"] .c1 b, #tally[data-now="2"] .c2 b { transform: scale(1.12); }

/* ---------- 画面が低いとき ---------- */
@media (max-height: 720px) {
  .menu-card { padding: 22px 24px 20px; }
  .title-block { margin-bottom: 14px; }
  h1 { font-size: clamp(28px, 3.6vw, 38px); }
  .tagline { margin-top: 8px; font-size: 13px; }
  .row { margin-bottom: 9px; }
  .setup h2 { margin-bottom: 10px; font-size: 18px; }
  button.big { padding: 12px 22px; font-size: 16px; }
  .rules-figure { min-height: 150px; }
  .rules-figure svg { max-width: 210px; }
  .rules-text { min-height: 0; font-size: 14px; line-height: 1.75; }
}

/* ---------- 横向きのスマホ・小さな窓：縦の幅は惜しいので、ボタンを詰めて1列に収める ---------- */
@media (min-width: 641px) and (max-width: 900px) {
  .dock { padding: 4px; }
  .dock button { min-width: 48px; padding: 6px 5px 5px; font-size: 11px; letter-spacing: -0.03em; }
  .dock .sep { margin: 6px 2px; }
  .dock button.toggle::after { top: 1px; right: 1px; padding: 0 3px; }
}

/* ---------- スマホ ---------- */
@media (max-width: 640px) {
  #menu { align-items: center; padding-left: 16px; background: none; }
  .menu-card { padding: 22px 20px; }
  .scoreboard { grid-template-columns: 1fr 1fr; gap: 8px; width: calc(100vw - 16px); top: max(8px, env(safe-area-inset-top)); }
  /* スマホ：「◯手目」は出さず、ルールの札だけを赤と青の札の下の中央に置く */
  .turn-info { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); width: auto; margin-top: 8px; }
  .turn-info #moveNo { display: none; }
  #hud.ending .turn-info, #hud.finished .turn-info, #hud.replaying .turn-info, #hud.no-rules-chip:not(.has-hint) .turn-info { display: none; }
  /* スマホ：ルールとヒントの札は、得点板の下に横に並べる */
  #hud.has-hint .turn-info { flex-direction: row; }
  /* スマホの振り返り（7×7・9×9 だけ）：得点板の下の中央には、ヒントの札だけを出す（「振り返り」の札と手数は出さない） */
  #hud.replaying.replay-hint .turn-info { display: flex; }
  #hud.replaying .turn-info::before { display: none; }
  /* スマホ：数の行だけ札の下いっぱいに広げる */
  .player { padding: 8px 8px 14px; column-gap: 6px; min-height: 0; grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "emb name score" "emb role score" "stats stats stats"; }
  .player.p2 { grid-template-columns: auto minmax(0, 1fr) 26px; grid-template-areas: "score name emb" "score role emb" "stats stats stats"; }
  .emblem { width: 26px; height: 26px; font-size: 17px; border-radius: 8px; }
  .pname { font-size: 13px; }
  .prole { font-size: 12px; }
  .pstats { gap: 8px; font-size: 10px; margin-top: 5px; padding-top: 4px; border-top: 1px solid var(--line); }
  .pstats b { font-size: 12px; }
  .pscore b { font-size: 24px; letter-spacing: -0.03em; }
  .pscore b.long { font-size: 19px; }
  .pscore { min-width: 2.4em; }
  .pscore small { font-size: 10px; }
  /* スマホ：見え方の切り替えは「表示」の吹き出しにまとめたので、どの場面でもボタンは6つまで。画面の幅いっぱいの1段に等分して並べる */
  .dock { flex-wrap: nowrap; justify-content: center; width: calc(100vw - 16px); overflow: visible; border-radius: 16px; padding: 4px; }
  .dock .sep { margin: 6px 2px; }
  .dock button { flex: 1 1 0; min-width: 0; padding: 6px 1px 5px; font-size: 10.5px; letter-spacing: -0.04em; white-space: normal; line-height: 1.15; text-align: center; }
  .dock button svg { width: 20px; height: 20px; }
  .dock button.toggle::after { top: 1px; right: 1px; padding: 0 3px; font-size: 8px; line-height: 12px; }
  /* スマホの説明文：1行に収まらない文も「…」で切らず、折り返して全部見せる */
  #message { font-size: 13px; line-height: 1.5; white-space: normal; text-align: center; width: max-content; max-width: calc(100vw - 24px); border-radius: 14px; padding: 7px 14px; }
  #btnMenu .lbl-long { display: none; }
  #btnMenu .lbl-short { display: inline; }
  .dock .hide-btn { min-width: 0; }
  #dockTab { padding: 8px 22px 8px 16px; font-size: 13px; } /* 指で押しやすい大きさに */
  .display-grid button { font-size: 11.5px; } /* 「2回タップ」などが1行に収まる大きさ */
  #toast { top: max(96px, var(--telop-top, 0px)); }
  /* 対局中は得点板の下にルールの札があるので、お知らせはその下に出す */
  body:has(#hud:not(.hidden):not(.ending):not(.finished):not(.replaying):not(.no-rules-chip)) #toast,
  body:has(#hud.has-hint:not(.hidden):not(.ending):not(.finished):not(.replaying)) #toast { top: max(134px, var(--telop-top, 0px)); }
  #tally { top: 96px; gap: 8px; padding: 8px 12px; }
  #tally .t { min-width: 96px; }
  #tally b { font-size: 32px; }
  .setup-buttons, .dialog-buttons { justify-content: center; }
  /* スマホの設定画面：題字を外し、行の間を詰めて、なるべくスクロールなしで開始のボタンまで見せる */
  #menu:has(#setup:not(.hidden)) .title-block { display: none; }
  #menu:has(#setup:not(.hidden)) .menu-card { padding-top: 16px; }
  .setup h2 { margin-bottom: 8px; font-size: 18px; }
  .row { margin-bottom: 8px; }
  .row label { margin-bottom: 4px; }
  .seg button { padding: 7px 4px; min-width: 52px; } /* 時間帯の5つも1段に並べる */
  .seg[data-key^="level"] button { min-width: 0; padding: 7px 2px; letter-spacing: 0; } /* CPUの強さの6つも1段に並べる */
}

/* ポップな丸ゴシックを使う所（大きい文字だけ） */
h1, h2, h3, .result-title, button.big, .pscore b, #tally b, .banner b, .pop, .count-label, .rules-head h2 { font-family: var(--font-pop); }
body { font-weight: 400; }
button { font-weight: 700; }

/* ============================================================
   崖の上の囲碁 — 絵本のような画面
   生成りの紙に、こげ茶のインク。見出しは端正な明朝、本文はやわらかい丸ゴシック、
   ひとことは手書き風。押せるものは、ふっくらした紙のつまみ。
   ============================================================ */
:root {
  --ink: #3b2c1f;
  --ink-2: #5d4a37;
  --muted: #8a7660;
  --paper: #fdf8ec;
  --paper-2: #f5ecd6;
  --paper-3: #ecdfc0;
  --line: #e0cda6;
  --lip: #cdb48a;
  --p1: #c8452f;
  --p1-d: #9c3020;
  --p1-t: #fbe6dc;
  --p2: #2f6fa8;
  --p2-d: #22527e;
  --p2-t: #e2edf6;
  --sun: #f2c35b;
  --sun-d: #c48d2c;
  --danger: #c8452f;
  --radius: 18px;
  --shadow: 0 10px 28px rgba(70, 48, 24, 0.18), 0 2px 6px rgba(70, 48, 24, 0.1);
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-pop: "Kaisei Decol", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-hand: "Klee One", "Zen Maru Gothic", serif;
  /* 紙のざらつき */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.33  0 0 0 0 0.2  0 0 0 0.09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
html, body { background: #cfe3ee; font-weight: 500; }
b { font-weight: 700; }

/* 紙の札とパネル：内側にもう一本、細い縁取り */
.panel, .menu-card, .player, .dock, .turn-info > * {
  background-color: var(--paper);
  background-image: var(--grain);
}
.panel, .menu-card {
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow), inset 0 0 0 5px var(--paper), inset 0 0 0 6px rgba(205, 180, 138, 0.55);
}
button { font-weight: 700; border-radius: 14px; background-color: var(--paper); background-image: var(--grain); }
button:not(:where(.dock button, .display-grid button)):hover { background-color: #fffbf1; }
button.big, #dialogYes, #btnAgain, #btnRuleNext { background-color: var(--sun); font-family: var(--font-pop); letter-spacing: 0.06em; }
button.big:hover, #dialogYes:hover, #btnAgain:hover, #btnRuleNext:hover { background-color: #f6cf73; }
button.big.alt { background-color: var(--paper); }

/* タイトル：空の明るい側から光が差すように */
#menu { background: linear-gradient(90deg, rgba(253, 248, 236, 0.55), rgba(253, 248, 236, 0) 50%); }
.subtitle { font-family: var(--font-pop); font-size: 14px; letter-spacing: 0.32em; color: #a0742a; font-weight: 700; font-style: italic; }
h1 {
  font-family: var(--font-pop);
  font-weight: 700;
  font-size: clamp(38px, 4.6vw, 52px);
  letter-spacing: 0.08em;
  color: #34261a;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
}
/* 日本語のタイトルの「クリフ」：字の左右の余白が大きいぶんを詰め、囲・碁の字間にそろえる */
h1 .kana-ku { letter-spacing: -0.14em; }
h1 .kana-ri { letter-spacing: -0.17em; }
h1 .kana-fu { letter-spacing: -0.04em; }
/* 見出しの下の飾り：紅と蒼の糸を、ゆるい波で */
h1::after, .title-block::after {
  width: 120px;
  height: 10px;
  border-radius: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='10'><path d='M2 6 Q 17 0 32 5 T 60 5' fill='none' stroke='%23c8452f' stroke-width='2.6' stroke-linecap='round'/><path d='M60 5 Q 75 10 90 5 T 118 4' fill='none' stroke='%232f6fa8' stroke-width='2.6' stroke-linecap='round'/></svg>") no-repeat;
}
/* 題名の文字だけをカードの中央に置き、その左横に、アイコンと同じ印（崖の上の台地）を添える。小見出し・波の飾り・紹介文は全幅で */
.title-block { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
.title-block > .subtitle { grid-column: 1 / -1; grid-row: 1; text-align: center; }
.title-block > h1 { grid-column: 2; grid-row: 2; text-align: center; white-space: nowrap; }
/* 波の飾りは題名の文字数や言語に左右されないよう、題名から離して独立の行にし、カードの真ん中に置く */
.title-block > h1::after { content: none; }
.title-block::after { content: ""; grid-column: 1 / -1; grid-row: 3; justify-self: center; margin-top: 12px; }
.title-block > .tagline { grid-column: 1 / -1; grid-row: 4; }
/* 題字の行の高さを変えないよう、上下の余白を負にする。top は題字の字面の中央に合わせる分。印の幅は題名の左右の空きに合わせ、カードの内余白には少しはみ出してよい */
.title-mark { grid-column: 1; grid-row: 2; justify-self: end; align-self: center; position: relative; top: 6px; width: 60px; height: auto; margin: -24px 8px -24px 0; }
@media (max-width: 640px) {
  .title-mark { width: 44px; margin-right: 6px; }
  /* 題名の長い日本語・韓国語は、小さなスマホでも1行に収まるよう、カードの幅に合わせて字を小さくする（168px は画面の余白・カードの内余白・題名の左右に取る印の分） */
  :root:lang(ja) .title-block > h1, :root:lang(ko) .title-block > h1 { font-size: min(38px, calc((100vw - 168px) / 5.4)); }
}
.tagline { font-family: var(--font-hand); font-size: 14px; line-height: 1.9; letter-spacing: -0.01em; color: var(--ink-2); }
/* 題名の下の紹介：1行目は題名と同じ書体で大きく、2行目は本文の書体で小さく。狭い画面では1行目がカードの幅に収まるよう字を小さくする */
.menu-lead { text-align: center; letter-spacing: 0; color: var(--ink); }
.lead-main { display: block; font-family: var(--font-pop); font-weight: 700; font-size: min(22px, calc((100vw - 72px) / 15.2)); line-height: 1.35; }
.lead-sub { display: block; font-family: var(--font); font-weight: 500; font-size: 14.5px; line-height: 1.45; margin-top: 1px; }
@media (max-width: 640px) { .lead-main { font-size: min(20px, calc((100vw - 72px) / 15.2)); } .lead-sub { font-size: 13.5px; } :root:lang(en) .lead-sub { font-size: min(13.5px, calc((100vw - 72px) / 23.2)); } }
h2, h3, .rules-head h2, .result-title, .dialog-panel h3 { font-family: var(--font-pop); letter-spacing: 0.05em; }
.note, .editor-help { font-family: var(--font-hand); }
#rules, #dialog, #choice, #result, #editor, #feedback, #ruleSheet, #history, #online { background: rgba(72, 52, 30, 0.32); }

/* 遊んでいるときの札：数字は端正な明朝で */
.pscore b, #tally b, .banner b, .pop, .count-label { font-family: var(--font-pop); }
.player { border: 1.5px solid var(--line); }
.emblem { font-family: var(--font-pop); }
.dock { border: 1.5px solid var(--line); }
.dock button, .display-grid button { background-image: none; }
.dock button.on, .display-grid button.on { background-color: #fff1cf; }

/* ---------- 手番をひと目で ----------
   手番の札：会社の色で縁取り、色の光がゆっくり脈打つ。下に「紅の番」の札。
   手番でない札：少し淡くする。どれも大きさは変えない（縁と影と色だけ） */
.player.active.p1 { background-color: #fdeee6; outline: 3px solid var(--p1); --glow: rgba(200, 69, 47, 0.28); }
.player.active.p2 { background-color: #e9f1f8; outline: 3px solid var(--p2); --glow: rgba(47, 111, 168, 0.28); }
.player.active::after { content: ''; position: absolute; inset: -3px; border-radius: inherit; box-shadow: 0 0 0 6px var(--glow); pointer-events: none; opacity: 0; animation: turnGlow 1.8s ease-in-out infinite; }
@keyframes turnGlow { 50% { opacity: 1; } }
.scoreboard:has(.player.active) .player:not(.active) { opacity: 0.55; filter: saturate(0.55); }
.player { transition: outline-color 0.25s, transform 0.25s, opacity 0.25s, filter 0.25s; }
.turn-tag { font-family: var(--font-pop); font-size: 13px; letter-spacing: 0.08em; padding: 3px 12px; box-shadow: 0 2px 6px rgba(70, 48, 24, 0.25); }
/* 考え中：役割の行が差し替わり、紋章がゆっくりうなずく */
.player.thinking .prole { color: var(--ink-2); font-family: var(--font-hand); }
.player.thinking .emblem { animation: ponder 1.4s ease-in-out infinite; }
@keyframes ponder { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-8deg); } 60% { transform: rotate(6deg); } }
.prole .dots { display: inline-block; width: 2.2em; text-align: left; }

/* 番号の札が煙突や塔の陰に入ったとき */
.count-label { transition: opacity 0.15s; }
.count-label.behind { opacity: 0; }

/* 終わったあとの集計：得点欄の数字が増えるたびに弾む */
.pscore b.bump { display: inline-block; animation: scoreBump 0.22s ease-out; }
@keyframes scoreBump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ---------- 振り返り ----------
   下のボタンの列（真上から・表示・再生バー・結果に戻る・トップへ・しまう）の上に、
   手数の帯と、再生のボタン（右の小札で速さを選ぶ）を載せた紙の札を出す */
.replay-only { display: none !important; }
#hud.replaying .replay-only { display: flex !important; }
#hud.replaying #btnPass, #hud.replaying #btnConfirm, #hud.replaying #btnScore,
#hud.replaying #btnResign, #hud.replaying .dock .sep, #hud.replaying #camHint { display: none !important; }
/* 終局後（景色をみる）だけ、下のボタンの列に「振り返る」を出す */
.after-only { display: none !important; }
#hud.finished:not(.replaying) .after-only { display: flex !important; }
/* 「もう一度遊ぶ」：終局後（景色をみる・振り返り）の次の一手なので、左端に黄色で目立たせる。観戦の対局中には出さない */
.again-dock { display: none !important; }
#hud.finished .again-dock { display: flex !important; }
/* 対局の記録の振り返りでは、次の対局を始めるボタンは出さない（ホームに戻って選び直す） */
#hud.history .again-dock { display: none !important; }
.dock button.again-dock { background: var(--sun); color: var(--ink); word-break: keep-all; } /* スマホで2行に折り返すときは「もう一度／遊ぶ」で切る（切れ目は辞書に入れてある） */
@media (hover: hover) { .dock button.again-dock:where(:not(.hover-off)):hover { background: #ffd35e; color: var(--ink); } }
/* CPU と対戦の「もう一度遊ぶ」の吹き出し：結果の画面と同じ色の3つのボタンを縦に並べる */
.again-pop button { padding: 10px 14px; font-size: 14px; white-space: nowrap; color: #fff; border-width: 1.5px; }
.again-pop button.p1 { background: var(--p1); border-color: var(--p1-d); box-shadow: 0 3px 0 var(--p1-d); }
.again-pop button.p2 { background: var(--p2); border-color: var(--p2-d); box-shadow: 0 3px 0 var(--p2-d); }
.again-pop button.again-random { background: var(--sun); border-color: var(--sun-d); box-shadow: 0 3px 0 var(--sun-d); color: var(--ink); }
.again-pop button.p1:hover { background: #ea6a54; }
.again-pop button.p2:hover { background: #4a8ee6; }
.again-pop button.again-random:hover { background: #ffd35e; }
html.go-look .again-pop button.p1:hover { background: #4a443e; }
html.go-look .again-pop button.p2:hover { background: #9c9686; }
/* 対局が終わってから（結果・振り返り・景色をみる）だけ出す：対局中に押し間違えて抜けないよう「ホームに戻る」に使う */
.done-only { display: none !important; }
#hud.finished .done-only { display: flex !important; }
/* CPU同士の観戦は打つ人がいないので、対局中でも「ホームに戻る」を出し、押せないパス・投了とその仕切りを下げる */
#hud.watching .done-only { display: flex !important; }
#hud.watching #btnPass, #hud.watching #btnResign, #hud.watching .dock .sep { display: none !important; }
/* 観戦の一時停止・再生：終局したら止めるものがないので下げる */
.watch-only { display: none !important; }
#hud.watching:not(.finished) .watch-only { display: flex !important; }
/* 終局後は、もう押せない・意味のないボタン（パス・投了とその仕切り・2回クリック・得点）を下げる */
#hud.finished #btnPass, #hud.finished #btnResign, #hud.finished .dock .sep, #hud.finished #btnConfirm, #hud.finished #btnScore { display: none !important; }
#hud.replaying .turn-info::before { content: attr(data-badge); /* 「振り返り」の札。文言は言語ごとに main.js が入れる */ font-family: var(--font-pop); font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #fff1cf; color: #8a5a00; box-shadow: var(--shadow); }
#hud.replaying .turn-info { margin-top: 8px; }
.replay-bar {
  position: absolute;
  bottom: calc(var(--dock-top, 84px) + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 16px));
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px 6px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background-color: var(--paper);
  background-image: var(--grain);
  box-shadow: var(--shadow);
}
#hud.replaying #message { bottom: calc(var(--bar-top, 190px) + 10px); }
/* 再生バーは、下のメニューの「再生バー」で隠せる（隠しても再生は続き、説明文はメニューのすぐ上に下りる） */
#hud.bar-off #replayBar { display: none !important; }
/* 手数の帯：つまみをドラッグ・帯をクリックで好きな手へ。帯の上に見どころの印 */
.rp-seek { position: relative; display: grid; grid-template-areas: "marks" "seek"; align-items: center; }
.rp-marks { grid-area: marks; position: relative; height: 18px; margin: 0 9px; }
/* 見どころの記号：影絵のように、工房の色の塗りだけで描く */
.rp-marks button {
  position: absolute;
  bottom: 0;
  left: var(--p);
  width: 14px;
  height: 14px;
  margin-left: -7px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  transform-origin: 50% 100%;
}
.rp-marks button.big { width: 18px; height: 18px; margin-left: -9px; }
.rp-marks svg { display: block; width: 100%; height: 100%; fill: currentColor; stroke: none; filter: drop-shadow(0 1px 0 rgba(255, 250, 235, 0.9)); }
.rp-marks .c1 { color: var(--p1-d); }
.rp-marks .c2 { color: var(--p2-d); }
/* ヒントを使った局面の電球：同じ手に爆発・煙突の印もあるときは、右へずらして並べる */
.rp-marks button.hint.beside { margin-left: 3px; }
.rp-marks button:hover { background: none; transform: scale(1.3); z-index: 1; }
.rp-marks button:active { transform: scale(1.1); box-shadow: none; }
.rp-range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; }
.rp-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--ink-2) var(--fill, 0%), var(--paper-3) var(--fill, 0%)); }
.rp-range::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--ink-2) var(--fill, 0%), var(--paper-3) var(--fill, 0%)); }
.rp-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-2); box-shadow: 0 1px 3px rgba(70, 48, 24, 0.35); }
.rp-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-2); }
#rpSeek { grid-area: seek; }
.rp-row { display: flex; justify-content: center; }
.rp-transport { display: flex; align-items: center; gap: 2px; }
.rp-transport button { display: grid; place-items: center; width: 42px; height: 40px; padding: 0; border: 0; border-radius: 12px; background: transparent; box-shadow: none; color: var(--ink-2); }
.rp-transport button:hover { background: var(--paper-2); color: var(--ink); }
.rp-transport button:active { transform: scale(0.94); box-shadow: none; }
/* 再生のボタンと速さの小札は、1枚の黄色いつまみを縦の線で2つに分けた形 */
.rp-playgroup { display: flex; margin: 0 6px; border-radius: 12px; }
.rp-playgroup:active { transform: translateY(1px); }
.rp-transport .rp-playgroup button { width: auto; display: flex; gap: 6px; }
/* 止めているとき（▶）は濃い黄色で目立たせ、再生中（‖）は淡くする。速さの小札も同じ色に */
.rp-playgroup:not(:has(.playing)) { box-shadow: 0 3px 0 var(--sun-d); }
.rp-transport .rp-playgroup:not(:has(.playing)) button { background-color: #f4b940; color: #3b2c1f; }
.rp-playgroup:has(.playing) { box-shadow: 0 3px 0 var(--lip); }
.rp-transport .rp-playgroup:has(.playing) button { background-color: #fbf1d6; color: var(--ink-2); }
.rp-playgroup:has(.playing) .rp-rate { border-left-color: rgba(140, 95, 20, 0.2); }
/* マウスを乗せたら2つ一緒に明るくする（片方だけ色が変わらないように）。指で押した後に色が残らないよう、マウスのときだけ */
@media (hover: hover) {
  .rp-transport .rp-playgroup:not(:has(.playing)):hover button { background-color: #f6c55c; }
  .rp-transport .rp-playgroup:has(.playing):hover button { background-color: #f8e8bf; }
}
.rp-transport .rp-playgroup button:active { transform: none; }
.rp-transport button.rp-play { width: 50px; justify-content: center; padding: 0; border-radius: 12px 0 0 12px; }
.rp-play svg { fill: currentColor; }
.rp-transport button.rp-rate { gap: 1px; min-width: 52px; padding: 0 8px 0 10px; border-radius: 0 12px 12px 0; border-left: 1.5px solid rgba(140, 95, 20, 0.35); font-family: var(--font-pop); font-size: 14px; font-variant-numeric: tabular-nums; }
.rp-rate svg { width: 14px; height: 14px; stroke-width: 2.6; opacity: 0.7; transition: transform 0.15s; }
.rp-rate[aria-expanded="true"] svg { transform: rotate(180deg); }
.rp-play .i-pause, .rp-play.playing .i-play { display: none; }
.rp-play.playing .i-pause { display: block; }
/* 速さの吹き出し：×0.5〜×8。目盛り（×1・×2・×4・×8）の近くで離すと、そこへ吸い付く */
.rp-speed-pop { width: 260px; gap: 2px; padding: 10px 14px 8px; }
.rp-speed-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; font-weight: 700; color: var(--muted); }
#rpSpeedVal { font-family: var(--font-pop); font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.rp-speed-track { position: relative; padding-bottom: 14px; }
.rp-ticks { position: absolute; left: 9px; right: 9px; bottom: 0; height: 12px; pointer-events: none; }
.rp-ticks i { position: absolute; left: var(--p); transform: translateX(-50%); font-style: normal; font-size: 10px; line-height: 12px; color: var(--muted); }

@media (max-width: 640px) {
  .replay-bar { padding: 6px 10px 4px; }
  .rp-hi { display: none !important; } /* 見どころへは、帯の印をタップする */
  .rp-transport button { width: 40px; height: 38px; }
}

/* ---------- 言語ごとの調整（英語・簡体字中国語） ---------- */
.pstats i { font-style: normal; } /* 「工場」「煙突」などの見出し */
/* 言語の切り替え：カードのいちばん上に、地球の印と4つの言語を1列に並べる。今の言語の札だけ白く浮かせる */
.lang-pick { display: flex; align-items: center; gap: 3px; margin: -12px -10px 12px; padding: 4px 4px 4px 8px; border: 1.5px solid var(--sun-d); border-radius: 999px; background-color: #fff6dc; }
.lang-pick .globe { flex: none; width: 18px; height: 18px; margin-right: 2px; fill: none; stroke: var(--sun-d); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html.lang-wait body { visibility: hidden; }
html.lang-wait #bootShot { visibility: visible; } /* 文字を隠しているあいだも、街の写真は見せておく（白い画面で待たせない） */
.lang-pick button { flex: 1; min-width: 0; padding: 6px 2px; font-size: 13px; white-space: nowrap; border: 0; border-radius: 999px; box-shadow: none; background: transparent; color: var(--ink-2); }
.lang-pick button:hover { background: rgba(255, 255, 255, 0.7); }
.lang-pick button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(70, 48, 24, 0.18), 0 2px 0 var(--lip); }
/* 言語の名前は、表示中の言語にかかわらず、それぞれの言語の書体で */
.lang-pick [lang="zh-CN"] { font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; }
.lang-pick [lang="zh-TW"] { font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; }
.lang-pick [lang="ko"] { font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
/* 簡体字：日本の書体のままだと漢字が日本の字形になるので、中国語の書体を先に使う
   汇文明朝体は太字の版がなく、ブラウザが重ね書きで太くするので、パソコンの画面では小さな字が潰れてにじむ。
   明朝は大きく出す題字・テロップ・結果の見出し・浮かぶ文字（--font-title）だけにし、ボタンや見出しなどは太字の版がある丸ゴシックにする */
:root:lang(zh) {
  --font: "Chiron GoRound TC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-pop: var(--font);
  --font-title: "Huiwen-mincho", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-hand: "LXGW WenKai", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}
/* 繁体字：台湾の字形の書体を使う（:lang(zh) より後に置いて上書きする） */
:root:lang(zh-TW) {
  --font: "Chiron GoRound TC", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-pop: var(--font);
  --font-title: "Huiwen-mincho", "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --font-hand: "LXGW WenKai TC", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}
:root:lang(zh) h1, :root:lang(zh) .banner b, :root:lang(zh) .result-title, :root:lang(zh) .pop, :root:lang(zh) .count-label { font-family: var(--font-title); }
/* 韓国語：日本語の書体にはハングルがないので、韓国語の書体を使う */
:root:lang(ko) {
  --font: "Sunflower", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-pop: "Song Myung", "Noto Serif KR", "AppleMyungjo", "Batang", serif;
  --font-hand: "Poor Story", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
/* 英語：題字の上の斜体の副題（Go on the Cliff）を詰める。文字の詰め（字間）は日本語向けなので戻す */
:root:lang(en) .subtitle { letter-spacing: 0.12em; }
:root:lang(en) .tagline, :root:lang(en) .rule-note { letter-spacing: 0; }
/* 英語のスマホ：工房の名前（Red Workshop）が札に収まるよう、少し小さく詰める */
/* 小さいスマホ：役割の行（CPU Lv.10 など）が切れないよう、字を少し小さくし、札の余白と紋章を詰めて幅を空ける。点数の大きさは保つ */
@media (max-width: 360px) {
  .prole { font-size: 11px; }
  .player { padding: 8px 6px 14px; column-gap: 4px; grid-template-columns: 22px minmax(0, 1fr) auto; }
  .player.p2 { grid-template-columns: auto minmax(0, 1fr) 22px; }
  .emblem { width: 22px; height: 22px; font-size: 15px; border-radius: 7px; }
}
@media (max-width: 640px) { :root:lang(en) .pname { font-size: 11.5px; letter-spacing: -0.02em; } }
/* 英語は名前が長いので、パソコンでは札の列を広げ、点数が3桁でも pts を添えられるようにする */
@media (min-width: 641px) { :root:lang(en) .scoreboard { width: min(740px, calc(100vw - 24px)); } }
/* 英語の題字「Cliff Go」は1行に収める：字間を詰め、カードの幅に合わせて大きさを変える */
:root:lang(en) h1 { white-space: nowrap; letter-spacing: 0.01em; font-size: clamp(24px, 7.6vw, 44px); }
/* 英語の説明文：日本語の手書き風の書体（Klee One）は欧文が細く読みにくい。
   世界観を保つため、やわらかい絵本調のセリフ体（Fraunces、角を丸めた SOFT）で、少し濃く・大きくする */
:root:lang(en) .tagline, :root:lang(en) .note, :root:lang(en) .editor-help { font-family: "Fraunces", var(--font-pop); font-variation-settings: "SOFT" 100; }
:root:lang(en) .tagline { font-size: 15px; line-height: 1.5; font-weight: 450; color: var(--ink); }
/* 英語のテロップ・お知らせ行・浮かぶ文字：英語は日本語より横に長くなるので、幅の狭いセリフ体（Roboto Serif の字幅を 62〜78% に）で詰める */
:root:lang(en) .banner b, :root:lang(en) .pop { font-family: "Roboto Serif", var(--font-pop); font-stretch: 62%; letter-spacing: 0; }
:root:lang(en) .banner small, :root:lang(en) #message { font-family: "Roboto Serif", var(--font); font-stretch: 78%; font-weight: 600; letter-spacing: 0; }
/* 中国語（簡体字・繁体字）：日本語向けに広げた字間のままだと横に間延びするので、題字・テロップ・ボタン・見出しは字間を広げない */
:root:lang(zh) h1, :root:lang(zh) .banner b, :root:lang(zh) button.big, :root:lang(zh) #dialogYes, :root:lang(zh) #btnAgain, :root:lang(zh) #btnRuleNext,
:root:lang(zh) h2, :root:lang(zh) h3, :root:lang(zh) .result-title, :root:lang(zh) .turn-tag, :root:lang(zh) button.choice b,
:root:lang(zh) .row label, :root:lang(zh) .banner small, :root:lang(zh) .watch-note { letter-spacing: 0; }
/* 英語の書体を、日本語の3書体の役割・雰囲気に合わせる（日本語の書体の欧文のままだと、絵本の世界観から浮く）
   題字・見出し・大きなボタン（Kaisei Decol の装飾的な明朝）→ 角を丸めた絵本調のセリフ体 Fraunces（SOFT）
   本文・設定の項目（Zen Maru Gothic の丸ゴシック）→ 丸ゴシックの Nunito
   ひとこと（Klee One の手書き風）→ 説明文と同じ Fraunces */
:root:lang(en) {
  --font: "Nunito", "Zen Maru Gothic", system-ui, sans-serif;
  --font-pop: "Fraunces", "Kaisei Decol", serif;
  --font-hand: "Fraunces", "Klee One", serif;
}
:root:lang(en) body { font-variation-settings: "SOFT" 100; }
:root:lang(en) button.big, :root:lang(en) #dialogYes, :root:lang(en) #btnAgain, :root:lang(en) #btnRuleNext, :root:lang(en) h2, :root:lang(en) h3 { letter-spacing: 0.01em; }
/* 英語の文は日本語より行が増えるので、タイトルの画面が日本語と同じくらいの高さに収まるよう、注記の行間を詰める */
:root:lang(en) .rule-note { line-height: 1.5; }
:root:lang(en) .rule-note span { text-wrap: balance; } /* 長い文が折り返すとき、最後の1語（wins. など）だけが次の行に落ちないよう、行の長さを均等にする */
/* 工房の選択：「Blue (Second)」が2行に割れて、隣のボタンと高さがそろわなくなるのを防ぐ */
:root:lang(en) #rowSide .seg button { white-space: nowrap; letter-spacing: -0.01em; }
@media (max-width: 400px) { :root:lang(en) #rowSide .seg button { font-size: 13px; } }

/* ---------- スマホのホーム画面：スクロールなしで、ルールの説明とクレジットまで1画面に収める ---------- */
@media (max-width: 640px) {
  #menu .menu-card { padding: 14px 18px 10px; }
  #menu .title-block { margin-bottom: 8px; }
  #menu .tagline, :root:lang(en) #menu .tagline { margin-top: 4px; font-size: 13px; line-height: 1.55; }
  #menu .tagline .gap { height: 0.25em; }
  #menu button.big { padding: 10px 20px; font-size: 16px; }
  #menu button.big.ghost { padding: 6px 10px; font-size: 15px; }
  #menu .rule-box { margin-bottom: 10px; }
  #menu .rule-note { font-size: 13px; line-height: 1.5; }
  #menu .credit { margin-top: 6px; }
}
/* 題名の下の紹介の2行が入るので、よくあるスマホの高さまで詰めた組み方にする */
@media (max-width: 640px) and (max-height: 860px) {
  #menu .title-block { margin-bottom: 4px; }
  #menu .tagline, :root:lang(en) #menu .tagline { font-size: 12px; line-height: 1.45; }
  #menu button.big { padding: 8px 18px; font-size: 15px; }
  #menu button.big.ghost { padding: 4px 10px; font-size: 14px; }
  #menu .rule-note { font-size: 12.5px; line-height: 1.4; }
  #menu #demoText .rule-note, #menu #demoTextGo .rule-note:last-of-type { padding-bottom: 2px; }
  #menu .menu-buttons { gap: 8px; }
  #menu .rule-box { margin-bottom: 6px; }
  #menu button.demo-play { gap: 5px; padding: 2px 12px 2px 3px; margin: 1px auto 6px; font-size: 13px; }
  #menu button.demo-play svg { width: 18px; height: 18px; padding: 2px; }
}
@media (max-width: 640px) and (max-height: 700px) {
  .row { margin-bottom: 6px; }
}

/* 本物の碁盤の表示：紅と蒼の代わりに、黒と白。白は札の上で読めるよう、字は濃い灰色にして、丸い印と枠で白を表す */
html.go-look {
  --p1: #2e2a26;
  --p1-d: #14110e;
  --p1-t: #ece7dc;
  --p2: #8a8474;
  --p2-d: #6d6759;
  --p2-t: #f7f3e8;
}
html.go-look .emblem { border-radius: 50%; }
html.go-look .p2 .emblem { background: #f6f2e6; color: #2e2a26; box-shadow: inset 0 -3px 0 #cfc8b4, 0 0 0 1px #b5ad98; }
html.go-look .result-panel .result-main button.again-side.p1:hover { background: #4a443e; }
html.go-look .result-panel .result-main button.again-side.p2:hover { background: #9c9686; }
/* 街の絵を使うトップ画面の説明とルールは、紅と蒼のまま */
html.go-look .demo-view, html.go-look .rule-note, html.go-look .rules-text {
  --p1: #e2513a;
  --p1-d: #b33822;
  --p1-t: #fdebe7;
  --p2: #2e7be0;
  --p2-d: #1d5bb0;
  --p2-t: #e6f0fc;
}

/* ---------- 横長で背の低い画面（iPad の横向き・小さめの PC の窓）：トップ画面のカードを左右2列に広げて、1画面に収める ----------
   1列のままだとカードの背が約1000px になり、下の遊ぶボタンや問い合わせ先が画面の外に出るため。
   言語の切り替えと問い合わせ先は横いっぱい、左に題名とルールの説明、右に遊ぶボタン（対局の準備を開いたときは、その設定）を置く。字やボタンの大きさは変えない */
@media (min-width: 960px) and (max-height: 980px) {
  #menu .menu-card { max-width: 900px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 30px; align-items: start; }
  #menu .menu-card > .lang-pick { grid-column: 1 / -1; grid-row: 1; justify-self: center; width: min(100%, 520px); margin: -12px 0 14px; }
  #menu .menu-card > .title-block { grid-column: 1; grid-row: 2; }
  #menu .menu-card > .rule-box { grid-column: 1; grid-row: 3; margin-bottom: 0; }
  #menu .menu-card > .menu-buttons, #menu .menu-card > .setup { grid-column: 2; grid-row: 2 / 4; align-self: center; }
  #menu .menu-card > .credit, #menu .menu-card > .about { grid-column: 1 / -1; }
  /* 対局の準備を開いたとき：2列にせず、大きな画面と同じく1列（題名が上・幅は広げない）に戻す */
  #menu:has(#setup:not(.hidden)) .menu-card { max-width: 440px; display: block; }
  #menu:has(#setup:not(.hidden)) .menu-card > .lang-pick { justify-self: auto; width: auto; margin: -12px -10px 12px; }
}

/* ---------- 対局の記録 ---------- */
/* 一覧の小窓。並びが長いときは一覧だけをスクロールする */
.history-panel { display: flex; flex-direction: column; gap: 12px; max-height: calc(100dvh - 32px); max-width: 480px; box-sizing: border-box; }
.history-panel .rules-head .close { margin-left: auto; }
.history-panel .rules-head h2 { font-size: 19px; }
.dialog-panel p.history-lead { font-size: 13px; line-height: 1.6; color: var(--muted); }
.history-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.history-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: baseline;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: none;
  color: var(--ink);
  font-size: 15px;
  font-weight: 400;
}
.history-row:hover:not(:disabled) { background: var(--paper-2); }
.history-row:disabled { opacity: 0.6; cursor: default; }
.history-row .h-when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.history-row .h-res { grid-row: span 2; max-width: 11em; align-self: center; text-align: right; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.history-row .h-res b { font-size: 16px; font-weight: 900; }
.history-row .h-res small { font-size: 12px; color: var(--muted); }
.history-row .h-res.win b { color: #c98a00; }
.history-row .h-res.lose b { color: var(--muted); }
.history-row .h-res.c1 b { color: var(--p1); }
.history-row .h-res.c2 b { color: var(--p2); }
.history-row .h-who { font-weight: 700; }
.history-row .h-land { grid-column: 1; font-size: 13px; color: var(--ink-2); }
.history-row .h-old { grid-column: 1 / -1; font-size: 12px; color: var(--danger); }
.history-panel .dialog-buttons { margin-top: 0; }
/* 結果の画面：記録の振り返りでは、次の対局の選び方ともう一度のボタンを隠し、記録の一覧へを出す */
.history-only { display: none !important; }
#result.history .history-only { display: flex !important; }
#result.history #btnAgain, #result.history .again-side, #result.history .again-random,
#result.history #resultLevelRow, #result.history #resultSizeRow, #result.history #resultHintRow, #result.history #resultRating { display: none !important; }
#result.history .result-main button { align-items: center; justify-content: center; gap: 6px; }

/* ---------- 通信で対戦 ---------- */
.online-panel { display: flex; flex-direction: column; gap: 12px; }
.online-panel h3 { margin: 0; }
.online-code { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px; border-radius: 14px; background: var(--paper-2, #f4efe4); }
.online-code small { font-size: 13px; color: var(--muted); font-weight: 700; }
.online-code b { font-size: 44px; font-weight: 900; letter-spacing: 0.18em; color: var(--ink); font-variant-numeric: tabular-nums; padding-left: 0.18em; }
.online-url { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink-2); }
.online-join input { width: 100%; box-sizing: border-box; font: inherit; font-size: 36px; font-weight: 900; text-align: center; letter-spacing: 0.3em; padding: 8px 0 8px 0.3em; border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); font-variant-numeric: tabular-nums; }
.online-join input:focus { outline: none; border-color: var(--sun-d); }
.dialog-panel p.online-status { min-height: 1.4em; font-size: 14px; font-weight: 700; text-align: center; color: var(--muted); }
.dialog-panel p.online-status.bad { color: var(--danger); }
.online-panel .dialog-buttons { margin-top: 0; }
.net-notice { position: absolute; bottom: calc(var(--dock-top, 84px) + 60px); left: 50%; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); box-sizing: border-box; padding: 8px 14px; border-radius: 12px; background: rgba(29, 36, 48, 0.86); color: #fff; font-size: 14px; font-weight: 700; line-height: 1.5; }
.net-notice button { flex: none; }
/* ボット戦をしながら人を待っているあいだのお知らせ：対局の邪魔にならないよう、左下に小さく控えめに出す */
/* 「対戦相手を探す」を押してから始まるまでの画面 */
#seekScreen { z-index: 22; background: rgba(29, 36, 48, 0.42); backdrop-filter: blur(4px); }
body.dev-phone #seekScreen { background: rgba(29, 36, 48, 0.58); backdrop-filter: none; }
.seek-panel { max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.seek-panel h2 { margin: 4px 0 0; font-size: 19px; }
.seek-ring { width: 46px; height: 46px; box-sizing: border-box; border-radius: 50%; border: 5px solid var(--paper-2); border-top-color: var(--sun); animation: seek-spin 0.9s linear infinite; }
@keyframes seek-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .seek-ring { animation-duration: 2.4s; } }
/* 通信で対戦の持ち時間：札のすぐ下（札の中の文字や、パスの札・オートの札と重ならない高さ）の真ん中に置く大きな時計。手番の札（赤の番・青の番）の代わりも兼ねる。
   止まっている側は白地で控えめに、減っている側は工房の色で少し大きく浮かせる。
   残り30秒からは数字を明るい黄色に、10秒を切ると（赤の工房の色と見分けられるよう）濃い地に赤い数字で鼓動させ、小数1桁まで出す */
#hud.has-clock .turn-tag { display: none; }
.pclock { position: absolute; left: 50%; top: calc(100% + 14px); z-index: 2; display: inline-flex; align-items: center; gap: 6px; min-width: 104px; box-sizing: border-box; justify-content: center; padding: 5px 14px; border-radius: 14px; overflow: hidden; background: var(--paper); border: 1.5px solid var(--line); color: var(--ink-2); box-shadow: 0 3px 10px rgba(70, 48, 24, 0.16); transform: translateX(-50%); transition: transform 0.25s cubic-bezier(.3, 1.4, .5, 1), background 0.25s, color 0.25s, box-shadow 0.25s, border-color 0.25s; }
.pclock b { font-size: 24px; font-weight: 800; line-height: 1; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.pclock-ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; opacity: 0.6; }
.pclock.run { color: #fff; border-color: transparent; transform: translateX(-50%) scale(1.08); }
.pclock.run .pclock-ico { opacity: 0.9; }
.p1 .pclock.run { background: var(--p1); box-shadow: 0 4px 14px color-mix(in srgb, var(--p1) 45%, transparent); }
.p2 .pclock.run { background: var(--p2); box-shadow: 0 4px 14px color-mix(in srgb, var(--p2) 45%, transparent); }
.pclock.run.warn b { color: #ffe27a; }
.pclock.run.low { background: #23262e; box-shadow: 0 0 0 2px #ff5a4a, 0 4px 16px rgba(255, 90, 74, 0.5); animation: clock-beat 1s ease-in-out infinite; }
.pclock.run.low b, .pclock.run.low .pclock-ico { color: #ff6a5a; }
.pclock.out { background: #23262e; border-color: transparent; color: #ff6a5a; }
@keyframes clock-beat { 0%, 100% { transform: translateX(-50%) scale(1.08); } 15% { transform: translateX(-50%) scale(1.16); } }
@media (prefers-reduced-motion: reduce) { .pclock.run.low { animation: none; } }
@media (max-width: 640px) {
  .pclock { min-width: 88px; top: calc(100% + 13px); padding: 4px 10px; gap: 4px; }
  .pclock b { font-size: 20px; }
  .pclock-ico { width: 13px; height: 13px; }
}
/* 結果の画面：通信で対戦の相手の様子の帯。状態が変わるとその場で書き換わる */
.result-peer { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--paper-2); color: var(--ink-2); font-size: 14px; font-weight: 700; line-height: 1.5; transition: background 0.3s, box-shadow 0.3s; }
.result-peer .dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--dot, var(--muted)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, var(--muted)) 22%, transparent); }
.result-peer .dots { display: none; margin-left: auto; gap: 4px; }
.result-peer .dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.25; animation: peer-dots 1.2s infinite; }
.result-peer .dots i:nth-child(2) { animation-delay: 0.2s; }
.result-peer .dots i:nth-child(3) { animation-delay: 0.4s; }
.result-peer[data-state="waiting"] .dots { display: inline-flex; }
.result-peer[data-state="asked"] { background: #fff3cf; color: #7a5200; box-shadow: 0 0 0 2px var(--sun) inset; animation: peer-glow 1.8s ease-in-out infinite; }
.result-peer[data-state="away"], .result-peer[data-state="left"], .result-peer[data-state="gone"] { color: var(--muted); }
.result-peer[data-state="away"] .dot, .result-peer[data-state="left"] .dot, .result-peer[data-state="gone"] .dot { filter: grayscale(1); opacity: 0.6; }
@keyframes peer-dots { 30% { opacity: 1; } }
@keyframes peer-glow { 50% { box-shadow: 0 0 0 2px var(--sun) inset, 0 0 0 5px color-mix(in srgb, var(--sun) 25%, transparent); } }
/* 相手がもう一度を待っているときの「もう一度を受ける」：そっと光らせて目を引く */
#btnAgain.glow { animation: again-glow 1.8s ease-in-out infinite; }
@keyframes again-glow { 50% { box-shadow: 0 4px 0 var(--sun-d, #c99a1a), 0 0 0 6px color-mix(in srgb, var(--sun) 30%, transparent); } }
@media (prefers-reduced-motion: reduce) { .result-peer .dots i, .result-peer[data-state="asked"], #btnAgain.glow { animation: none; } .result-peer .dots i { opacity: 0.7; } }
/* 盤の下のお知らせ：終わったあと、相手がもう一度を待っているときは黄色の縁で知らせる */
.net-notice[data-state="asked"] { box-shadow: 0 0 0 2px var(--sun); }
.net-notice #btnNetAgain { background: var(--sun); color: var(--ink); }
/* 通信で対戦の準備の画面：上に「パスコードで入る」の欄、その下に「部屋を作る」の選び方 */
.online-entry { margin-bottom: 4px; }
.online-join-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 16px; background: #fff7e3; border: 1.5px solid color-mix(in srgb, var(--sun) 60%, var(--line)); }
.online-join-card label { font-size: 14px; font-weight: 800; color: var(--ink); }
.online-join-line { display: flex; gap: 10px; align-items: stretch; }
.online-join-line input { flex: 1; min-width: 0; box-sizing: border-box; font: inherit; font-size: 28px; font-weight: 900; letter-spacing: 0.35em; text-align: center; padding: 6px 0 6px 0.35em; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font-variant-numeric: tabular-nums; }
.online-join-line input::placeholder { color: var(--line); }
.online-join-line input:focus { outline: none; border-color: var(--sun-d, #c99a1a); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sun) 35%, transparent); }
.online-join-line button { flex: none; min-width: 84px; background-color: var(--sun); font-family: var(--font-pop); letter-spacing: 0.06em; }
.online-join-line button:disabled { background-color: var(--paper-2); color: var(--muted); box-shadow: none; cursor: default; }
.online-join-msg { margin: 0; font-size: 12px; color: var(--muted); }
.online-join-msg.bad { color: var(--danger); font-weight: 700; }
.online-or { display: flex; align-items: center; gap: 10px; margin: 18px 0 6px; font-size: 13px; font-weight: 800; color: var(--ink-2); }
.online-or::before, .online-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
/* 再戦の「取り消す」は控えめに（結果の画面の大きなボタンの黄色を外す） */
#btnAgain.ghost { background-color: var(--paper-2); font-family: inherit; letter-spacing: 0; box-shadow: none; color: var(--ink-2); }

/* ---------- レーティング戦 ---------- */
#btnRated.someone .watch-note { color: #b5361f; font-weight: 800; }
#btnRated.someone .watch-note::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #e2513a; vertical-align: 1px; animation: peer-dots 1.4s infinite; }
.rated-panel { display: flex; flex-direction: column; gap: 12px; max-width: 460px; max-height: calc(100dvh - 32px); box-sizing: border-box; overflow-y: auto; }
.rated-panel .rules-head .close { margin-left: auto; }
.rated-panel .rules-head h2 { font-size: 19px; }
.rated-view { display: flex; flex-direction: column; gap: 12px; }
.rated-view.hidden { display: none; }
.rated-view input { width: 100%; box-sizing: border-box; font: inherit; font-size: 17px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); }
.rated-view input:focus { outline: none; border-color: var(--sun-d, #c99a1a); }
.dialog-panel p.rated-msg { min-height: 1.2em; margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; }
.dialog-panel p.rated-msg.bad { color: var(--danger); }
.dialog-panel p.rated-note { margin: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.link-btn { align-self: center; background: none !important; border: 0; box-shadow: none; padding: 4px; font-size: 13px; font-weight: 700; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.rated-card { display: grid; gap: 6px; padding: 16px; border-radius: 16px; background: linear-gradient(160deg, #fff7e3, var(--paper-2)); border: 1.5px solid color-mix(in srgb, var(--sun) 50%, var(--line)); text-align: center; }
.rated-who { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.rated-who b { font-size: 17px; }
.rated-who .link-btn { font-size: 12px; }
.rated-score { display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.rated-score b { font-family: var(--font-pop); font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
.rated-title { font-size: 14px; font-weight: 800; color: #a0742a; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--sun) 30%, transparent); }
.rated-stats { font-size: 13px; color: var(--ink-2); }
.rated-actions { display: flex; flex-direction: column; gap: 8px; }
.rated-actions button.big { width: 100%; }
.rated-sub { display: flex; gap: 8px; justify-content: center; }
.rated-ranking { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: min(55dvh, 460px); overflow-y: auto; }
.rated-ranking li { display: grid; grid-template-columns: 2.4em minmax(0, 1fr) auto 3.6em; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 10px; background: var(--paper-2); font-size: 14px; }
.rated-ranking li.bot { background: transparent; border: 1px dashed var(--line); color: var(--ink-2); }
.rated-ranking li.me { background: #fff3cf; box-shadow: 0 0 0 2px var(--sun) inset; }
.rated-ranking .rk { font-weight: 900; text-align: right; color: var(--muted); }
.rated-ranking li:nth-child(-n+3) .rk { color: #a0742a; }
.rated-ranking .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.rated-ranking .bot-mark { font-style: normal; font-size: 11px; color: var(--muted); margin-left: 4px; }
.rated-ranking .tt { font-size: 11px; color: var(--muted); white-space: nowrap; }
.rated-ranking .rt { text-align: right; font-variant-numeric: tabular-nums; }
.dialog-panel p.rated-me { margin: 0; font-size: 13px; font-weight: 700; text-align: center; color: var(--ink-2); }
.rated-code-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--paper-2); }
.rated-code-box b { font-size: 20px; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.rated-code-in { display: flex; gap: 8px; }
.rated-code-in input { flex: 1; min-width: 0; letter-spacing: 0.06em; text-transform: uppercase; }
/* 結果の画面：レーティングの増減 */
.result-rated { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 8px; margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--paper-2); font-variant-numeric: tabular-nums; }
.result-rated.hidden { display: none; }
.result-rated .rr-label { font-size: 12px; font-weight: 800; color: var(--muted); margin-right: 4px; }
.result-rated b { font-family: var(--font-pop); font-size: 26px; line-height: 1; }
.result-rated .rr-arrow { color: var(--muted); }
.result-rated .rr-delta { font-size: 14px; font-weight: 800; color: var(--muted); }
.result-rated.up .rr-delta, .result-rated.up #resultRatedTo { color: #2f9e5b; }
.result-rated.down .rr-delta, .result-rated.down #resultRatedTo { color: var(--danger); }
/* 誘い */
.invite-panel { display: flex; flex-direction: column; gap: 10px; max-width: 400px; }
.invite-panel h3 { margin: 0; }
.invite-who { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; border-radius: 12px; background: #fff3cf; box-shadow: 0 0 0 2px var(--sun) inset; }
.invite-who .dot { width: 10px; height: 10px; border-radius: 50%; background: #2f9e5b; align-self: center; animation: peer-dots 1.2s infinite; }
.invite-who b { font-size: 17px; }
.invite-who span { font-family: var(--font-pop); font-size: 18px; font-variant-numeric: tabular-nums; color: var(--ink-2); margin-left: auto; }
.invite-mute { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); }
.invite-mute.hidden { display: none; }
.invite-time { height: 4px; border-radius: 2px; background: var(--paper-2); overflow: hidden; }
.invite-time i { display: block; height: 100%; width: 100%; background: var(--sun); }
.invite-panel .dialog-buttons { margin-top: 0; }
#btnInviteYes { background-color: var(--sun); font-family: var(--font-pop); letter-spacing: 0.06em; }
/* トップの「レーティング戦」の NEW の印 */
.new-badge { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; background: #e2513a; color: #fff; font-family: inherit; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; vertical-align: 3px; line-height: 1.5; }
/* レーティング戦の札：レートの数字を太く */
.prole .rate-num { font-size: 14px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.rated-prov { font-size: 11px; color: var(--muted); line-height: 1.5; }
.rated-prov:empty { display: none; }
/* 段級位 */
.result-rated .rr-grade { flex-basis: 100%; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.result-rated .rr-grade:empty { display: none; }
.result-rated .rr-grade.up { font-size: 18px; font-weight: 900; color: #b5361f; font-family: var(--font-pop); letter-spacing: 0.06em; animation: grade-pop 0.6s cubic-bezier(.3, 1.6, .5, 1) 0.9s both; }
@keyframes grade-pop { from { transform: scale(0.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .result-rated .rr-grade.up { animation: none; } }
.rated-goal { font-size: 12px; font-weight: 700; color: #a0742a; }
.rated-goal:empty { display: none; }
.prole .rl-short { display: none; }
@media (max-width: 640px) { .prole .rl-long { display: none; } .prole .rl-short { display: inline; } }

/* オンラインの対局がお休み中（サーバーの無料の枠を使い切った）：ボタンを薄くし、添え書きで再開の時刻を出す。押すと理由を出す */
#mainButtons .big.paused { opacity: .62; }
#mainButtons .big.paused .watch-note { color: #8a5a2b; background: none; font-weight: 700; }
