/* 試合機能（得点ボード・履歴・ダイアログ・配信ビュー）のスタイル */

/* ---------------- 得点ボード ---------------- */
#scoreboard {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  background: rgba(13, 20, 28, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 6px 10px;
  backdrop-filter: blur(6px);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  max-width: calc(100% - 80px);
  --sb-name-w: 96px;
}

#scoreboard:empty { display: none; }

.sb-row {
  display: grid;
  /* 名前列は固定幅。各行が独立したグリッドなので max-content にすると行ごとに幅が変わり列がずれる */
  grid-template-columns: 12px var(--sb-name-w, 96px) 14px repeat(var(--ends, 8), var(--sb-cell, 18px)) 28px auto;
  column-gap: 4px;
  align-items: center;
  height: 22px;
}

.sb-row.head { height: 16px; color: var(--text-dim); font-size: 10px; }
.sb-row.head .sb-swatch { visibility: hidden; }

/* 現在のエンド・投球の簡潔表示。通常時は隠し、コンパクトのときだけ縦に出す */
.sb-cstatus { display: none; }
#scoreboard.compact .sb-cstatus {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 3px;
  font-variant-numeric: tabular-nums;
}
/* タップでコンパクト表示: エンド別・見出し・タイトル・状況・投球者は隠し、合計だけ残す */
#scoreboard.compact .sb-title,
#scoreboard.compact .sb-row.head,
#scoreboard.compact .sb-cell,
#scoreboard.compact .sb-hammer,
#scoreboard.compact .sb-status,
#scoreboard.compact .sb-dots { display: none; }
#scoreboard.compact .sb-row { grid-template-columns: 14px 1fr auto; column-gap: 8px; height: 24px; }
#scoreboard.compact .sb-total { font-size: 18px; }
/* 両チームとも同じ内側余白・角丸にして、カプセルの有無で文字位置がずれないようにする */
#scoreboard.compact .sb-name {
  justify-self: start;
  padding: 1px 8px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px transparent;
}
/* コンパクトでは、ハンマー（最終投の権利＝攻め）を持つチーム名を強調して攻守を示す */
#scoreboard.compact .sb-row.has-hammer .sb-name {
  background: var(--accent-wash);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(108, 192, 255, 0.35);
}
#scoreboard.compact .sb-row:not(.has-hammer) .sb-name { color: var(--text-dim); }

.sb-row.team.next .sb-name { color: #fff; }

.sb-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-dim);
  max-width: 100%;
  margin-bottom: 2px;
}

.sb-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.25) inset;
}

