/* 英語用の欧文書体：説明文はやわらかい絵本調のセリフ体（Fraunces）、テロップは幅を詰められるセリフ体（Roboto Serif）。日本語・中国語の表示では読み込まれない */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght,SOFT@9..144,400..800,100&family=Nunito:wght@500..900&family=Roboto+Serif:opsz,wdth,wght@8..144,50..100,500..800&display=swap");
/* 中国語用の書体：日本語の3書体と同じ役割・雰囲気のものを選ぶ（日本語・英語の表示では字の形を読み込まない）
   簡体字と繁体字は同じ書体（または同じ書体の繁体字版）にそろえ、ゲームで使う字がすべて入っている書体だけを使う（字が欠けた書体を無理に使わない）
   見出し・テロップ（Kaisei Decol の明朝）→ 汇文明朝体（Huiwen-mincho。日本の明朝体の活字をもとにした、古い印刷物の味のある明朝。簡体字・繁体字とも持つ）
   本文（Zen Maru Gothic の丸ゴシック）→ 昭源圓體（Chiron GoRound TC。簡体字の字も持つ）
   ひとこと（Klee One の手書き風）→ Klee One から作られた霞鹜文楷：簡体字は LXGW WenKai、繁体字はその繁体字版 LXGW WenKai TC */
@import url("https://fonts.googleapis.com/css2?family=Chiron+GoRound+TC:wght@500;700;900&family=LXGW+WenKai+TC:wght@700&display=swap");
@import url("https://cdn.jsdelivr.net/npm/lxgw-wenkai-webfont@1.7.0/lxgwwenkai-bold.css");
@import url("https://cdn.jsdelivr.net/npm/@chinese-fonts/hwmct@3.0.0/dist/%E6%B1%87%E6%96%87%E6%98%8E%E6%9C%9D%E4%BD%93/result.css");
/* 韓国語用の書体：同じく日本語の3書体の役割・雰囲気に合わせる（韓国語の表示でだけ字の形を読み込む）
   見出し・テロップ → 송명（Song Myung。筆の丸みが残る装飾的な明朝）、本文 → 해바라기（Sunflower。やわらかいゴシック）、
   ひとこと → 서툰 이야기（Poor Story。読みやすい手書き風） */
@import url("https://fonts.googleapis.com/css2?family=Song+Myung&family=Sunflower:wght@500;700&family=Poor+Story&display=swap");
/* ============================================================
   城壁工場都市 — 画面デザイン
   明るい紙色のパネルに、会社の色（紅・蒼）と黄色の操作色。
   押せるものは下に厚みのある「つまみ」、読むものは平らな面。
   ============================================================ */
: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;
}
#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.big { font-size: 18px; padding: 15px 24px; border-radius: 14px; }
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 { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); padding: 10px 14px 10px 16px; }
#btnRules span { flex: 1; }
#btnRules svg { width: 20px; height: 20px; opacity: 0.75; }
#btnRules .chev { width: 18px; height: 18px; transition: transform 0.15s; }
#btnRules:hover { background: var(--paper-2); }
#btnRules:hover .chev { transform: translateX(3px); }
/* 「ルール」の下の注記：囲碁を知っている人に、中国ルールとの違いだけを */
.rule-note { font-size: 12px; line-height: 1.7; color: var(--muted); margin: -4px 0 0; text-align: center; }
.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; }
/* 「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;
}
#rules, #dialog, #choice, #result, #editor { 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 { 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; }

.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の強さの6つは、パソコンでも折り返さず1段に並べる */
.seg[data-key^="level"] { flex-wrap: nowrap; }
.seg[data-key^="level"] button { min-width: 0; padding: 9px 2px; white-space: nowrap; }
.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 { width: 0.75em; height: 0.9em; margin-left: 3px; vertical-align: -0.1em; } /* 0 の右の初心者マーク */
.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); }
.note { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.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: 12px -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.analytics-note { font-size: 10px; margin-top: 2px; opacity: .6; }
#menu:has(#setup:not(.hidden)) .title-block { margin-bottom: 14px; }

/* ---------- ルール ---------- */
.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; }

/* ---------- 街の形 ---------- */
.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); }
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: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); }
/* 選ぶダイアログ：選択肢は、見出しと一言の説明をもつ大きなつまみ。いちばん勧める選択肢を黄色に */
.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); }
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; }
.result-panel .dialog-buttons button { padding: 10px 14px; white-space: nowrap; }

/* ---------- 対局中：上の得点板 ---------- */
#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: 11px; font-weight: 700; line-height: 1.3; color: var(--muted); 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); }
.hide-score .pscore, .hide-score .share, .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); }
.dock button.autostop: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: "・・・"; } }
/* 得点の割合 */
.share {
  grid-column: 1 / -1;
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.6);
  margin-top: 14px;
  box-shadow: 0 1px 3px rgba(24, 34, 52, 0.15);
}
.share i { display: block; height: 100%; width: 50%; transition: width 0.6s cubic-bezier(0.3, 1.2, 0.5, 1); }
#share1 { background: var(--p1); }
#share2 { background: var(--p2); }

