/* ROWTATE（ロウテート）。見た目はデザインキャンバスの「ナイトダイヤル」 */
:root {
  --ground: #0F1626;
  --card: #17223A;
  --button: #1C2A45;
  --line: #33456A;
  --line-soft: #26324A;
  --plate: #1A2539;
  --groove: #22304A;
  --hole: #0B1222;
  --dial: #131D31;
  --dial-line: #2A3854;
  --text: #EEF2F8;
  --sub: #A9B4C7;
  --gold: #FFC53D;
  --gold-ink: #1A1300;
  --blue: #3E7BFA;
  --blue-text: #6E9BFF;
  --warn: #FF7A59;
  --warn-text: #FF9C80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--text);
  font-family: 'M PLUS Rounded 1c', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.screen {
  max-width: 440px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 13px calc(20px + env(safe-area-inset-bottom));
}

/* ---------- タイトル ---------- */
.title-screen { align-items: center; padding: 20px; overflow-x: hidden; overflow-y: auto; }
/* 読み上げと検索のためだけの文字（画面には出さない） */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.gold { color: var(--gold); }
/* 左（名前と盤。スマホは「遊ぶ」「カスタマイズ」も）と、右（設定。スマホは下から出る板）。並べ方は下の @media で */
.title-hero { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; }
/* タイトルの盤：A「スポットライト」。--tb 倍（app.js の fitTitle が、空いた高さと幅いっぱいに合わせる）。
   名前を輪の上の弧に乗せるので、盤の座標で x -74〜438・y -40〜430（上の弧の ROWTATE から、下の「下」の印まで）を映す */
.title-board { --tb: .55; width: calc(512px * var(--tb)); height: calc(470px * var(--tb)); flex-shrink: 0; position: relative; }
/* 盤の後ろの光（金色の光と、青い明かり）。ゆっくり息をする。
   縦は盤の箱の中だけ（はみ出すと、パソコンで縦のスクロールが出る）。横は少しはみ出す（画面の外は .title-screen が切る） */
.title-board::before { content: ''; position: absolute; left: -10%; top: 0; width: 120%; height: 100%; background: radial-gradient(ellipse closest-side at 50% 57.45%, rgba(255, 197, 61, .22), rgba(255, 197, 61, .07) 50%, rgba(29, 44, 79, .5) 72%, rgba(29, 44, 79, 0)); pointer-events: none; animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }
/* タイトルの盤は見せるだけ。指でなぞると画面がスクロールするように（対局の盤の touch-action: none を戻す） */
/* 回した輪の四角い外枠（見えない）がはみ出してスクロールが出ないよう、盤の枠で切る（見える部分はすべて内側） */
.title-board .stage { transform: scale(var(--tb)) translate(74px, 40px); touch-action: auto; overflow: hidden; }
.title-arc { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.arc-ring { fill: none; stroke: var(--gold); stroke-opacity: .35; stroke-width: 1.2; }
.arc-tick { stroke: #3A4A6A; stroke-width: 1.2; }
.arc-tick.long { stroke: var(--gold); stroke-width: 2; }
/* 名前は 74。弧は半径 300 のゆるやかなもの（左右 ±46° ほど。文字のはしが x -74〜438 に収まる。
   大きくするなら、上の箱と viewBox・fitTitle の数も広げる）。光る ROW は、ぼかした同じ字を後ろに重ねる */
.arc-name { font-family: 'Dela Gothic One', sans-serif; font-size: 74px; letter-spacing: 0; fill: var(--text); }
.arc-gold { fill: var(--gold); }
.arc-glow { opacity: .75; }
.arc-none { fill: transparent; }
/* スマホの「遊ぶ」「カスタマイズ」と、カスタマイズの板の見出し・後ろの暗がり（パソコンでは出さない） */
.title-quick { display: flex; flex-direction: column; gap: 8px; align-self: stretch; }
.quick-summary { margin: 0; text-align: center; font-size: 13px; font-weight: 700; color: var(--sub); }
.sheet-head { display: flex; align-items: center; gap: 8px; position: relative; padding-top: 10px; }
.sheet-handle { position: absolute; left: 50%; top: 0; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: #3A4A6A; }
.sheet-title { margin: 0; flex: 1; font-family: 'Dela Gothic One', sans-serif; font-weight: 400; font-size: 20px; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 19; background: rgba(5, 9, 18, .6); opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s .2s; }
/* カスタマイズ：見出しの下に −・値・＋ の1列（ほかの設定のボタンの列と同じ高さ） */
.step-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); container-type: inline-size; }
/* 欄がせまいとき（幅 320 のスマホ・幅 900 のパソコン）は、−＋ と字を欄の幅に合わせて少し小さくする（「11×11」が切れないように） */
.step-row .step { width: clamp(30px, 26cqw, var(--seg-h, 44px)); }
.step { width: var(--seg-h, 44px); height: var(--seg-h, 44px); border: 1px solid var(--line); border-radius: 10px; background: var(--button); font-size: 18px; font-weight: 800; }
.step:disabled { color: #56657F; border-style: dashed; }
.step-value { min-width: 0; text-align: center; font-size: clamp(12px, 10.5cqw, 15px); font-weight: 800; white-space: nowrap; }
/* はじめの設定に もどす：ほかの設定のボタンの列と同じ高さの札 */
.reset-row { width: 100%; height: calc(var(--seg-h) + 8px); border: none; border-radius: 14px; background: var(--card); font-size: 14px; font-weight: 800; }
.reset-row:disabled { color: #7D8AA3; }
.setting { align-self: stretch; display: flex; flex-direction: column; gap: 6px; }
.setting-label { font-size: 12px; font-weight: 700; color: var(--sub); }
.setting-note { font-size: 13px; line-height: 1.5; color: var(--sub); }
/* 遊び方の説明は2行分の高さに固定（切りかえても、下の設定が上下に動かないように） */
#mode-note { min-height: 3em; }
/* どの設定も「見出し＋同じ高さのボタン1列」。ボタンの高さは --seg-h（スマホ 44px、パソコン 38px） */
.title-screen { --seg-h: 44px; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 4px; border-radius: 14px; background: var(--card); }
.segmented button { height: var(--seg-h, 44px); padding: 0 2px; border: none; border-radius: 10px; background: transparent; font-size: 14px; font-weight: 800; white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--ground); }
.segmented button:disabled { color: #7D8AA3; }
.segmented:has(> button:nth-child(3)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented:has(> button:nth-child(4)) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* だれと（CPU・オンライン・ローカル）：ほかの設定と同じ高さで、字だけ少し大きく */
.tabs button { font-size: 15px; }
/* カスタマイズ（盤の大きさ・並べる数・回数）と、予告・音・もどす。スマホは2列×3段（パソコンは下の @media で3列×2段） */
.setting-grid { align-self: stretch; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; flex-shrink: 0; }
/* 相手ごとの欄とボタン：同じ場所に重ね、選んでいないもの（.away）は見えなくするだけ。いちばん高いものに合わせた高さのまま変わらない */
.play-rows, .play-actions { align-self: stretch; display: grid; flex-shrink: 0; }
.play-rows > *, .play-actions > * { grid-area: 1 / 1; }
.play-rows > .away, .play-actions > .away { visibility: hidden; }
/* 選ぶもののない欄（ローカル・オンラインが使えないとき）：ボタンの列と同じ高さの、説明の札 */
.info-row { display: flex; align-items: center; justify-content: center; min-height: calc(var(--seg-h) + 8px); padding: 0 12px; border-radius: 14px; background: var(--card); font-size: 13px; font-weight: 700; color: var(--sub); text-align: center; }
.play-rows .code-row input, .play-rows .code-row .btn { height: calc(var(--seg-h) + 8px); }
.play-rows .code-row input { font-size: 17px; }
.setting-label.warn { color: var(--warn-text); }
/* 使わない設定（重力なし・回数 0 の予告）：消さずに薄くして押せなくする */
.setting.off { opacity: .45; }
.setting.off .segmented button[aria-pressed="true"] { background: var(--line); color: var(--text); }
.link-button { border: none; background: none; color: var(--sub); font-size: 13px; font-weight: 700; text-decoration: underline; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; }
.link-button:hover { color: var(--text); }

.online-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.online-buttons .btn { height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.btn-sub { font-size: 12px; font-weight: 700; color: var(--sub); }
.btn-gold .btn-sub { color: #6B5000; }
.btn-light .btn-sub { color: #46526B; }
.btn:disabled { opacity: .5; cursor: default; }
.consent { margin: 0; font-size: 12px; color: var(--sub); text-align: center; }
.consent a { color: var(--sub); display: inline-block; padding: 12px 2px; margin: -12px -2px; }
/* 下のリンク：4つを1列に（幅 320 の小さいスマホでは2段に折り返す）。字の高さもそろえる */
.title-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 4px; }
.title-links .link-button { padding: 0 8px; }

/* ---------- オンライン（ロビー） ---------- */
.lobby-screen { overflow-y: auto; }
.icon-spacer { width: 44px; }
.lobby-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 18px; background: var(--card); }
.lobby-h { margin: 0; font-family: 'Dela Gothic One', sans-serif; font-weight: 400; font-size: 22px; }
.lobby-text, .lobby-settings { margin: 0; font-size: 14px; line-height: 1.7; color: var(--sub); }
.lobby-settings { color: var(--text); font-weight: 700; }
.lobby-or { text-align: center; font-size: 12px; color: var(--sub); }
.lobby-label { font-size: 13px; font-weight: 800; }
.code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.code-row input, .dialog textarea { min-width: 0; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--ground); color: var(--text); font: inherit; font-size: 18px; font-weight: 800; letter-spacing: .08em; padding: 0 12px; }
.dialog textarea { width: 100%; height: auto; padding: 10px 12px; font-size: 16px; font-weight: 400; letter-spacing: 0; line-height: 1.6; resize: vertical; }
.code-row input:focus, .dialog textarea:focus { outline: 3px solid var(--gold); outline-offset: 1px; }
.code-row .btn { min-width: 76px; }
.code-big { font-family: 'Dela Gothic One', sans-serif; font-size: 42px; letter-spacing: .12em; text-align: center; color: var(--gold); padding: 8px 0; user-select: all; }
.dots { display: flex; justify-content: center; gap: 10px; padding: 8px 0; }
.dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); animation: dot 1.2s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: .2s; background: var(--blue); }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-8px); opacity: 1; } }
/* 待っているあいだ：小さな盤が回り、その下に待った時間（2026-11-12） */
/* 待つ画面（2026-11-12 pineさん「スクロールがないように」）：パネルが画面の残りの高さを使い、小さな盤と QR コード（.lobby-grow）が
   さらにその残りに合わせて伸び縮みする（大きさは app.js の fitLobby が入れる）。ほかの部品は詰めて、決まった高さにする */