.sb-name {
  max-width: 100%;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-hammer { font-size: 11px; text-align: center; }

.sb-cell {
  width: var(--sb-cell, 18px);
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  border-radius: 4px;
}

.sb-cell.scored { color: #fff; font-weight: 700; }
.sb-cell.current { background: rgba(59, 154, 225, 0.25); color: #74c0fc; }
.sb-cell.unplayed { color: #868e96; }
.sb-cell.head { font-size: 10px; }

.sb-total {
  text-align: right;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sb-total.head { font-size: 10px; font-weight: 600; }

.sb-dots {
  display: flex;
  gap: 2px;
  margin-left: 4px;
}

.sb-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
}

.sb-dots i.on { background: var(--c); }

/* いま投げている石。TV 中継のように、チーム色と消灯を繰り返して点滅させる */
.sb-dots i.throwing { animation: sb-throwing 1s steps(1, end) infinite; }
@keyframes sb-throwing {
  0%, 50% { background: var(--c); }
  50.01%, 100% { background: rgba(255, 255, 255, 0.15); }
}

/* 見出し行のダミー: 幅だけ確保して列をそろえる */
.sb-dots.ghost { visibility: hidden; }

.sb-status {
  margin-top: 3px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.sb-endbtn {
  margin-left: auto;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  cursor: pointer;
}

/* スコアチップは得点ボードの下へ */
#score-chip { top: auto; bottom: 12px; left: 10px; }
#info-chip { top: auto; bottom: 52px; left: 10px; right: auto; }

/* チームボタンの色見本 */
.team-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--team-color, #888);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.2) inset;
}

.team-btn.active { border-color: var(--team-color); background: color-mix(in srgb, var(--team-color) 16%, transparent); color: #fff; }

/* ---------------- シーンバナー ---------------- */
#scene-banner {
  position: absolute;
  top: 10px;
  right: 64px;
  z-index: 3;
  display: flex;
  flex-direction: column;   /* テキストを上、ボタンを下の2段に */
  align-items: flex-start;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(255, 196, 25, 0.95);
  color: #1c2733;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  max-width: calc(100% - 80px);
}
#scene-banner #banner-text { padding: 0 2px; }
#scene-banner .banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
#scene-banner .mini { padding: 4px 8px; display: inline-flex; align-items: center; gap: 4px; }
#scene-banner .ic-mini {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* リプレイ読み込み直後の「再生」プロンプト（自動再生の代わり） */
#replay-start {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(14, 20, 27, 0.5);
}
#replay-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 30px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#replay-start-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(0,0,0,0.55); }
#replay-start-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#replay-start-btn .rs-icon { font-size: 20px; line-height: 1; }
#replay-start .rs-hint {
  margin: 0;
  color: rgba(255,255,255,0.9);
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

/* リプレイの中継風テロップ（今の投球: 種別・評価・選手・チーム成功率）。控えめな小型 */
#shot-info {
  position: absolute;
  left: 50%;
  bottom: 70px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(13, 20, 28, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
  max-width: calc(100% - 20px);
  font-size: 11px;
  opacity: 0.92;
  --si-team: #888;
}
#shot-info .si-team {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--si-team);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.02em;
  /* 黄色など明るいチーム色でも白文字が読めるよう、縁取り＋ドロップシャドウ */
  text-shadow:
    -0.5px -0.5px 0 rgba(0, 0, 0, 0.55), 0.5px -0.5px 0 rgba(0, 0, 0, 0.55),
    -0.5px 0.5px 0 rgba(0, 0, 0, 0.55), 0.5px 0.5px 0 rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.45);
}
#shot-info .si-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  padding: 3px 10px;
  min-width: 0;
}
#shot-info .si-player { font-weight: 700; color: #fff; font-size: 12px; white-space: nowrap; line-height: 1.25; }
#shot-info .si-shot { display: flex; gap: 6px; align-items: baseline; color: var(--text-dim); font-size: 10px; line-height: 1.2; }
#shot-info .si-pct { font-weight: 700; color: #fff; }
#shot-info .si-cum {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}
#shot-info .si-cum-lbl { font-size: 9px; color: var(--text-dim); letter-spacing: 0.03em; }
#shot-info .si-cum-val { font-size: 14px; font-weight: 800; color: #fff; line-height: 1.1; }
body.broadcast #shot-info { bottom: 60px; }   /* トーストと重なりにくいよう少し上げる */
/* 中継テロップ（字幕）はショット評価が要るリプレイ専用。ゲーム／ライブでは字幕ボタンを出さない */
body:not(.replay-mode) #telop-btn { display: none !important; }

button.mini {
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.12);
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
}

button.mini.primary { background: #1c2733; color: #fff; }

/* ---------------- ダイアログのタブ ---------------- */
.dialog-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 999px;
}

.dtab {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  flex: 0 0 auto;        /* 縮ませない。狭い画面ではタブ列ごと横スクロールさせる */
  white-space: nowrap;   /* 「ライブラリ」が縦積みに折り返さないように */
}