/* ---------- 対局中：下の操作 ---------- */
/* 説明文・再生バー・操作の案内は、下のメニューの実際の高さ（--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; margin-left: 2px; position: relative; }
.dock .hide-btn::before { content: ''; position: absolute; left: -3px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
#message, .replay-bar, #camHint { transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
#btnFold { display: none; } /* たたむボタンはスマホの縦画面だけ */
#btnMenu .lbl-short { display: none; } /* スマホの縦画面では幅が足りないので短い言い方にする */
.dock .sep { width: 1px; align-self: stretch; margin: 8px 4px; background: var(--line); flex: none; }
.dock 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;
}
.dock button:hover { background: var(--paper-2); color: var(--ink); }
.dock button:active { transform: scale(0.95); box-shadow: none; }
.dock button:disabled { box-shadow: none; }
.dock button.on { background: #fff3cf; color: #8a5a00; }
/* 切り替えボタン：右上の小札で今の状態（オン・オフ）を示す */
.dock button.toggle { position: relative; }
.dock 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 { content: 'ON'; background: #2f9e5b; color: #fff; opacity: 1; }
.dock button.toggle:not(.on) svg { opacity: 0.4; }
/* 時間帯ボタンで開く吹き出し（時間帯ボタンの真上に出る） */
.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; }
#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); } }

/* ---------- 演出 ---------- */
#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: 28px;
  transform: translate(-50%, -50%);
  animation: popUp 1.1s ease-out forwards;
  -webkit-text-stroke: 5px #fff;
  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: 34%;
  display: flex;
  justify-content: center;
  animation: bannerLife 4s forwards;
}
.banner .band {
  background: var(--c);
  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); }
}
.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: 112px;
  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 { 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: 9px; letter-spacing: -0.03em; }
  .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 { min-width: 2.4em; }
  .pscore small { display: none; }
  /* スマホ：1列では半分ほどが画面の外に隠れて気づかれないので、1段6つの2段に折り返して全部見せる（対局中の12個が2段に収まる） */
  .dock { flex-wrap: wrap; justify-content: center; width: calc(100vw - 16px); overflow: visible; border-radius: 16px; padding: 4px; }
  .dock .sep { display: none; }
  .dock button { flex: 0 0 calc((100% - 10px) / 6); 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; }
  /* たたんだとき：よく使う4つと「すべて」だけの1段にする */
  #btnFold { display: flex; }
  #btnMenu .lbl-long { display: none; }
  #btnMenu .lbl-short { display: inline; }
  #btnFold svg { transform: rotate(0deg); }
  .dock-folded .dock .extra { display: none; }
  #hud:not(.dock-folded):not(.replaying) .dock .hide-btn { display: none; } /* 広げた2段では「たたむ」だけ。しまうのは、たたんだ1段から */
  .dock .hide-btn { min-width: 0; margin-left: 0; }
  #dockTab { padding: 8px 22px 8px 16px; font-size: 13px; } /* 指で押しやすい大きさに */
  .dock .hide-btn::before { display: none; }
  .dock-folded #btnFold svg { transform: rotate(180deg); }
  #toast { top: 96px; }
  #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: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::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;
}
.tagline { font-family: var(--font-hand); font-size: 14px; line-height: 1.9; letter-spacing: -0.01em; color: var(--ink-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 { 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 { background-image: none; }
.dock 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 #btnMenu, #hud.replaying #btnFold, #hud.replaying .dock .sep, #hud.replaying #camHint { display: none !important; }
#hud.replaying .dock .extra { display: flex !important; }
/* 終局後（景色をみる）だけ、下のボタンの列に「振り返る」を出す */
.after-only { display: none !important; }
#hud.finished:not(.replaying) .after-only { display: flex !important; }
/* 終局後は、もう押せない・意味のないボタン（パス・投了・2回クリック・得点）を下げて、メニューの段数を減らす */
#hud.finished #btnPass, #hud.finished #btnResign, #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: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; }
  #hud.replaying .dock button { flex-basis: calc((100% - 8px) / 5); } /* 9つを5つ・4つの2段に。「結果に戻る」が2行に割れない幅 */
}

/* ---------- 言語ごとの調整（英語・簡体字中国語） ---------- */
.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; }
.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; }
/* 簡体字：日本の書体のままだと漢字が日本の字形になるので、中国語の書体を先に使う */
:root:lang(zh) {
  --font: "Chiron GoRound TC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-pop: "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: "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(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）が札に収まるよう、少し小さく詰める */
@media (max-width: 640px) { :root:lang(en) .pname { font-size: 11.5px; letter-spacing: -0.02em; } }
/* 英語の題字「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; }