.lobby-panel.lobby-fit { flex: 1 1 0; min-height: 0; gap: 9px; padding: 14px 14px 12px; }
.lobby-grow { flex: 1 1 0; min-height: 0; overflow: hidden; }
/* スマホを横にしたとき（背が低い）：左に盤か QR コード、右に文とボタンを並べて、スクロールを出さない。こつと下の一文は省く */
@media (orientation: landscape) and (max-height: 520px) {
  .screen.lobby-screen { max-width: 780px; gap: 6px; padding-top: 6px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .lobby-screen .topbar { height: 36px; }
  .lobby-panel.lobby-fit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); grid-template-rows: repeat(7, auto) 1fr; column-gap: 18px; row-gap: 7px; padding: 10px 14px; }
  .lobby-fit > .lobby-grow { grid-column: 1; grid-row: 1 / -1; }
  .lobby-fit > :not(.lobby-grow) { grid-column: 2; }
  .lobby-fit .search-tip, .lobby-screen .lobby-note { display: none; }
  .lobby-fit .lobby-h { font-size: 17px; }
}
/* とても小さい画面では、盤と QR コードを切らずに、最小の大きさを守る（そのときだけスクロールが出る） */
.search-stage.lobby-grow { min-height: 64px; }
.room-qr-box.lobby-grow { min-height: 84px; }
.lobby-fit .lobby-h { font-size: 19px; line-height: 1.35; }
.lobby-fit .lobby-text { font-size: 13px; line-height: 1.6; }
.lobby-fit .lobby-text.small { font-size: 12.5px; }
.lobby-fit .lobby-settings { font-size: 13.5px; line-height: 1.5; }
.lobby-fit .code-big { font-size: 34px; padding: 0; line-height: 1.2; }
.lobby-fit .sheet-buttons .btn { height: 46px; }
.lobby-foot { display: flex; align-items: center; gap: 10px; }
.lobby-foot .search-clock.small { flex: 1; text-align: left; }
.lobby-foot .btn { height: 44px; padding: 0 24px; }
.search-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.search-stage.row { flex-direction: row; gap: 18px; }
.lobby-board { position: relative; overflow: hidden; width: var(--lbw, 168px); height: var(--lbh, 170px); flex-shrink: 0; pointer-events: none; }
.lobby-board .stage { transform: scale(var(--lbs, .4375)) translate(10px, -38px); }
.lobby-board::before { content: ''; position: absolute; inset: 0; background: radial-gradient(closest-side, rgba(255, 197, 61, .18), rgba(255, 197, 61, 0)); animation: breathe 3.6s ease-in-out infinite; }
.search-clock { margin: 0; font-family: 'Dela Gothic One', sans-serif; font-size: 30px; letter-spacing: .06em; color: var(--gold); font-variant-numeric: tabular-nums; }
.search-clock.small { font-family: inherit; font-size: 13px; font-weight: 700; letter-spacing: 0; color: var(--sub); text-align: center; }
.search-tip { margin: 0; min-height: calc(3.2em + 16px); padding: 8px 12px 8px 40px; border-radius: 12px; border: 1px dashed var(--line); font-size: 12.5px; line-height: 1.6; color: var(--text); position: relative; }
.search-tip::before { content: 'こつ'; position: absolute; left: 10px; top: 9px; font-size: 11px; font-weight: 800; color: var(--gold); }
/* 30秒たっても見つからないとき：こつの代わりに「まだ見つかりません」（同じ場所・同じ高さ） */
.search-tip.help { border-color: var(--gold); }
.search-tip.help::before { content: 'まだ'; }
.search-tip.show { animation: tip-in .4s ease; }
@keyframes tip-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.lobby-panel .btn-wide .btn-sub, #search-to-cpu .btn-sub, #room-to-cpu .btn-sub, .result-play .btn-sub { display: block; }
.search-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.search-actions:has(> #search-to-cpu[hidden]) { grid-template-columns: minmax(0, 1fr); }
#search-to-cpu { height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0 8px; font-size: 15px; }
#cancel-search, #cancel-room { height: 54px; padding: 0 18px; }
#room-to-cpu { height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0 8px; font-size: 15px; }
/* 友達を待っている：待った時間は見出しの右に（1行ぶん詰める） */
.lobby-h-clock { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lobby-h-clock .search-clock.small { flex-shrink: 0; font-size: 14px; color: var(--gold); font-variant-numeric: tabular-nums; }
/* 合言葉の部屋の QR コード（白い地。読みやすさのため、色は変えない） */
.room-qr-box { margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.room-qr { width: var(--qr, 168px); height: var(--qr, 168px); flex-shrink: 0; border-radius: 10px; overflow: hidden; background: #fff; }
.room-qr svg { display: block; width: 100%; height: 100%; }
.room-qr-note { font-size: 12px; color: var(--sub); text-align: center; }
/* さがしながらコンピューターと遊んでいるとき：上の帯の真ん中の札 */
.search-pill { min-width: 0; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 4px 0 12px; border-radius: 17px; background: var(--card); border: 1px solid var(--gold); font-size: 12px; font-weight: 800; }
.search-pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex-shrink: 0; animation: breathe 1.2s ease-in-out infinite; }
.search-pill-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
/* 札を押すと出る、合言葉の窓 */
.room-dialog { text-align: center; }
.room-dialog .code-big { padding: 0 0 8px; font-size: 36px; }
.room-dialog .room-dialog-qr { --qr: 180px; margin: 0 auto 12px; }
.room-dialog .sheet-buttons { margin-bottom: 10px; }
.search-pill-x { width: 28px; height: 28px; flex-shrink: 0; border: none; border-radius: 50%; background: var(--button); color: var(--text); display: grid; place-items: center; }
/* あいてが見つかった：先手と後手と、3・2・1 */
.found-dialog { text-align: center; border-color: var(--gold); overflow: hidden; }
.found-kicker { margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--gold); }
.found-dialog h2 { font-size: 21px; }
.found-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 8px 0 12px; }
.found-side { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 14px; background: var(--ground); }
.found-side b { font-size: 16px; }
.found-role { font-size: 12px; color: var(--sub); font-weight: 700; }
.found-piece { width: 34px; height: 34px; border-radius: 50%; position: relative; }
.found-piece.p1 { background: var(--gold); box-shadow: 0 0 18px rgba(255, 197, 61, .55), inset 0 -3px 0 rgba(0,0,0,.18); }
.found-piece.p1::after { content: ''; position: absolute; inset: 8px; border-radius: 50%; border: 3px solid #FFF0C2; }
.found-piece.p2 { background: var(--blue); box-shadow: 0 0 18px rgba(62, 123, 250, .55), inset 0 -3px 0 rgba(0,0,0,.22); }
.found-piece.p2::after { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: #BCD2FF; }
.found-x { font-family: 'Dela Gothic One', sans-serif; font-size: 18px; color: var(--sub); }
.found-settings { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--sub); }
.found-count { height: 68px; display: grid; place-items: center; font-family: 'Dela Gothic One', sans-serif; font-size: 48px; line-height: 1; color: var(--gold); }
.found-count.pop { animation: count-pop .8s ease-out; }
@keyframes count-pop { 0% { transform: scale(1.6); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.92); opacity: .85; } }
.lobby-error { margin: 0; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--warn); color: var(--warn-text); font-size: 14px; line-height: 1.6; }
.lobby-note { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--sub); flex-shrink: 0; }
.lobby-note a { color: var(--sub); }
.inbox-msg { margin: 0; min-height: 1.2em; font-size: 13px; line-height: 1.6; color: var(--sub); white-space: pre-line; }
.inbox-msg.strong { color: var(--text); font-weight: 700; }
.dialog-rule { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.dialog .lobby-label { display: block; margin-bottom: 6px; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }

/* ---------- ボタン ---------- */
.btn { height: 52px; border-radius: 14px; border: none; background: var(--button); font-size: 16px; font-weight: 800; padding: 0 12px; }
.btn-wide { align-self: stretch; width: 100%; }
.btn-gold { background: var(--gold); color: var(--gold-ink); }
.btn-light { background: var(--text); color: var(--ground); }
.btn-outline { background: transparent; border: 1.5px solid var(--line); }
.btn-warn { background: transparent; border: 1.5px solid var(--warn); color: var(--warn-text); }
.btn-blue { background: var(--blue-text); color: #071026; }
#start-button { height: 56px; font-size: 17px; flex-shrink: 0; }

/* ---------- ゲーム画面 ---------- */
/* 盤をできるだけ大きくするため、すきまと余白は小さめ。上の帯（メニューと「？」）は画面の幅いっぱいで、両はしに置く */
.screen.game-screen { max-width: none; gap: 8px; padding: 10px 10px calc(14px + env(safe-area-inset-bottom)); overflow-x: hidden; overflow-x: clip; }
@media (max-width: 639px), (orientation: portrait) {
  /* 縦長：上の帯のほかは、真ん中の列（幅 --col）に並べる */
  .game-screen > :not(.topbar) { width: 100%; max-width: var(--col, 440px); margin-left: auto; margin-right: auto; }
}
.topbar { display: flex; align-items: center; justify-content: space-between; height: 44px; flex-shrink: 0; }
.icon-button { width: 44px; height: 44px; padding: 0; border: none; border-radius: 12px; background: var(--card); display: flex; align-items: center; justify-content: center; }
.icon-button:disabled { color: #56657F; background: #141D30; }
.topbar .icon-button { flex-shrink: 0; }
.mode-text { min-width: 0; font-size: 13px; line-height: 1.45; font-weight: 700; color: var(--sub); text-align: center; }

.players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; flex-shrink: 0; }
.player-card { position: relative; border-radius: 16px; background: var(--card); border: 2px solid var(--line-soft); padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; transition: border-color .2s; }
.player-card.active, .player-card.winner { border-color: var(--gold); }
#card-2.active, #card-2.winner { border-color: var(--blue-text); }
.player-head { display: flex; align-items: center; gap: 8px; min-height: 22px; min-width: 0; }
.swatch { position: relative; width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }
/* 色だけに頼らない：駒と同じ印（1P は輪、2P は点） */
.swatch::after { content: ''; position: absolute; border-radius: 50%; }
.swatch.p1::after { inset: 4px; border: 2px solid #FFF0C2; }
.swatch.p2::after { inset: 6px; background: #BCD2FF; }
.swatch.p1 { background: var(--gold); box-shadow: inset 0 -2px 0 rgba(0,0,0,.18); }
.swatch.p2 { background: var(--blue); box-shadow: inset 0 -2px 0 rgba(0,0,0,.22); }
.player-name { min-width: 0; font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { position: absolute; top: -10px; right: 10px; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 2px 8px; background: var(--gold); color: var(--gold-ink); white-space: nowrap; }
#card-2 .badge { background: var(--blue-text); color: #071026; }
.player-rot { display: flex; align-items: center; gap: 6px; }
.rot-label { font-size: 12px; font-weight: 700; color: var(--sub); margin-right: 2px; }
.tokens { display: flex; gap: 6px; }
.token { width: 12px; height: 12px; border-radius: 50%; background: var(--text); }
.token.used { background: transparent; border: 2px solid #7F8EAB; }
.rot-left { margin-left: auto; font-size: 12px; color: var(--sub); white-space: nowrap; }
.rot-label { white-space: nowrap; }
.player-card.many .tokens { gap: 4px; }
.player-card.many .token { width: 10px; height: 10px; }
.player-card.many .rot-left { display: none; }

.status { min-height: 24px; display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center; font-size: 16px; font-weight: 800; flex-shrink: 0; }
.thinking { display: inline-flex; gap: 3px; margin-left: 2px; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--sub); animation: think 1s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes think { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.status .chip { font-size: 12px; font-weight: 800; color: var(--gold); border: 1.5px solid var(--gold); border-radius: 999px; padding: 2px 9px; }

.board-area { position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
/* 盤の後ろの光（タイトルと同じ A「スポットライト」）。--glow は映している盤の幅（app.js の fitBoard）。ゆっくり息をする */
/* 縦は盤の場所（.board-area）の中だけ（はみ出すと、横持ちのスマホで右の欄がスクロールできなくなる）。横は画面のはしで切る */
.board-area::before { content: ''; position: absolute; left: 50%; top: 0; width: calc(var(--glow, 300px) * 1.45); height: 100%; transform: translateX(-50%); background: radial-gradient(ellipse closest-side, rgba(255, 197, 61, .2), rgba(255, 197, 61, .06) 50%, rgba(29, 44, 79, .45) 72%, rgba(29, 44, 79, 0)); pointer-events: none; animation: breathe 3.6s ease-in-out infinite; }
/* 回した輪の四角い外枠がはみ出して横スクロールが出ないよう、盤の枠で切る（見える部分はすべて内側） */
.scaler { position: relative; flex-shrink: 0; overflow: hidden; }
.toast { position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 2; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 999px; background: var(--button); border: 1px solid var(--line); font-size: 13px; font-weight: 700; white-space: nowrap; pointer-events: none; }
.toast .swatch { width: 12px; height: 12px; }

.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; flex-shrink: 0; }
/* 盤の下のボタンの列：回すボタン（2つ）と、一手もどす。見えているボタンの数で等分して、どれも同じ大きさ
   （回すボタンの入れ物 .controls は箱を無いものとして、中のボタンを直接この列に並べる。隠すと中のボタンも消える） */
.action-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; flex-shrink: 0; }
.action-row > .controls { display: contents; }
/* ボタンは、絵が上・名前が下（スマホで3つ並べても字が切れないように） */
.rotate-button { height: 56px; min-width: 0; padding: 0 6px; border-radius: 16px; background: var(--button); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.rotate-button svg { order: -1; width: 22px; height: 22px; flex-shrink: 0; }
.rotate-main { font-size: 14px; font-weight: 800; white-space: nowrap; }
.rotate-button:disabled { background: #141D30; border-style: dashed; color: #8C9BB8; }
/* 回したときの予測（パソコンの右の欄。下の @media のときだけ出す） */
.forecast { display: none; }
.forecast-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.forecast-title { font-size: 13px; font-weight: 800; color: var(--sub); }
.forecast-toggle { min-width: 64px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); background: transparent; font-size: 13px; font-weight: 800; color: var(--sub); }
.forecast-toggle[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--ground); }
.forecast-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fc { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.fc-board { position: relative; overflow: hidden; width: 160px; height: 162px; }
/* 小さな盤：映す範囲は対局の盤と同じ（app.js の VIEW。左右 -10・上 38） */
.fc .stage { transform: scale(var(--fs, .42)) translate(10px, -38px); }
.fc figcaption { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 3.1em; text-align: center; font-size: 12px; line-height: 1.4; color: var(--sub); }
.fc figcaption b { font-size: 13px; color: var(--text); }
.fc.win .fc-text { color: var(--gold); font-weight: 800; }
.fc.lose .fc-text { color: var(--warn-text); font-weight: 800; }
.forecast-note { margin: 0; font-size: 13px; color: var(--sub); }
@media (min-width: 900px) and (orientation: landscape) and (min-height: 560px) {
  .forecast { grid-area: forecast; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line-soft); }
  .forecast[hidden] { display: none; }
}
.reserved { visibility: hidden; }
kbd { font-family: inherit; font-size: 11px; font-weight: 800; color: var(--sub); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 5px; line-height: 16px; }
.mouse-only { display: none; }
@media (hover: hover) and (pointer: fine) {
  .mouse-only { display: inline; }
  .touch-only { display: none; }
}

.sheet { border-radius: 18px; background: #1A2133; border: 1.5px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.sheet.warn { border-color: var(--warn); }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.warn-icon { color: var(--warn); flex-shrink: 0; }
.sheet:not(.warn) .warn-icon { display: none; }
.sheet-title { font-size: 17px; font-weight: 800; }
.sheet-text { font-size: 13px; line-height: 1.6; color: var(--sub); }
.sheet-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.direction-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.direction-grid button, .direction-grid .dir-center { height: 58px; border-radius: 12px; border: 1px solid var(--line); background: var(--button); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 800; }
.direction-grid .dir-center { background: transparent; border-style: dashed; color: var(--sub); font-weight: 700; }
.direction-grid svg { color: var(--gold); }
.axis-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.axis-grid button { height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--button); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 800; }
.axis-grid button[aria-pressed="true"] { background: var(--text); color: var(--ground); border-color: var(--text); }
.axis-grid button:disabled { color: #56657F; border-style: dashed; }
.result-sheet { background: var(--card); border: 2px solid var(--gold); border-radius: 20px; padding: 18px; }
.result-sheet.p2 { border-color: var(--blue-text); }
.result-sheet.draw { border-color: var(--line); }
.result-title { font-family: 'Dela Gothic One', sans-serif; font-size: 34px; line-height: 1.2; color: var(--gold); }
.result-sheet.p2 .result-title { color: var(--blue-text); }
.result-sheet.draw .result-title { color: var(--text); }
.result-chips { display: flex; gap: 8px; }
.result-chips span { font-size: 12px; font-weight: 700; background: var(--groove); border-radius: 999px; padding: 4px 10px; }

/* ---------- 盤 ---------- */
.stage { position: absolute; left: 0; top: 0; width: 364px; height: 432px; transform-origin: top left; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage:focus-visible { outline-offset: -4px; border-radius: 24px; }
/* 盤の見た目は A「スポットライト」（タイトルと対局で同じ）：輪は少し明るいふち、駒はほんのり光る、「下」の印は金色 */
.dial { position: absolute; left: 0; top: 48px; width: 364px; height: 364px; border-radius: 50%; background: #121B2E; border: 2px solid #3A4A6A; }
.ring { position: absolute; left: 0; top: 48px; width: 364px; height: 364px; transition-property: transform; transition-timing-function: ease-in-out; }
.notch { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: #3A4A6A; }
.notch.home { width: 12px; height: 12px; margin: -6px 0 0 -6px; background: transparent; border: 2px solid #8C9BB8; }
.notch.current { width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--text); border: none; }
/* ダイヤルのメモリ（15° ごと。飾り） */
.tick { position: absolute; width: 2px; height: 8px; margin: -4px 0 0 -1px; border-radius: 1px; background: #2E3D5C; }

.pointer { position: absolute; left: 174px; top: 411px; width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 12px solid var(--gold); }
.plate { position: absolute; left: 62px; top: 110px; width: 240px; height: 240px; border-radius: 18px; background: var(--plate); box-shadow: 0 10px 28px rgba(0,0,0,.35); transition-property: transform; transition-timing-function: ease-in-out; }
.strips, .holes, .bars, .pieces { position: absolute; inset: 0; }
/* 溝の帯：ふだんは出さない（重力の向きが変わるたびに引き直すので、線が出たり消えたりして見えた。2026-10-24 pineさん「線はなくするか」）。
   駒を入れる溝を選んでいるあいだだけ、その溝を明るくする（.aimed） */
.strip { position: absolute; background: transparent; transition: background .12s; }
.strips[data-player="1"] .strip.aimed { background: rgba(255,197,61,.24); }
.strips[data-player="2"] .strip.aimed { background: rgba(62,123,250,.34); }
/* --c は1マスの大きさ（盤の大きさで変わる。7×7 で 32px）。駒や穴はこれに比例させる */
.hole { position: absolute; left: 0; top: 0; width: calc(var(--c) * .6875); height: calc(var(--c) * .6875); border-radius: 50%; background: var(--hole); }
.labels { position: absolute; inset: 0; pointer-events: none; }
.label { position: absolute; width: 18px; height: 16px; line-height: 16px; text-align: center; font-size: max(8px, calc(var(--c) * .34)); font-weight: 700; color: #8C9BB8; transition-property: transform; transition-timing-function: ease-in-out; }
.labels[data-active="col"] .label.col,
.labels[data-active="row"] .label.row,
.labels[data-active="both"] .label { color: var(--sub); font-weight: 800; }
.labels[data-player="1"] .label.aimed { color: var(--gold); }
.labels[data-player="2"] .label.aimed { color: var(--blue-text); }
.bar { position: absolute; border-radius: 999px; animation: fade-in .2s ease-out both; }
.bar.p1 { background: rgba(255,197,61,.18); border: 2px solid var(--gold); }
.bar.p2 { background: rgba(62,123,250,.22); border: 2px solid var(--blue-text); }
.bar.warn { background: rgba(255,122,89,.16); border: 2px dashed var(--warn); }
.piece { position: absolute; left: 0; top: 0; width: calc(var(--c) * .8125); height: calc(var(--c) * .8125); transition-property: transform; transition-timing-function: cubic-bezier(.55, 0, 1, .45); }
.disc { position: relative; width: 100%; height: 100%; border-radius: 50%; }
.disc::before { content: ''; position: absolute; border-radius: 50%; }
.piece.p1 .disc { background: var(--gold); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 0 12px rgba(255, 197, 61, .45); }
.piece.p1 .disc::before { left: 23%; top: 23%; width: 54%; height: 54%; border: max(1.5px, calc(var(--c) * .0625)) solid #FFF0C2; box-sizing: border-box; }
.piece.p2 .disc { background: var(--blue); box-shadow: inset 0 -3px 0 rgba(0,0,0,.22), 0 0 12px rgba(62, 123, 250, .5); }
.piece.p2 .disc::before { left: 34.6%; top: 34.6%; width: 30.8%; height: 30.8%; background: #BCD2FF; }
.piece.moved .disc::after { content: ''; position: absolute; left: -15%; top: -15%; width: 130%; height: 130%; box-sizing: border-box; border-radius: 50%; border: 2px dashed #C9D3E3; }
.piece.landed .disc { animation: pop .28s ease-out; }
.piece.last .disc { box-shadow: inset 0 -3px 0 rgba(0,0,0,.2), 0 0 0 2px var(--plate), 0 0 0 4px var(--text), 0 0 14px rgba(238, 242, 248, .35); }
/* 対局の盤のまわりの細い金の外輪とメモリ（app.js が作る）。回らない盤（重力なし・回す回数 0）では、輪と一緒に出さない */
.outer-ring { position: absolute; left: 0; top: 0; width: 364px; height: 432px; overflow: visible; pointer-events: none; }
.stage.free .outer-ring, .stage.still .outer-ring { display: none; }
.piece.lit .disc { animation: lit .45s ease-out both; outline: 2px solid var(--text); outline-offset: 2px; }

.aim { position: absolute; inset: 0; pointer-events: none; }
.aim.p1 { --aim: var(--gold); }
.aim.p2 { --aim: var(--blue); }
.aim-guide { position: absolute; top: 44px; width: 0; border-left: 2px dashed var(--aim); }
.aim-land { position: absolute; width: calc(var(--c) * .94); height: calc(var(--c) * .94); border-radius: 50%; border: 2px dashed var(--aim); }
.aim-piece { position: absolute; top: 57px; width: 30px; height: 30px; border-radius: 50%; background: var(--aim); box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
/* 重力なし：置くマスに、点線の輪だけを出す（溝の点線と、上の駒は出さない） */
.aim.free .aim-guide, .aim.free .aim-piece { display: none; }
.aim.free .aim-land { background: color-mix(in srgb, var(--aim) 22%, transparent); }
.piece.placed .disc { animation: place-in .2s ease-out; }
@keyframes place-in { 0% { transform: scale(.4); opacity: .4; } 70% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }
/* ひっくり返す列を選んでいるとき：その列を点線の帯で囲む（縦・横・斜めどれでも） */
.line-hi { position: absolute; border-radius: 999px; border: 2px dashed var(--text); pointer-events: none; }
.line-hi.p1 { background: rgba(255,197,61,.18); border-color: var(--gold); }
.line-hi.p2 { background: rgba(62,123,250,.24); border-color: var(--blue-text); }

/* 列をひっくり返す回転（Spin のように、端と端が入れかわる向きにくるくる回る） */
.spinner { position: absolute; width: 0; height: 0; z-index: 3; }
.lift { position: absolute; left: 0; top: 0; transition: transform .18s ease-out; }
.lift.up { transform: scale(1.1); }
.wheel { position: absolute; left: 0; top: 0; transform-style: preserve-3d; transition-property: transform; transition-timing-function: cubic-bezier(.12, .7, .22, 1); }
.wheel-face { position: absolute; border-radius: 999px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.wheel-face.front { background: #2B3B5E; box-shadow: 0 0 0 2px #4A5E8C, 0 12px 24px rgba(0,0,0,.5); }
.wheel-face.back { background: #4A3570; box-shadow: 0 0 0 2px #8B6FC8, 0 12px 24px rgba(0,0,0,.5); transform: rotateY(180deg); }
.wheel .piece { transition: none; backface-visibility: hidden; -webkit-backface-visibility: hidden; }

/* ひっくり返しの結果の札 */
.stamp { position: absolute; z-index: 5; transform: translate(-50%, -50%); padding: 4px 14px; border-radius: 999px; background: var(--text); color: var(--ground); font-family: 'Dela Gothic One', sans-serif; font-size: 22px; line-height: 1.4; white-space: nowrap; pointer-events: none; box-shadow: 0 6px 16px rgba(0,0,0,.45); animation: stamp 1.1s ease-out both; }
.stamp.strong { background: #8B6FC8; color: #fff; }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  28% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes lit { 0% { transform: scale(1); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- ダイアログ ---------- */
.dialog { width: min(400px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 20px; background: var(--card); color: var(--text); padding: 20px; }
.dialog::backdrop { background: rgba(5, 9, 18, .7); }
.dialog h2 { margin: 0 0 12px; font-family: 'Dela Gothic One', sans-serif; font-weight: 400; font-size: 22px; }
.rules { margin: 0 0 12px; padding-left: 1.4em; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.6; }
.rules strong { color: var(--gold); font-weight: 800; }
.dialog-note { margin: 0 0 16px; font-size: 12px; line-height: 1.6; color: var(--sub); }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
/* シェア */
.share-preview { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--ground); border: 1px solid var(--line); font-size: 14px; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.share-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
/* App Check（reCAPTCHA v3）の右下の印は出さない。かわりに、規約とロビーに「reCAPTCHA で守っています」と書く（4．公開.md の「App Check」） */
.grecaptcha-badge { visibility: hidden; }
/* スタンプ：盤の右下のすみのボタン・選ぶ窓・名前カードの吹き出し */
.stamp-open { position: absolute; right: 2px; bottom: 2px; z-index: 4; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.stamp-open:disabled { opacity: .45; cursor: default; }
.stamp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.stamp-grid .btn { height: 48px; font-size: 16px; font-weight: 800; }
.stamp-mute { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; color: var(--sub); }
.stamp-mute input { width: 18px; height: 18px; accent-color: var(--gold); }
.stamp-bubble { position: absolute; left: 50%; top: calc(100% + 8px); z-index: 6; transform: translateX(-50%); padding: 6px 14px; border-radius: 14px; background: var(--text); color: var(--ground); font-size: 15px; font-weight: 800; white-space: nowrap; pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); animation: stamp-in .25s ease-out both; }
.stamp-bubble::before { content: ''; position: absolute; left: 50%; top: -6px; margin-left: -6px; border: 6px solid transparent; border-top: none; border-bottom-color: var(--text); }
.stamp-bubble.p1 { box-shadow: 0 0 0 2px var(--gold), 0 4px 14px rgba(0, 0, 0, .35); }
.stamp-bubble.p2 { box-shadow: 0 0 0 2px var(--blue-text), 0 4px 14px rgba(0, 0, 0, .35); }
.stamp-bubble.out { animation: stamp-out .3s ease-in both; }
@keyframes stamp-in { from { opacity: 0; transform: translate(-50%, -6px) scale(.8); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes stamp-out { to { opacity: 0; transform: translate(-50%, -4px); } }
@media (prefers-reduced-motion: reduce) { .stamp-bubble, .stamp-bubble.out { animation-duration: .01s; } }
/* 決着の盤の画像：小さく見せて、送る・保存のボタン */
.share-image { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; margin: 0 0 12px; }
.share-image img { display: block; width: 96px; aspect-ratio: 4 / 5; border-radius: 10px; border: 1px solid var(--line); background: var(--ground); object-fit: cover; }
.share-image-buttons { display: flex; flex-direction: column; gap: 8px; }
.share-image-buttons .btn { height: 44px; font-size: 14px; }
.share-buttons .btn-wide { grid-column: 1 / -1; }
.share-buttons .btn { height: 48px; padding: 0 8px; font-size: 14px; }
.share-x { background: #000; color: #fff; border: 1px solid #3A4A6A; }
.share-line { background: #06C755; color: #fff; }
.share-fb { background: #1877F2; color: #fff; }
.result-share { height: 44px; font-size: 14px; }
/* 予告「なし」で回すボタンの1回目：「もう一度押すと回す」（3秒） */
.rotate-button.armed { border-color: var(--gold); background: rgba(255, 197, 61, .16); color: var(--gold); }
/* ランキング戦の持ち時間：のこり10秒で、いまの番の名前カードを赤く */
.player-card.hurry { border-color: var(--warn) !important; }
#card-1.hurry .badge, #card-2.hurry .badge { background: var(--warn); color: #1A0A05; }
.ask-sheet { border-color: var(--gold); }
/* 決着の欄（2026-11-12）：上の段に「そのまま遊ぶ」「カスタマイズして遊ぶ」、下の段に「タイトルへ」「結果をシェア」 */
.result-play .btn { height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0 8px; font-size: 15px; }
.result-more .btn { height: 44px; font-size: 14px; padding: 0 4px; }
.result-more { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.result-more:has(> #replay-button[hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* はじめての人の練習 */
.coach-sheet { border-color: var(--gold); gap: 8px; }
.coach-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.coach-step { flex-shrink: 0; font-size: 12px; font-weight: 800; color: var(--gold); }
.coach-title { min-width: 0; flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coach-quit { flex-shrink: 0; min-height: 32px; font-size: 12px; }
.coach-text { margin: 0; font-size: 14px; line-height: 1.7; }
.coach-sheet.done .coach-text { color: var(--text); }
.coach-buttons:has(> #coach-alt[hidden]) { grid-template-columns: minmax(0, 1fr); }
.coach-buttons .btn { height: 46px; }
.rules-practice { margin-bottom: 10px; }
/* 対局のふり返り */
.replay-sheet { gap: 8px; padding: 12px 14px; }
.replay-head { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.replay-count { flex-shrink: 0; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--gold); }
.replay-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--sub); }
.replay-range { width: 100%; margin: 0; accent-color: var(--gold); height: 24px; }
.replay-buttons { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.replay-buttons .btn { height: 44px; padding: 0; display: grid; place-items: center; }
.replay-sheet .btn-wide { height: 40px; font-size: 14px; }
/* 「カスタマイズして遊ぶ」は10文字。幅の狭いスマホでも1行に収まるよう、画面の幅に合わせて字を少し小さく */
#custom-again-button { white-space: nowrap; font-size: clamp(12px, 3.7vw, 15px); letter-spacing: -.01em; }
.result-play:has(> #custom-again-button[hidden]) { grid-template-columns: minmax(0, 1fr); }

/* ---------- 横長の画面（パソコン・スマホを横にしたとき）：盤を左に大きく、情報とボタンを右に ----------
   盤の列の幅 --bw は、画面の高さから決める（盤の縦横は 364:432）。横が足りなければ横に合わせる。
   盤と右の欄をくっつけて、2つまとめて真ん中に置く（広い画面で、盤と欄のあいだが空かないように） */
@media (min-width: 640px) and (orientation: landscape) {
  /* 上の帯は5列ぜんぶ（画面の幅いっぱい）。盤と右の欄は、まんなかの3列（盤・すきま・欄）にまとめて置く。
     --ratio は映す範囲の横÷縦（app.js の fitBoard が入れる）。縦 = 画面の高さ − 上下の余白 36 − 上の帯 44 − すきま 14 */
  /* 右の欄の幅 --side は、盤（高さで決まる幅 --bwh）の残りの幅から 300〜440。盤は高さで決まるので、欄を広げても小さくならない
     （2026-10-24：欄が 24vw だと、1366 の画面で名前カードの字が切れていた） */
  .screen.game-screen {
    --gap: 32px;
    --bwh: calc((100vh - 94px) * var(--ratio, .9846));
    --bwh: calc((100dvh - 94px) * var(--ratio, .9846));
    --side: clamp(300px, calc(100vw - var(--bwh) - var(--gap) - 48px), 440px);
    --bw: min(var(--bwh), calc(100vw - var(--side) - var(--gap) - 48px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--bw) var(--gap) var(--side) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto auto 1fr;
    grid-template-areas: "top top top top top" ". board . players ." ". board . status ." ". board . controls ." ". board . sheet ." ". board . forecast ." ". board . . .";
    column-gap: 0;
    row-gap: 14px;
    padding: 16px 24px 20px;
  }
  .topbar { grid-area: top; }
  .players { grid-area: players; }
  .status { grid-area: status; justify-content: flex-start; text-align: left; flex-wrap: wrap; }
  .board-area { grid-area: board; }
  .action-row { grid-area: controls; }
  #preview-sheet, #result-sheet, #direction-sheet, #select-sheet, #left-sheet, #replay-sheet, #coach-sheet { grid-area: sheet; }
}
/* スマホを横にしたときなど、高さが低い横長の画面：すきまを詰め、操作の説明は省く */
@media (min-width: 640px) and (orientation: landscape) and (max-height: 560px) {
  .screen.game-screen {
    --gap: 20px;
    --bwh: calc((100vh - 66px) * var(--ratio, .9846));
    --bwh: calc((100dvh - 66px) * var(--ratio, .9846));
    --side: clamp(260px, calc(100vw - var(--bwh) - var(--gap) - 24px), 440px);
    --bw: min(var(--bwh), calc(100vw - var(--side) - var(--gap) - 24px));
    row-gap: 8px;
    padding: 6px 12px 8px;
  }
  /* 回す向き・ひっくり返す列を選ぶ欄、結果や予告の欄も詰めて、右の欄が下にはみ出さないように */
  .game-screen .direction-grid button, .game-screen .direction-grid .dir-center, .game-screen .axis-grid button { height: 38px; }
  .game-screen .sheet .btn { height: 40px; }
  .game-screen .result-play .btn { height: 46px; }
  .game-screen .player-card { padding: 6px 12px; }
  .game-screen .sheet { padding: 10px 12px; gap: 6px; }
  .game-screen .result-sheet { padding: 10px 14px; }
}

/* スマホを横にしたとき（パソコンの2列にならない横長）：はじめの画面は、盤を左・ボタンを右に */
/* （下のスマホ縦の決まりより後ろにあるので、.title-screen を付けて強くしている） */
@media (max-width: 899px) and (orientation: landscape) {
  .screen.title-screen { max-width: none; }
  .title-screen .title-hero { flex-direction: row; justify-content: center; align-items: center; gap: 24px; }
  .title-screen .title-board { margin: 0; }
  .title-screen .title-quick { width: 300px; flex-shrink: 0; padding: 0; align-self: center; }
}

/* ---------- パソコンのタイトル：左に名前と盤、右に設定（設定はさらに左右2列） ----------
   ブラウザの上の帯で高さが減っても、スクロールなしで1画面に収まるように、設定を2列に分けて背を低くする */
@media (min-width: 900px) and (orientation: landscape) {
  .title-screen {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 40px;
    align-items: center;
    align-content: safe center;
    padding: 24px 40px;
  }
  /* 左半分：名前と盤。名前は画面の幅と高さに合わせて大きく、盤は残りの高さいっぱい（app.js の fitTitle） */
  .title-hero { display: flex; flex-direction: column; align-items: center; gap: 16px; min-width: 0; }
  .title-quick, .sheet-head, .sheet-backdrop { display: none; }
  /* 右半分：設定を1列に */
  .title-side { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 480px; justify-self: center; }
  /* パソコンはマウスで押すので、ボタンを少し低くして、縦に収める */
  .title-screen { --seg-h: 38px; }
  .title-side .segmented button { font-size: 13px; }
  .title-side .tabs button { font-size: 14px; }
  .title-side .setting { gap: 4px; }
  .reset-row { font-size: 13px; }
  .setting-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 10px; }
  /* 決着の欄の「カスタマイズして遊ぶ」から開いたとき：タイトルの盤と名前は出さず、設定だけを真ん中に（✕ で決着の欄にもどる） */
  .title-screen.sheet-full { grid-template-columns: minmax(0, 1fr); padding-top: 6px; padding-bottom: 6px; }
  .title-screen.sheet-full .title-hero { display: none; }
  .title-screen.sheet-full .sheet-head { display: flex; }
  .title-screen.sheet-full .sheet-handle { display: none; }
  .title-screen.sheet-full .title-links { display: none; }
  .title-screen.sheet-full .title-side { gap: 7px; }
  .title-screen.sheet-full .sheet-head { padding-top: 0; }
  .title-screen.sheet-full .sheet-head .sheet-title { font-size: 16px; margin: 0; }
  .title-screen.sheet-full .sheet-head .icon-button { width: 34px; height: 34px; }
  /* 回す角度：見出しをボタンの左に置いて、1段ぶんの高さで収める（縦にスクロールが出ないように） */
  .title-side .setting.inline { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); align-items: center; gap: 8px; }
}
/* 大きな画面（1600×860 以上）：左の名前と盤が大きくなるので、右の設定も、ボタンと字を大きくしてつり合わせる */
@media (min-width: 1600px) and (min-height: 860px) and (orientation: landscape) {
  .title-screen { --seg-h: 48px; column-gap: 64px; }
  .title-side { max-width: 560px; gap: 16px; }
  .title-side .setting { gap: 6px; }
  .title-side .setting-label { font-size: 14px; }
  .title-side .segmented button, .reset-row { font-size: 16px; }
  .title-side .tabs button { font-size: 17px; }
  .title-side .step-value { font-size: clamp(12px, 10.5cqw, 17px); }
  .title-side .setting-note { font-size: 15px; }
  .title-side #start-button { height: 64px; font-size: 19px; }
  .title-side .online-buttons .btn { height: 64px; font-size: 18px; }
  .title-side .consent, .title-side .link-button { font-size: 14px; }
}
/* 背の低いパソコンの画面：すきまを詰める */
@media (min-width: 900px) and (orientation: landscape) and (max-height: 640px) {
  .title-screen { padding-top: 14px; padding-bottom: 14px; --seg-h: 34px; }
  .title-side { gap: 9px; }
  /* パソコンはマウスなので、下のリンクは低くしてよい */
  .title-side .link-button { min-height: 30px; }
}

/* ---------- タブレットを縦にしたとき：1列のまま、幅を広げる ---------- */
@media (min-width: 700px) and (orientation: portrait) {
  .screen { max-width: 620px; }
  .game-screen { --col: 620px; }
  .title-board { --tb: .8; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  /* 動きを減らす設定でも、ひっくり返しの結果の札は（動かさずに）見せる */
  .stamp { animation: none; }
}

/* 重力なし：盤が回らないので、まわりの輪・目盛り・下の印は出さない（fitBoard が盤だけを大きく映す） */
.stage.free .dial, .stage.free .ring, .stage.free .pointer,
.stage.still .dial, .stage.still .ring, .stage.still .pointer { display: none; }

/* 記録（この端末だけ） */
.result-record { font-size: 13px; font-weight: 800; color: var(--text); }
.records table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 13px; }
.records th, .records td { padding: 7px 4px; border-bottom: 1px solid var(--line-soft); text-align: center; font-weight: 700; }
.records th { color: var(--sub); font-size: 12px; }
.records th:first-child, .records td:first-child { text-align: left; }
.records .records-list { margin: 0 0 14px; padding: 0; list-style: none; font-size: 13px; line-height: 1.9; }
.records .records-list b { color: var(--gold); }
/* 全国ランキング（2026-11-12） */
.result-rank { color: var(--gold); font-weight: 700; font-size: 12.5px; line-height: 1.6; }
.ranking-dialog { max-height: calc(100dvh - 32px); }
.ranking-closed { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--gold); font-size: 14px; line-height: 1.8; }
.ranking-closed a { color: var(--gold); }
.ranking-me { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.ranking-you { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--ground); border: 1px solid var(--gold); }
.ranking-you-head { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.ranking-you-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.ranking-you-label { flex-shrink: 0; font-size: 11px; font-weight: 800; color: var(--gold); }
/* 自分の欄：今月・通算・勝率を3つ並べる */
.ranking-you-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ranking-stat { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; border-radius: 10px; background: var(--card); font-variant-numeric: tabular-nums; }
.ranking-stat-label { font-size: 11px; font-weight: 800; color: var(--sub); }
.ranking-stat b { font-size: 17px; line-height: 1.3; }
.ranking-stat-rank { font-size: 12px; font-weight: 700; color: var(--gold); }
/* 表の切りかえ（今月・通算・勝率） */
.ranking-board { display: flex; flex-direction: column; gap: 8px; }
.ranking-tabs button { height: 38px; }
.ranking-caption { margin: 0; font-size: 12px; line-height: 1.5; color: var(--sub); }
.rk-wins small { margin-left: 6px; font-size: 11px; font-weight: 700; color: var(--sub); }
.ranking-you-buttons { display: flex; gap: 4px; margin: -4px -10px -10px; }
.ranking-you-buttons .link-button { min-height: 36px; font-size: 12px; }
.ranking-form .dialog-note { margin: 6px 0 0; }
.ranking-form .code-row input { font-size: 16px; letter-spacing: 0; }
.ranking-list { list-style: none; margin: 0 0 12px; padding: 0; max-height: 46dvh; overflow-y: auto; border-radius: 12px; background: var(--ground); }
.ranking-list li { display: grid; grid-template-columns: 2.6em minmax(0, 1fr) auto 30px; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--line-soft, #24324F); font-size: 14px; }
/* 名前を知らせる旗（押しやすいよう 30×30。ふだんは目立たない色） */
.rk-report { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: none; border-radius: 8px; background: none; color: var(--sub); cursor: pointer; opacity: .55; }
.rk-report:hover, .rk-report:focus-visible { opacity: 1; color: var(--warn-text); background: rgba(255, 255, 255, .06); }
.rk-report svg { width: 16px; height: 16px; }
.ranking-list li:last-child { border-bottom: none; }
.ranking-list li.mine { background: rgba(255, 197, 61, .12); }
.ranking-list li.ranking-empty { display: block; color: var(--sub); text-align: center; padding: 18px 12px; }
.rk-rank { font-family: 'Dela Gothic One', sans-serif; font-size: 15px; color: var(--sub); text-align: center; }
.rk-rank.top1 { color: var(--gold); font-size: 18px; }
.rk-rank.top2 { color: #D6DEEA; font-size: 17px; }
.rk-rank.top3 { color: #E0A36A; font-size: 16px; }
.rk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.rk-wins { font-weight: 800; font-variant-numeric: tabular-nums; }
/* 規約の改定のお知らせ（タイトルの「同意」の文のあと） */
.consent .terms-notice { margin: -12px -2px -12px 6px; color: var(--gold); font-weight: 800; }

/* はじめての人へ（ルールの上の一言） */
.rules-first { margin: 0 0 10px; font-size: 14px; font-weight: 800; color: var(--gold); }
.search-help { align-self: stretch; display: flex; flex-direction: column; gap: 10px; }

/* 押した手ごたえ（押すと少し沈んで明るくなる）と、ダブルタップで拡大しないように */
.btn, .rotate-button, .icon-button, .step, .reset-row, .segmented button, .axis-grid button, .direction-grid button, .link-button { touch-action: manipulation; transition: transform .08s, filter .08s; }
:is(.btn, .rotate-button, .icon-button, .step, .reset-row, .segmented button, .axis-grid button, .direction-grid button):not(:disabled):active { transform: scale(.97); filter: brightness(1.2); }
@media (hover: hover) and (pointer: fine) {
  :is(.btn, .rotate-button, .icon-button, .step, .reset-row, .segmented button, .axis-grid button, .direction-grid button):not(:disabled):hover { filter: brightness(1.12); }
}

/* スマホ（縦）とタブレット：「はじめる」（オンラインでは「部屋を作る」「世界の人と」）を画面の下に残す（設定が多くても、スクロールせずに始められるように） */
@media (max-width: 899px), (orientation: portrait) {
  /* はじめの画面は、盤と「遊ぶ」「カスタマイズ」だけ（スクロールしない）。盤は画面の左右のはしまで使い、
     大きさは app.js の fitTitle が、ボタンの上に残った高さに合わせる */
  .title-hero { flex: 1 1 auto; align-self: stretch; justify-content: space-between; margin: 0 -20px; overflow: hidden; }
  .title-board { margin: auto 0; }
  .title-quick { padding: 0 20px; }
  /* 設定は「カスタマイズ」で下から出てくる板（.sheet-open のとき） */
  .title-side { --sheet: #131C2E; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; max-height: calc(100% - 56px); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 620px; margin: 0 auto; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--sheet); border: 1px solid #2A3854; border-bottom: none; border-radius: 22px 22px 0 0; transform: translateY(105%); visibility: hidden; transition: transform .28s ease, visibility 0s .28s; }
  .title-screen.sheet-open .title-side { transform: none; visibility: visible; transition: transform .28s ease; }
  .title-screen.sheet-open .sheet-backdrop { opacity: 1; visibility: visible; transition: opacity .2s; }
  /* 決着の欄の「カスタマイズして遊ぶ」から開いたとき：板を画面いっぱいに（後ろのタイトルの盤や名前は見せない） */
  .title-screen.sheet-full .title-side { max-height: 100%; height: 100%; border-radius: 0; border: none; padding-top: calc(10px + env(safe-area-inset-top)); }
  .title-screen.sheet-full .sheet-backdrop { background: var(--ground); }
  .title-screen.sheet-full .sheet-handle { display: none; }
  /* 板の中の「はじめる」（オンラインは「部屋を作る」「世界の人と」）は、板の下に残す */
  .play-actions { position: sticky; bottom: 0; z-index: 3; border-radius: 14px; background: var(--sheet); box-shadow: 0 -14px 18px 6px var(--sheet), 0 6px 0 10px var(--sheet); }
}
@media (prefers-reduced-motion: reduce) {
  .thinking i { animation: none; opacity: .8; }
}