.dtab.active { background: var(--accent); color: #fff; }

.dpanel { display: flex; flex-direction: column; gap: 12px; }

/* 高さを固定して、タブを切り替えても本体がスクロールするだけで大きさが変わらない。
   display は [open] のときだけ付ける（付けっぱなしだと閉じても表示され続けるため） */
#menu-dialog { width: min(94vw, 640px); height: min(86dvh, 700px); }
#menu-dialog[open] { display: flex; flex-direction: column; }
#menu-dialog .dialog-body { flex: 1; min-height: 0; }
/* 写真から配置は作業領域が要るので大きく */
#photo-dialog { width: min(96vw, 960px); }
#end-dialog, #concede-dialog, #help-dialog { width: min(92vw, 460px); }

/* フォーム */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

.form-grid label, .team-form-head, .players {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.form-grid label.wide { grid-column: 1 / -1; }

.form-grid input, .form-grid select, .team-form input[type="text"], .players input, .end-scores input, #s-broadcast-url {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
  min-width: 0;
}

.form-grid input:focus, .team-form input:focus, .players input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.team-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.team-form {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-form-head { flex-direction: row; align-items: flex-end; gap: 8px; }
.team-form-head label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--text-dim); }
.team-form-head .f-color { align-items: center; flex-shrink: 0; }
.team-form-head .f-color input[type="color"] { width: 34px; height: 34px; border: none; background: none; padding: 0; cursor: pointer; }
.team-form-head .f-name { flex: 1; min-width: 0; }
.team-form-head .f-short { width: 76px; flex-shrink: 0; }
.team-form-head .f-short input { text-align: center; }

@media (hover: none) { .desktop-only { display: none; } }

.players { gap: 6px; }

/* コーチ・リザーブ欄（任意）。他のフォームと同じ見た目に揃える */
.staff { display: flex; flex-direction: column; gap: 6px; }
.staff label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-dim); }

/* 履歴 */
#history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 52dvh;
  overflow-y: auto;
}

.hist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  font-size: 12px;
  cursor: pointer;
}

.hist-item.active { border-color: var(--accent); background: rgba(59, 154, 225, 0.18); }
.hist-item.end { background: rgba(255,255,255,0.06); font-weight: 700; }
.hist-item.start { color: var(--text-dim); }
.hist-icon { width: 14px; text-align: center; font-size: 13px; }
.hist-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-split { color: var(--text-dim); font-variant-numeric: tabular-nums; }

.hist-type {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  font-size: 11px;
  padding: 3px 4px;
  max-width: 96px;
}

.hist-rating { display: flex; gap: 2px; }
.hist-rating button {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
}
.hist-rating button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.hist-replay {
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
}

/* 共有 */
.share-box { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.share-box h3 { font-size: 13px; }
.share-box code { font-size: 11px; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.file-btn { display: block; cursor: pointer; position: relative; }
/* hidden 属性は display:none 相当で input がタブ順から外れ、キーボードと
   スクリーンリーダーから到達できなくなる。視覚的にだけ隠し、フォーカスは
   label 側の :focus-within でリングを出す */
.file-btn input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 色プリセット */
.color-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.color-preset {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  background: var(--c);
  cursor: pointer;
  padding: 0;
}
.color-preset.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

/* 検討モード */
/* 検討モードの表示は、ハウス（上中央）とドラッグ投球の開始域（下のホッグ付近）を避け、
   右上の角に控えめなピルで置く */
#sandbox-banner {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  background: rgba(59, 154, 225, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
#sandbox-banner .mini { background: rgba(255,255,255,0.2); color: #fff; }

/* ドラッグ投球の使い方ヒント（最初だけ・ホッグ付近の下端に出す） */
#drag-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(13, 20, 28, 0.9);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-1), 0 0 0 4px rgba(59, 154, 225, 0.12);
  backdrop-filter: blur(4px);
  pointer-events: none;
}
#drag-hint .dh-arrow {
  color: var(--accent-2, #6cc0ff);
  font-size: 18px;
  line-height: 1;
  animation: dhBob 1.4s ease-in-out infinite;
}
@keyframes dhBob {
  0%, 100% { transform: translateY(2px); opacity: 0.7; }
  50% { transform: translateY(-3px); opacity: 1; }
}
body.player-open #drag-hint { bottom: 68px; }
@media (prefers-reduced-motion: reduce) {
  #drag-hint .dh-arrow { animation: none; }
  .sb-dots i.throwing { animation: none; background: var(--c); }
}
body.sandbox #scoreboard { opacity: 0.75; }

/* 効果音パネル */
.sound-box { display: flex; flex-direction: column; gap: 10px; }
.sound-tests .btn { flex: 1 1 auto; }
.sound-sliders { display: flex; flex-direction: column; gap: 6px; }
.sound-sliders label { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.sound-sliders input[type="range"] { width: 100%; accent-color: var(--accent); }
.sound-sliders b { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.sample-box { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.sample-box h4 { font-size: 12px; }

/* エンド終了 */
#end-dialog { width: min(92vw, 380px); }
/* キャンセル・コンシードは左、主アクションの「確定」は右端に寄せる */
#end-dialog .panel-row { justify-content: flex-start; }
#end-dialog .panel-row .btn { white-space: nowrap; flex: 0 0 auto; }
#end-dialog #e-confirm { margin-left: auto; padding-left: 20px; padding-right: 20px; }
.end-scores { display: flex; flex-direction: column; gap: 8px; }
.end-scores label { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.end-scores label span:nth-child(2) { flex: 1; }
.end-scores input { width: 80px; font-size: 18px; font-weight: 800; text-align: center; }

/* ---------------- 配信ビュー ----------------
   ルール: 配信ビューは送信側の「観戦者に見せる情報・演出」だけをミラーし、
   「送信側が操作するUI」は隠す。
   ・隠す（操作・編集・ナビゲーション）: topbar / panel / canvas-buttons（軌跡・比較・反転・字幕の操作）/
     player（再生バー）/ suggest-box / scene-banner
   ・表示する（情報・演出。送信側と同じに描画）: 盤面（石・軌跡・比較・反転・狙い矢印・予測）/
     scoreboard（点数表。コンパクトなら同じ）/ score-chip（現在のスコア計算）/ info-chip（ホッグ間などの情報）/
     shot-info（中継テロップ）/ toast（除外・反則など進行イベントの通知のみ。操作系は送らない）
   表示状態は applySyncMessage が送信側からミラーする
   （flip/showTrails/showCompare/showTelop/sbCompact/realMode/mode/aim/prediction/broom/toast）。 */
body.broadcast #topbar,
body.broadcast #panel,
body.broadcast #canvas-buttons,
body.broadcast #scene-banner { display: none !important; }

body.broadcast #scoreboard { cursor: default; font-size: 14px; }
body.broadcast .sb-row { height: 26px; }
body.broadcast #scoreboard { --sb-name-w: 140px; --sb-cell: 24px; }
body.broadcast .sb-total { font-size: 18px; }

/* ---------------- ライブ配信セットアップ画面 ----------------
   ライブタブは盤面（カーリングレーン）を出さず、配信（OBS）の作り方を中央に出す。
   実際の受信は配信ビュー（?view=broadcast）が行う。 */
body.live-mode #canvas-wrap > *:not(#live-setup):not(#toast) { display: none !important; }
body.live-mode #panel { display: none; }
#live-setup { display: none; }
body.live-mode #live-setup {
  display: flex;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  z-index: 4;
}
.ls-card {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 28px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.ls-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-on-accent);
  background: var(--accent);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.ls-card h2 { font-size: 20px; font-weight: 800; margin: 0 0 10px; }
.ls-card p { font-size: 13px; line-height: 1.7; color: var(--text-dim); margin: 0 0 14px; }
.ls-card strong { color: var(--text); font-weight: 700; }
.ls-steps { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.ls-steps li { font-size: 13px; line-height: 1.6; }
.ls-opts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 18px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 10px;
}
.ls-opts label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.ls-open { width: 100%; font-size: 15px; padding: 12px; }
.ls-note { font-size: 11.5px !important; margin: 14px 0 0 !important; }

/* ---------------- モバイル ---------------- */
@media (max-width: 560px) {
  #scoreboard { padding: 5px 8px; font-size: 11px; top: 8px; left: 8px; --sb-name-w: 44px; --sb-cell: 15px; }
  .sb-dots { display: none; }
  .sb-title { max-width: 120px; }
  .form-grid { grid-template-columns: 1fr; }
  .team-forms { grid-template-columns: 1fr; }
  #info-chip { bottom: 52px; }
  #scene-banner { top: 128px; left: 8px; right: auto; max-width: calc(100% - 16px); }
  #sandbox-banner { max-width: calc(100% - 16px); }
}

/* ---------------- PCN ---------------- */
#s-pcn-text {
  width: 100%;
  box-sizing: border-box;
  margin: 8px 0 6px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

/* ルールタブ・表示タブ: フォームグリッド内のトグルは横並びのまま */
.form-grid label.menu-toggle { flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; align-self: end; padding-bottom: 12px; }
.form-grid label.menu-toggle span { font-size: 12px; white-space: nowrap; }
/* .form-grid input の width:100% がチェックボックスにも効いて横に伸びるので、ここで戻す */
.form-grid label.menu-toggle input[type="checkbox"] { width: 18px; height: 18px; flex: none; }

/* ---------------- 再生コントロール ---------------- */
#player {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(13, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  /* 幅を固定して、シーン名やエンド名の文字数でバー全体が動かないようにする */
  width: min(720px, calc(100% - 20px));
  box-sizing: border-box;
}
#player button {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
}
#player button:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
#player button:disabled { opacity: 0.3; cursor: default; }
#player button.primary { background: var(--accent, #3b9ae1); color: #fff; }
#player button.primary:disabled { opacity: 0.35; }
#player select {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  font-size: 12px;
  padding: 3px 6px;
  max-width: 120px;
}
#player #pl-scene { flex: 1 1 auto; width: auto; min-width: 60px; }
#player #pl-end { flex: 0 0 auto; width: 104px; }
#player .pl-label { flex: 0 0 auto; width: 150px; font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.player-open #toast { bottom: 64px; }
body.player-open #info-chip { bottom: 64px; }
body.broadcast #player { display: none !important; }
@media (max-width: 559px) {
  #player { bottom: 8px; gap: 3px; padding: 5px 6px; width: calc(100% - 12px); }
  #player .pl-label { display: none; }
  #player #pl-end { width: 92px; }
}
body.real-mode #compare-btn { display: none; }

/* ---------------- 回転量 ---------------- */
.spin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.spin-row input[type="range"] { flex: 1; }
/* スライダーの既定値を示すトラック上のティック（ダブルクリックで既定へ戻せる） */
.range-default-tick {
  position: absolute;
  width: 2px;
  height: 14px;
  transform: translate(-50%, -50%);
  background: var(--text);
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);   /* 青いアクセント塗り・暗いトラックの両方で見えるよう縁取り */
  pointer-events: none;
  z-index: 1;
}
.spin-row b { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------- ライブラリ ---------------- */
#lib-search {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font-size: 13px;
}
.lib-event {
  margin: 12px 0 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.lib-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  margin-bottom: 6px;
}
.lib-main { flex: 1; min-width: 0; }
.lib-teams { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-score { margin: 0 6px; color: #74c0fc; font-weight: 800; font-variant-numeric: tabular-nums; }
.lib-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lib-tag { background: rgba(59,154,225,0.18); color: #74c0fc; border-radius: 999px; padding: 1px 7px; font-size: 10px; }
.lib-play { flex-shrink: 0; padding: 6px 10px; }

/* ---------------- ヘルプ・コンシード ---------------- */
.help-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-table td { padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.help-table td:first-child { width: 110px; }
.help-table kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #fff;
}
.concede-row { display: flex; gap: 8px; margin: 12px 0; }
.concede-row .btn { flex: 1; }

/* 中間幅ではバナーを点数表の下に出す（重なり防止） */
@media (max-width: 1100px) {
  #scene-banner { top: 132px; right: 10px; }
}
/* 再生バーを出している間は右下のボタン群と左下のチップを持ち上げる */
body.player-open #canvas-buttons { bottom: 64px; }
@media (max-width: 1100px) {
  #player .pl-label { display: none; }
  #player input[type="range"] { width: 110px; }
}
.spin-row > span { white-space: nowrap; }

/* ---------------- ショット提案 ---------------- */
#suggest-box {
  position: absolute;
  left: 10px;
  bottom: 100px;
  width: 300px;
  max-width: calc(100% - 90px);
  max-height: calc(100% - 200px);
  overflow-y: auto;
  z-index: 3;
  background: rgba(13, 20, 28, 0.94);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 8px 10px 4px;
  backdrop-filter: blur(6px);
  font-size: 12px;
}
#suggest-box .sg-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 6px; }
#suggest-box .sg-head button { border: none; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 14px; }
.sg-item {
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
}
.sg-item:hover, .sg-item.on { background: rgba(59,154,225,0.16); border-color: rgba(59,154,225,0.5); }
.sg-item .sg-head { display: flex; align-items: center; gap: 8px; }
.sg-item .sg-no { width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%; background: var(--accent, #3b9ae1); color: #fff; font-weight: 800; font-size: 11px; display: grid; place-items: center; }
.sg-item .sg-type { flex: 1; font-weight: 700; font-size: 13px; }
.sg-item .sg-diff { color: #ffd43b; font-size: 12px; letter-spacing: 1px; }
.sg-item .sg-detail { margin: 4px 0 5px; font-size: 12px; line-height: 1.45; color: var(--text-dim); }
.sg-item .sg-target { color: var(--text); }
.sg-item .sg-line b { color: var(--text-dim); font-weight: 600; margin-right: 4px; }
.sg-item .sg-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sg-item .sg-val { color: #74c0fc; font-variant-numeric: tabular-nums; font-size: 12px; }
.sg-item .sg-go { padding: 5px 10px; font-size: 12px; }
body.real-mode #suggest-btn, body.broadcast #suggest-box { display: none; }

/* ---------------- スポンサー画像の一覧 ---------------- */
.sp-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 12px; }
.sp-item img { width: 48px; height: 28px; object-fit: contain; background: #fff; border-radius: 4px; }
.sp-item .sp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-item input[type="range"] { width: 80px; }
.sp-item select { font-size: 11px; }

/* ---------------- 機能バッジ ---------------- */
.pro-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59f00, #e8590c);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: middle;
  align-self: flex-start;
  width: auto;
}
#canvas-buttons button .pro-badge { display: none; }
.feature-locked { opacity: 0.5; pointer-events: none; }

/* モバイル: 過去シーンのバナーを小さくして右下のボタンに重ねない */
@media (max-width: 560px) {
  #scene-banner { padding: 5px 8px; gap: 4px; font-size: 11px; max-width: calc(100% - 112px); }
  #scene-banner .mini { padding: 4px 7px; font-size: 11px; }
}

/* ---------------- 得点ボードのブロードキャスト・ポリッシュ ---------------- */
#scoreboard {
  background: linear-gradient(180deg, rgba(18,26,35,0.94), rgba(10,15,21,0.94));
  border-color: var(--hairline);
  box-shadow: var(--shadow-2);
}
.sb-title {
  position: relative;
  padding-left: 10px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}
.sb-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 3px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}
.sb-name { letter-spacing: 0.06em; }
.sb-cell { transition: color 0.15s; }
.sb-cell.current {
  background: transparent;
  color: var(--accent-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.sb-cell.scored { color: #fff; }
.sb-total { font-size: 16px; letter-spacing: -0.01em; }
.sb-row.team.next .sb-total { color: #fff; }
.sb-status { color: var(--text-dim); letter-spacing: 0.01em; }

/* ---------------- 情報タブ ---------------- */
.info-block { margin-top: 4px; }
.info-block h3 { font-size: 14px; margin-bottom: 6px; }
.info-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.6; }
.info-list a { color: var(--accent-2); }
.info-block details { border: 1px solid var(--hairline); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.info-block summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.info-block details p { margin-top: 6px; font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.info-block .btn.small { padding: 2px 10px; font-size: 12px; }
.info-foot { text-align: center; margin-top: 10px; font-size: 11px; }
/* タブが増えたので、狭い画面では横スクロール。タブ自体は縮まず（.dtab の flex: 0 0 auto）、
   右端をぼかして「まだ先がある」ことを見せる */
.dialog-tabs {
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;                    /* dialog-head の中で縮めるようにする */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;  /* 端まで来てもダイアログの外へスクロールが伝わらない */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
}
.dialog-tabs::-webkit-scrollbar { display: none; }
/* 端まで見えているときはぼかさない（スクロールできないのに切れて見えるのを防ぐ） */
.dialog-tabs.at-end {
  -webkit-mask-image: none;
  mask-image: none;
}
