/* ===========================================================================
   野球スコアブック  スタイル

   デザインは「那加二野球 成績管理アプリ」と揃えている。
   ・色は紺（--navy-*）と金（--gold）。色相は --team-hue の 1 つだけで決まる
   ・ライト / ダークは値の差し替えだけで切り替える
   ・角丸・影・イージングも同じトークンを使う
   画面はスマートフォンを基準に組み、広い画面向けの指定を後から足している。
   =========================================================================== */

:root {
  /* 画面の中身を置く幅。大きな画面では下のほうで広げている */
  --shell: 1180px;

  color-scheme: light;

  /* チームカラー（紺と金）。設定でチームカラーを選ぶとこの数字だけが変わる。
     金はメダル・強調に使うため色相を変えても固定。 */
  --team-hue: 213;

  --navy-900: hsl(var(--team-hue) 61% 10%);
  --navy-800: hsl(var(--team-hue) 58% 14%);
  --navy-700: hsl(var(--team-hue) 56% 20%);
  --navy-600: hsl(var(--team-hue) 56% 26%);
  --navy-500: hsl(var(--team-hue) 53% 35%);
  --navy-400: hsl(var(--team-hue) 39% 47%);
  --navy-300: hsl(var(--team-hue) 37% 63%);

  --gold: #c2a15c;
  --gold-soft: #e8dcc2;
  --gold-deep: #8a6d23;

  --bg: #eef1f6;
  --bg-tint: #e4e9f2;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-sunken: #f1f4f9;
  --line: #e2e7ef;
  --line-soft: #eef1f6;

  --text: #14233a;
  --text-strong: #0a1729;
  --muted: #6b7889;
  --faint: #a8b3c2;

  --accent-soft: hsl(var(--team-hue) 45% 94%);
  --gold-bg: #f6ecd6;
  --danger: #b3402c;
  --danger-bg: #fdf3f2;
  --danger-line: #e7c3bd;
  --safe: #1f7a4d;
  --safe-bg: #eff7f2;
  --safe-line: #bfdccb;

  --shadow-1: 0 1px 2px rgba(10, 23, 41, 0.04), 0 1px 3px rgba(10, 23, 41, 0.05);
  --shadow-2: 0 2px 4px rgba(10, 23, 41, 0.04), 0 10px 26px rgba(10, 23, 41, 0.07);
  --shadow-hover: 0 4px 8px rgba(10, 23, 41, 0.06), 0 16px 36px rgba(10, 23, 41, 0.1);
  --ring: 0 0 0 3px rgba(42, 86, 135, 0.18);

  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);

  /* スコアブックの紙とインク。印刷では必ず白地・黒字に戻す */
  --sb-paper: var(--surface);
  --sb-paper-2: var(--surface-2);
  --sb-ink: var(--text-strong);
  --sb-grid: var(--line);
  --sb-grid-strong: var(--navy-300);
  --sb-run: hsl(var(--team-hue) 50% 88%);

  /* 端末のノッチ・ホームバーの余白 */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --navbar-h: 62px;
}

/* OS がダークのとき（テーマ「自動」） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;

    --bg: #0b1220;
    --bg-tint: #0f1829;
    --surface: #131c2c;
    --surface-2: #182234;
    --surface-sunken: #0f1727;
    --line: #263349;
    --line-soft: #1d2839;

    --text: #e6ecf5;
    --text-strong: #f4f7fb;
    --muted: #93a1b5;
    --faint: #5e6c80;

    --navy-300: hsl(var(--team-hue) 43% 69%);
    --accent-soft: hsl(var(--team-hue) 42% 18%);
    --gold-bg: rgba(51, 41, 19, 0.55);
    --gold-deep: #d9bd7c;
    --danger: #e88370;
    --danger-bg: #2a1614;
    --danger-line: #4a2622;
    --safe: #6cc79a;
    --safe-bg: #10281d;
    --safe-line: #24503a;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.3), 0 12px 30px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 6px 12px rgba(0, 0, 0, 0.35), 0 20px 44px rgba(0, 0, 0, 0.45);
    --ring: 0 0 0 3px rgba(120, 165, 220, 0.28);

    --sb-grid-strong: hsl(var(--team-hue) 25% 45%);
    --sb-run: hsl(var(--team-hue) 40% 24%);
  }
}

/* 手動でダークを選んだとき */
:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: #0b1220;
  --bg-tint: #0f1829;
  --surface: #131c2c;
  --surface-2: #182234;
  --surface-sunken: #0f1727;
  --line: #263349;
  --line-soft: #1d2839;

  --text: #e6ecf5;
  --text-strong: #f4f7fb;
  --muted: #93a1b5;
  --faint: #5e6c80;

  --navy-300: hsl(var(--team-hue) 43% 69%);
  --accent-soft: hsl(var(--team-hue) 42% 18%);
  --gold-bg: rgba(51, 41, 19, 0.55);
  --gold-deep: #d9bd7c;
  --danger: #e88370;
  --danger-bg: #2a1614;
  --danger-line: #4a2622;
  --safe: #6cc79a;
  --safe-bg: #10281d;
  --safe-line: #24503a;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.3), 0 12px 30px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 6px 12px rgba(0, 0, 0, 0.35), 0 20px 44px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(120, 165, 220, 0.28);

  --sb-grid-strong: hsl(var(--team-hue) 25% 45%);
  --sb-run: hsl(var(--team-hue) 40% 24%);
}

/* チームの基調色。ダークの指定より後ろに置き、明暗どちらでも効かせる */
:root[data-team='forest']  { --team-hue: 152; }
:root[data-team='crimson'] { --team-hue: 350; }
:root[data-team='royal']   { --team-hue: 232; }
:root[data-team='teal']    { --team-hue: 190; }
:root[data-team='purple']  { --team-hue: 278; }
:root[data-team='umber']   { --team-hue: 25; }

/* ===========================================================================
   土台
   =========================================================================== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden], .hidden { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-bottom: calc(var(--navbar-h) + var(--safe-b));
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overscroll-behavior-y: none;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===========================================================================
   ヘッダー
   =========================================================================== */
.page-header {
  position: relative;
  padding: calc(14px + var(--safe-t)) 14px 12px;
  border-bottom: 1px solid var(--gold);
  background:
    radial-gradient(130% 170% at 88% 0%, rgba(194, 161, 92, 0.16) 0%, transparent 55%),
    linear-gradient(120deg, var(--navy-900) 0%, var(--navy-800) 48%, var(--navy-700) 100%);
}
.header-inner {
  position: relative;
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo {
  height: 34px; width: auto; display: block;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(194, 161, 92, 0.45);
  box-shadow: 0 6px 20px rgba(5, 12, 22, 0.5);
}
.brand-mark {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(194, 161, 92, 0.45);
  background: rgba(255, 255, 255, 0.06);
  font-size: 17px;
}
.brand-text { min-width: 0; }
.page-header h1 {
  margin: 0; color: #fff;
  font-size: 16px; font-weight: 600; letter-spacing: 0.06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 10px rgba(5, 12, 22, 0.65);
}
/* 狭い画面では、ロゴ（チーム名入り）と英字だけにする。
   成績管理アプリのヘッダーと同じ収め方にして、行き来しても跳ねないようにする */
@media (max-width: 900px) {
  .page-header h1 { display: none; }
}

.header-sub {
  margin: 1px 0 0; color: var(--gold);
  font-size: 9px; font-weight: 600; letter-spacing: 0.26em;
  text-shadow: 0 1px 8px rgba(5, 12, 22, 0.8);
}
.header-tools { display: flex; align-items: center; gap: 8px; flex: none; }

/* すりガラス調の操作。別アプリのヘッダーと同じ見た目 */
.glass-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 23, 41, 0.55);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  color: #fff;
  font-family: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.12s var(--ease);
}
.glass-btn:hover { background: rgba(29, 64, 104, 0.7); border-color: rgba(255, 255, 255, 0.4); }
.glass-btn:active { transform: translateY(1px); }
.glass-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(194, 161, 92, 0.45); }
.theme-icon { font-size: 14px; line-height: 1; }

/* 成績管理アプリへ移るボタン。下のタブの「成績」（この試合の成績）と
   区別が付くよう、⇄ と「アプリ」を添えてある */
.app-switch { text-decoration: none; }
/* 圏外のとき。押せないことが見て分かるようにする */
.app-switch.is-off { opacity: 0.45; }
.as-icon { font-size: 13px; line-height: 1; }
.as-label { white-space: nowrap; }
.theme-label { display: none; }

/* 広い画面のときだけ出す上部タブ */
.top-tabs { display: none; }

/* ===========================================================================
   画面
   =========================================================================== */
.screen { display: none; }
.screen.is-active { display: block; }
.wrap { max-width: var(--shell); margin: 0 auto; padding: 14px 14px 28px; }
/* スコアシートは用紙なので、広い画面では目いっぱい使う */
#screen-book .wrap { max-width: 1560px; }

.sec-title {
  display: flex; align-items: center; gap: 9px;
  margin: 20px 0 12px; padding-bottom: 10px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-strong);
  border-bottom: 1px solid var(--line);
}
.sec-title::before {
  content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--gold);
}
.wrap > .sec-title:first-child { margin-top: 4px; }
/* 見出しの右端に置くボタン（先攻と後攻の入れ替え）。
   見出しそのものが flex なので、右へ寄せるだけでよい */
.sec-title .btn-swap {
  margin-left: auto; padding: 6px 11px; font-size: 11px; letter-spacing: 0.04em;
}

.card {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.hint { font-size: 11px; color: var(--muted); margin: 10px 0 0; letter-spacing: 0.02em; }
.hint-flush { margin: 0; }

/* 成績管理アプリへの書き出し画面 */
.exp-preview { margin-top: 10px; }
.exp-copy-btn { margin-top: 8px; }
.hint-warn {
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--gold-bg); border: 1px solid var(--gold); color: var(--gold-deep); font-weight: 700;
}

/* ===========================================================================
   ボタン
   =========================================================================== */
.btn {
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-family: inherit; font-weight: 600; letter-spacing: 0.06em;
  white-space: nowrap; cursor: pointer;
  transition: background 0.18s var(--ease), box-shadow 0.18s var(--ease),
              transform 0.12s var(--ease), border-color 0.18s var(--ease);
}
.btn:hover { border-color: var(--navy-300); color: var(--text-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); color: var(--text); }

.btn-primary {
  background: linear-gradient(160deg, var(--navy-600) 0%, var(--navy-800) 100%);
  border-color: transparent; color: #fff;
  box-shadow: var(--shadow-1);
}
.btn-primary:hover {
  background: linear-gradient(160deg, var(--navy-500) 0%, var(--navy-700) 100%);
  box-shadow: 0 4px 14px rgba(15, 33, 56, 0.3);
  color: #fff;
}
.btn-danger { color: var(--danger); border-color: var(--danger-line); background: var(--danger-bg); }
.btn-danger:hover { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 8px 14px; font-size: 12px; }
.btn-lg { padding: 16px 28px; font-size: 15px; }
.btn-block { display: block; width: 100%; }

/* ===========================================================================
   下部のタブ（スマートフォンの主操作）
   =========================================================================== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--navbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 16px rgba(10, 23, 41, 0.07);
}
.tabbar-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font-family: inherit; font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  position: relative;
  transition: color 0.16s var(--ease);
}
.tabbar-btn .tb-icon { font-size: 19px; line-height: 1.1; }
.tabbar-btn.is-active { color: var(--navy-500); }
.tabbar-btn.is-active::before {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--gold);
}
.tabbar-btn:focus-visible { outline: none; box-shadow: inset var(--ring); }

/* ===========================================================================
   スコアボード（入力画面の上部・固定）
   =========================================================================== */
.scoreboard {
  position: sticky; top: 0; z-index: 40;
  padding: 9px 12px;
  background:
    radial-gradient(120% 180% at 92% 0%, rgba(194, 161, 92, 0.14) 0%, transparent 60%),
    linear-gradient(120deg, var(--navy-900) 0%, var(--navy-800) 100%);
  border-bottom: 1px solid var(--gold);
  color: #fff;
}
.sbd-inner {
  max-width: var(--shell); margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
}
.sbd-teams { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
/* --tc はそのチームの色。濃い下地の上でも読めるよう明るさを固定している */
.sbd-team { display: flex; align-items: center; gap: 7px; --tc: hsl(var(--team-hue) 68% 62%); }
.sbd-team.is-atbat .sbd-name { color: #fff; font-weight: 700; }
.sbd-team.is-atbat .sbd-run { color: var(--tc); }
.sbd-mark {
  width: 10px; flex: none; text-align: center;
  font-size: 9px; color: var(--tc); line-height: 1.4;
}
.sbd-name {
  flex: 1; min-width: 0; padding-left: 7px;
  border-left: 3px solid var(--tc);
  font-size: 12px; color: rgba(255, 255, 255, 0.78);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sbd-run {
  font-size: 19px; font-weight: 700; min-width: 22px; text-align: right;
  color: rgba(255, 255, 255, 0.92);
}
.sbd-inning {
  flex: none; display: flex; align-items: center; padding: 0 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  border-right: 1px solid rgba(255, 255, 255, 0.16);
}
.sbd-inning-num { font-size: 19px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }

/* ボール・ストライク・アウト。球場のスコアボードと同じ色づかい */
.count-panel {
  flex: none; display: flex; flex-direction: column; gap: 4px;
  padding: 6px 9px; border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.cnt-row { display: flex; align-items: center; gap: 7px; }
.cnt-key {
  width: 13px; font-size: 14px; font-weight: 800; line-height: 1;
  color: rgba(255, 255, 255, 0.55); text-align: center;
}
.cnt-pips { display: flex; gap: 5px; }
.pip {
  display: block; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
.pip-b.is-on { background: #3ddc84; border-color: #3ddc84; box-shadow: 0 0 9px rgba(61, 220, 132, 0.65); }
.pip-s.is-on { background: #ffd23f; border-color: #ffd23f; box-shadow: 0 0 9px rgba(255, 210, 63, 0.65); }
.pip-o.is-on { background: #ff4d4d; border-color: #ff4d4d; box-shadow: 0 0 9px rgba(255, 77, 77, 0.65); }
.cnt-key-b { color: #3ddc84; }
.cnt-key-s { color: #ffd23f; }
.cnt-key-o { color: #ff6b6b; }
/* いま点いたランプを一度だけ弾ませる */
.pip.just-lit { animation: pip-hit 0.36s var(--ease); }
@keyframes pip-hit {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.6); }
  100% { transform: scale(1); }
}

/* カウント入力（スコアボードの下の帯） */
.count-bar {
  display: flex; gap: 6px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-pill);
  margin-bottom: 12px;
}
.count-bar .btn { flex: 1; padding: 10px 6px; font-size: 12px; letter-spacing: 0.02em; }

/* ボタンの色は、すぐ上のカウントのランプと同じにする。
   球場のスコアボードと同じ並び（ボール＝緑・ストライク＝黄）なので、
   試合中に文字を読まなくても指が迷わない。
   明るい画面でも暗い画面でも同じ色にしてある（スコアボードはどちらでも同じ色） */
#btn-ball, #btn-strike { border-color: transparent; font-weight: 700; }
#btn-ball   { background: #3ddc84; color: #06281a; }
#btn-strike { background: #ffd23f; color: #3a2c00; }
#btn-ball:hover   { background: #5fe8a0; color: #06281a; border-color: transparent; }
#btn-strike:hover { background: #ffdd6b; color: #3a2c00; border-color: transparent; }
/* ファウルはストライクの仲間（ただし2ストライクのあとは増えない）。
   同じ黄でも塗らずに輪郭だけにして、押し間違えないようにする */
#btn-foul {
  background: transparent; border-color: #ffd23f;
  color: var(--text-strong); font-weight: 700;
}
#btn-foul:hover { background: rgba(255, 210, 63, 0.18); border-color: #ffd23f; color: var(--text-strong); }
/* 入力の途中はカウントを受け付けない（押しても何も起きないことを見た目でも示す） */
.count-bar .btn.is-locked { opacity: .4; border-style: dashed; }
.count-lock {
  margin-top: 7px; padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gold); background: var(--gold-bg); color: var(--gold-deep);
  font-size: 12px; font-weight: 700; text-align: center;
}

/* --- 試合時間 ------------------------------------------- */
.clockbar {
  max-width: var(--shell); margin: 8px auto 0;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.ck-icon { font-size: 13px; opacity: .8; flex: none; }
.ck-time {
  font-size: 16px; font-weight: 700; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap; flex: none;
}
.ck-sub {
  flex: 1; min-width: 0; font-size: 11px; color: rgba(255, 255, 255, 0.68);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ck-btns { display: flex; gap: 5px; flex: none; }
.ck-btns .btn {
  background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.28); color: #fff;
  padding: 6px 11px;
}
.ck-btns .btn:hover { background: rgba(255, 255, 255, 0.24); color: #fff; }
.ck-btns .btn-primary { background: var(--gold); border-color: var(--gold); color: var(--navy-900); }
.ck-btns .btn-primary:hover { background: var(--gold-soft); color: var(--navy-900); }
.ck-btns .btn-danger { background: rgba(255, 90, 90, 0.18); border-color: #ff8f8f; color: #ffc9c9; }
.ck-btns .btn-danger:hover { background: rgba(255, 90, 90, 0.32); color: #fff; }

.clockbar.is-idle .ck-time { color: rgba(255, 255, 255, 0.62); font-size: 14px; }
.clockbar.is-paused { border-color: var(--gold); background: rgba(194, 161, 92, 0.18); }
.clockbar.is-paused .ck-sub { color: var(--gold-soft); font-weight: 700; }
.clockbar.is-near { border-color: var(--gold); }
.clockbar.is-near .ck-time { color: var(--gold-soft); }
.clockbar.is-over { border-color: #ff8f8f; background: rgba(255, 90, 90, 0.18); }
.clockbar.is-over .ck-time, .clockbar.is-over .ck-sub { color: #ffc9c9; font-weight: 700; }
/* 試合前の設定に不備があるとき。「試合開始」は押せない状態になっている */
.clockbar.is-blocked { border-color: var(--gold); background: rgba(194, 161, 92, 0.16); }
.clockbar.is-blocked .ck-sub { color: var(--gold-soft); font-weight: 700; }

.clockbar.is-finished { border-color: rgba(255, 255, 255, 0.3); }
.clockbar.is-finished .ck-sub { color: #fff; font-weight: 700; }

/* ===========================================================================
   入力画面
   =========================================================================== */
.game-body { max-width: var(--shell); margin: 0 auto; padding: 12px 12px 20px; }

/* 打者と塁の状況を横に並べた 1 枚 */
.now-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
/* いまの対戦（打者 対 投手）。図の札と色をそろえてある */
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
.mu-vs {
  align-self: center; font-size: 12px; font-weight: 700; color: var(--faint); letter-spacing: 0.1em;
}
.mu-box {
  min-width: 0; padding: 9px 11px;
  border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--surface-2);
}
.mu-label { font-size: 9px; font-weight: 700; letter-spacing: 0.16em; color: var(--muted); }
.mu-main {
  display: flex; align-items: center; gap: 6px; margin: 1px 0;
  min-width: 0;
}
.mu-no {
  flex: none; min-width: 24px; padding: 1px 6px;
  border-radius: var(--radius-pill);
  color: #fff; font-size: 11px; font-weight: 700; text-align: center;
}
.mu-name {
  font-size: 19px; font-weight: 700; letter-spacing: 0.02em; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mu-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 打者は「いまの打者」を示す金色。図の打者の札と同じ */
.mu-batter { border-color: var(--gold); background: var(--gold-bg); }
.mu-batter .mu-label { color: var(--gold-deep); }
.mu-batter .mu-no { background: linear-gradient(160deg, var(--gold), var(--gold-deep)); color: #fff; }

/* 投手は守っているチームの色。図の投手の札と同じ */
.mu-pitcher { border-color: hsl(var(--team-hue) 45% 55%); }
.mu-pitcher .mu-no {
  background: linear-gradient(160deg, hsl(var(--team-hue) 56% 30%), hsl(var(--team-hue) 61% 14%));
}
.mu-count { font-variant-numeric: tabular-nums; color: var(--text); }
.mu-count b { font-size: 20px; font-weight: 800; color: var(--text-strong); margin-right: 1px; }
.mu-limit { color: var(--faint); }
.mu-pitcher.is-near { border-color: var(--gold); background: var(--gold-bg); }
.mu-pitcher.is-near .mu-count b { color: var(--gold-deep); }
.mu-pitcher.is-over { border-color: var(--danger); background: var(--danger-bg); }
.mu-pitcher.is-over .mu-count b { color: var(--danger); }

/* 攻撃中のチームの投手（いまは投げていないほう）の球数。
   対戦の札より一段おさえた、1行の帯にしてある */
.mu-rest {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 8px; padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--team-hue) 45% 55%); background: var(--surface-2);
  font-size: 12px; color: var(--text);
}
.mu-rest-team { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: var(--muted); }
/* 背番号の丸は、地の色が付いて初めて読める（素の .mu-no は白字だけ）。
   ここも投手なので、対戦の札と同じくチームの色で塗る */
.mu-rest .mu-no {
  background: linear-gradient(160deg, hsl(var(--team-hue) 56% 30%), hsl(var(--team-hue) 61% 14%));
}
.mu-rest-name { font-weight: 600; color: var(--text-strong); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mu-rest-count { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mu-rest-count b { font-size: 15px; font-weight: 800; color: var(--text-strong); margin-right: 1px; }
.mu-rest.is-near { border-color: var(--gold); background: var(--gold-bg); }
.mu-rest.is-near .mu-rest-count b { color: var(--gold-deep); }
.mu-rest.is-over { border-color: var(--danger); background: var(--danger-bg); }
.mu-rest.is-over .mu-rest-count b { color: var(--danger); }
.mu-alert {
  margin-top: 8px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger);
  font-size: 12px; font-weight: 700; text-align: center;
}

.now-bases { width: 100%; }
.bases-cap { text-align: center; font-size: 10px; color: var(--faint); letter-spacing: 0.06em; margin-top: 2px; }

/* --- 打者と走者の位置関係の図 --------------------------- */
.sit-svg { width: 100%; height: auto; display: block; max-width: 380px; margin: 0 auto; }
.sit-box { margin-bottom: 14px; }
.sit-field { fill: var(--accent-soft); }
.sit-path { stroke: var(--line); stroke-width: 3; }
.sit-base { fill: var(--surface); stroke: var(--faint); stroke-width: 2; cursor: pointer; }
/* 走者がいる塁は、そのチームのカラーで塗る。
   --navy-* は :root で解決済みなので、ここでは色相から直接つくる */
.sit-base.is-on { fill: hsl(var(--team-hue) 53% 42%); stroke: hsl(var(--team-hue) 61% 16%); }
.sit-home { fill: var(--surface); stroke: var(--faint); stroke-width: 2; }
.sit-cap { font-size: 11px; text-anchor: middle; fill: var(--faint); }

.sit-tag-bg { fill: var(--surface); stroke: var(--navy-400); stroke-width: 1.5; }
.sit-tag-no-bg { fill: var(--navy-600); }
.sit-tag-no { font-size: 10px; text-anchor: middle; fill: #fff; font-weight: 700; }
.sit-tag-name { font-size: 13px; fill: var(--text-strong); font-weight: 600; }
/* 塁上の選手はチームカラーで塗りつぶし、誰のチームの走者か一目で分かるようにする */
.sit-runner .sit-tag-bg { fill: hsl(var(--team-hue) 56% 28%); stroke: hsl(var(--team-hue) 61% 12%); stroke-width: 1.5; }
.sit-runner .sit-tag-no-bg { fill: #fff; }
.sit-runner .sit-tag-no { fill: hsl(var(--team-hue) 58% 20%); }
.sit-runner .sit-tag-name { fill: #fff; }
/* 投手はマウンドに置く。守備チームの色で、走者と見分けられるよう枠だけ色を付ける */
.sit-pitcher .sit-tag-bg { fill: var(--surface); stroke: hsl(var(--team-hue) 50% 42%); stroke-width: 2.5; }
.sit-pitcher .sit-tag-no-bg { fill: hsl(var(--team-hue) 56% 28%); }
.sit-pitcher .sit-tag-no { fill: #fff; }
.sit-pitcher .sit-tag-name { fill: var(--text-strong); }
.sit-batter .sit-tag-bg { stroke: var(--gold); stroke-width: 2; fill: var(--gold-bg); }
.sit-batter .sit-tag-no-bg { fill: var(--gold-deep); }
.sit-batter .sit-tag-name { fill: var(--gold-deep); }

.sit-arrow { stroke: var(--navy-500); stroke-width: 3.5; stroke-linecap: round; }
.sit-arrow-head { fill: var(--navy-500); }
.sit-arrow.is-score, .sit-arrow-head.is-score { stroke: var(--safe); fill: var(--safe); }
.sit-arrow.is-out, .sit-arrow-head.is-out { stroke: var(--danger); fill: var(--danger); opacity: .55; }
.sit-out { font-size: 18px; text-anchor: middle; fill: var(--danger); font-weight: 700; }

.sit-legend, .fld-legend {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 12px;
  margin-top: 6px; font-size: 11px; color: var(--muted);
}
.sit-legend span, .fld-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg-line { width: 16px; height: 3px; border-radius: 2px; background: var(--navy-500); }
.lg-line.lg-score { background: var(--safe); }
.lg-line.lg-out { background: var(--danger); opacity: .55; }
.lg-dot { width: 12px; height: 12px; border-radius: 50%; }
.lg-dot.lg-batter { background: var(--gold); }
.lg-dot.lg-runner { background: var(--navy-500); }
.lg-dot.lg-fielder { background: var(--surface); border: 2px solid var(--navy-400); }

.sit-note {
  margin-bottom: 8px; padding: 8px 11px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); text-align: center;
}
.no-badge {
  display: inline-block; min-width: 20px; margin-right: 4px; padding: 0 5px;
  border-radius: var(--radius-pill);
  background: linear-gradient(160deg, var(--navy-600), var(--navy-900));
  color: #fff; font-size: 10px; font-weight: 700; text-align: center; vertical-align: 1px;
}
.runner-label .no-badge { vertical-align: 1px; }

/* 球場図の中の走者・打者 */
/* 走者・打者の印は目印なので、守備位置のタップを邪魔しない */
.fld-runner, .fld-batter { pointer-events: none; }
.fld-runner-bg { fill: hsl(var(--team-hue) 56% 30%); stroke: var(--surface); stroke-width: 2.5; }
.fld-runner-no { font-size: 9px; text-anchor: middle; fill: #fff; font-weight: 700; }
.fld-batter-bg { fill: var(--gold); stroke: var(--surface); stroke-width: 2.5; }
.fld-batter-no { font-size: 9px; text-anchor: middle; fill: var(--navy-900); font-weight: 700; }

/* ウィザード */
.wizard {
  padding: 16px 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.wz-head { position: relative; margin-bottom: 14px; padding-right: 74px; }
.wz-title { font-size: 17px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-strong); }
.wz-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.wz-sub b { color: var(--text-strong); }
.wz-back {
  position: absolute; right: 0; top: -2px;
  padding: 8px 13px;
  border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.wz-back:hover { border-color: var(--navy-300); color: var(--text-strong); }

.wz-group { margin-bottom: 14px; }
.wz-group:last-child { margin-bottom: 0; }
.wz-group-title {
  font-size: 9px; font-weight: 700; letter-spacing: 0.16em;
  color: var(--navy-300); margin-bottom: 7px;
}
.wz-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.res-btn {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: 60px; padding: 9px 12px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font-family: inherit; text-align: left; cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease),
              box-shadow 0.16s var(--ease), transform 0.12s var(--ease);
}
.res-btn:active { transform: translateY(1px); }
.res-btn:hover { box-shadow: var(--shadow-1); }
.res-label { font-size: 15px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-strong); }
.res-sub { font-size: 10px; color: var(--muted); margin-top: 1px; letter-spacing: 0.04em; }

.g-out .res-btn { border-color: var(--danger-line); background: var(--danger-bg); }
.g-out .res-btn:hover { border-color: var(--danger); }
.g-on .res-btn { border-color: var(--safe-line); background: var(--safe-bg); }
.g-on .res-btn:hover { border-color: var(--safe); }
.g-etc .res-btn:hover { border-color: var(--navy-300); }

/* 球場図 */
.field-box { max-width: 420px; margin: 0 auto; }
.field-svg { width: 100%; height: auto; display: block; }
.fld-grass { fill: var(--accent-soft); }
.fld-dirt { fill: var(--gold-bg); }
.fld-diamond { fill: none; stroke: var(--surface); stroke-width: 2.5; }
.fld-line { stroke: var(--faint); stroke-width: 2; }
.fld-mound { fill: var(--gold-bg); stroke: var(--gold-soft); }
.fld-pos { cursor: pointer; }
.fld-pos-bg {
  fill: var(--surface); stroke: var(--navy-400); stroke-width: 1.6;
  transition: fill 0.14s var(--ease);
}
.fld-pos:hover .fld-pos-bg { fill: var(--accent-soft); }
.fld-pos.is-sel .fld-pos-bg { fill: var(--navy-600); stroke: var(--navy-800); }
.fld-pos.is-sel .fld-pos-label, .fld-pos.is-sel .fld-pos-num { fill: #fff; }
.fld-pos-label { font-size: 14px; font-weight: 700; text-anchor: middle; fill: var(--text-strong); pointer-events: none; }
.fld-pos-num { font-size: 9px; text-anchor: middle; fill: var(--muted); pointer-events: none; }

/* 選択行 */
.opt-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.opt-label {
  width: 100%; font-size: 9px; font-weight: 700; letter-spacing: 0.16em; color: var(--navy-300);
}
.opt-btn {
  padding: 10px 15px; min-height: 42px;
  border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit; font-weight: 600; cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease);
}
.opt-btn:hover { border-color: var(--navy-300); }
.opt-btn.is-sel {
  background: linear-gradient(160deg, var(--navy-600) 0%, var(--navy-800) 100%);
  border-color: transparent; color: #fff;
}
/* ボタンの中の小さな説明 */
.opt-note { display: block; margin-top: 1px; font-size: 10px; font-weight: 500; opacity: 0.7; }
/* 守備の配置図（選手交代の画面） */
.def-box { margin: 12px 0; }
.def-svg { width: 100%; height: auto; display: block; max-width: 380px; margin: 0 auto; }
.def-pos { cursor: pointer; }
.def-pos-bg { fill: var(--surface); stroke: hsl(var(--team-hue) 45% 45%); stroke-width: 2; transition: fill .14s var(--ease); }
.def-pos:hover .def-pos-bg { fill: var(--accent-soft); }
.def-pos.is-sel .def-pos-bg { fill: hsl(var(--team-hue) 56% 30%); stroke: var(--gold); stroke-width: 3; }
.def-pos.is-sel .def-pos-label, .def-pos.is-sel .def-pos-no { fill: #fff; }
.def-pos.is-empty .def-pos-bg { stroke-dasharray: 3 3; opacity: .6; }
.def-pos-label { font-size: 13px; font-weight: 700; text-anchor: middle; fill: var(--text-strong); pointer-events: none; }
.def-pos-no { font-size: 10px; text-anchor: middle; fill: var(--muted); font-weight: 700; pointer-events: none; }
.def-pos-name { font-size: 11px; text-anchor: middle; fill: var(--text); font-weight: 600; pointer-events: none; }
.def-guide {
  margin-top: 8px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--gold); background: var(--gold-bg); color: var(--gold-deep);
  font-size: 12px; font-weight: 700; text-align: center;
}
.def-guide b { font-size: 13px; }

/* よくある形のプリセット */
.preset-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.preset-btn {
  padding: 10px 15px; min-height: 42px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--gold); background: var(--gold-bg); color: var(--gold-deep);
  font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer;
  transition: background 0.16s var(--ease), transform 0.12s var(--ease);
}
.preset-btn:active { transform: translateY(1px); }

/* 走者の行 */
.runner-list { display: flex; flex-direction: column; gap: 9px; }
.runner-row {
  padding: 11px 12px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2);
}
.runner-label { font-size: 13px; font-weight: 600; color: var(--text-strong); margin-bottom: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  flex: 1 1 0; min-width: 62px; min-height: 46px; padding: 10px 6px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit; font-weight: 600; cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease);
}
.seg-btn:hover { border-color: var(--navy-300); }
.seg-btn.is-sel {
  background: linear-gradient(160deg, var(--navy-600) 0%, var(--navy-800) 100%);
  border-color: transparent; color: #fff;
}

.wz-actions { margin-top: 16px; }
.wz-actions .btn { width: 100%; }
.wz-note {
  margin-top: 10px; text-align: center; font-size: 12px; color: var(--muted); min-height: 18px;
}
.wz-note b { color: var(--gold-deep); font-size: 14px; }

/* 直前のプレー */
.log-card { margin-top: 12px; padding: 0; overflow: hidden; }
.log-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; cursor: pointer; list-style: none;
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-strong);
}
.log-summary::-webkit-details-marker { display: none; }
.log-summary::after { content: "▾"; color: var(--muted); font-size: 11px; }
details[open] .log-summary::after { content: "▴"; }
.log-list { list-style: none; margin: 0; padding: 0 14px 12px; }
.log-list li {
  display: flex; gap: 8px; padding: 7px 0; font-size: 12px;
  border-top: 1px solid var(--line-soft);
}
.lg-inn {
  flex: none; min-width: 38px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; color: var(--navy-300);
}
.lg-empty { color: var(--muted); justify-content: center; }
/* 履歴の行はそのまま押して直せる */
.lg-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; padding: 0; text-align: left;
  font-family: inherit; font-size: 12px; color: var(--text); cursor: pointer;
}
button.lg-row:hover .lg-fix { background: var(--accent-soft); color: var(--navy-500); }
.lg-txt { flex: 1; min-width: 0; }
.lg-fix {
  flex: none; padding: 2px 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); color: var(--faint); font-size: 10px; font-weight: 700;
}
.log-card .btn-block { margin: 0 14px 12px; width: calc(100% - 28px); }

/* 記録の修正 */
.hist-list { display: flex; flex-direction: column; gap: 6px; max-height: 58vh; overflow-y: auto; }
.hist-row {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  font-family: inherit; font-size: 13px; color: var(--text); text-align: left; cursor: pointer;
}
.hist-row:hover { border-color: var(--navy-300); background: var(--surface); }
.hist-no {
  flex: none; min-width: 26px; text-align: center;
  font-size: 10px; font-weight: 700; color: var(--faint);
}
.hist-text { flex: 1; min-width: 0; }
.hist-go {
  flex: none; padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--navy-500); font-size: 11px; font-weight: 700;
}
.hist-target {
  margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--text-strong);
}
.mi-note { display: block; margin-top: 2px; font-size: 11px; font-weight: 400; opacity: .75; }
.menu-item { flex-wrap: wrap; }
.link-btn {
  border: 0; background: none; padding: 0; color: var(--navy-500);
  font-family: inherit; font-size: 11px; font-weight: 700; text-decoration: underline; cursor: pointer;
}

/* 修正中であることを示す帯 */
.edit-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: -4px 0 14px; padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--gold); background: var(--gold-bg); color: var(--gold-deep);
  font-size: 12px; font-weight: 700;
}
.edit-banner span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* 画面下の操作（タブバーのすぐ上） */
.action-bar {
  position: sticky; bottom: calc(8px + var(--safe-b)); z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px;
  margin-top: 14px; padding: 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  box-shadow: var(--shadow-2);
}
.action-bar .btn { padding: 11px 4px; font-size: 12px; letter-spacing: 0.02em; border-color: transparent; background: none; }
.action-bar .btn:hover { background: var(--surface-2); }

/* ===========================================================================
   設定画面
   =========================================================================== */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  font-size: 9px; font-weight: 700; letter-spacing: 0.16em; color: var(--navy-300);
}
.field input, .field select, .lu-no, .lu-name, .lu-pos, .modal-body input, .modal-body select {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 16px;  /* iOS で入力時に拡大されないように 16px */
  font-family: inherit; color: var(--text); background: var(--surface-2);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), background 0.16s var(--ease);
}
.field input:focus, .field select:focus,
.lu-no:focus, .lu-name:focus, .lu-pos:focus,
.modal-body input:focus, .modal-body select:focus {
  outline: none; background: var(--surface);
  border-color: var(--navy-500); box-shadow: var(--ring);
}
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.grid-form .col-2 { grid-column: 1 / -1; }
.chk {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--text);
}
.chk input { width: 20px; height: 20px; flex: none; accent-color: var(--navy-600); }
/* 結果を選ぶ画面の「くわしく決める」 */
.chk-detail {
  flex-wrap: wrap; margin-bottom: 12px; padding: 9px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2);
  font-size: 12px; cursor: pointer;
}
.chk-note { width: 100%; padding-left: 29px; font-size: 10px; color: var(--faint); }

.color-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chk-logo { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; }
.chk-logo code { font-size: 11px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.color-dot {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--line); padding: 0;
  /* 色は data-hue から流し込まれた --team-hue で決まる（js/dom.js） */
  background: linear-gradient(160deg, hsl(var(--team-hue) 56% 26%), hsl(var(--team-hue) 61% 10%));
  transition: transform 0.12s var(--ease), border-color 0.16s var(--ease);
}
.color-dot:hover { transform: scale(1.08); }
.color-dot.is-sel { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-bg); }

.lineup-card { margin-bottom: 14px; }
.lineup-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; flex-wrap: wrap; }
/* よく使うので見出しの行に置く。下のツール欄にあった頃は気づかれなかった。
   狭いときは名前の下へ回り込ませる（縮めて読めなくするより良い） */
.btn-myteam { flex: none; white-space: nowrap; }
.lineup-head .team-name { min-width: 8em; }
.team-name {
  flex: 1; min-width: 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-strong);
  font-size: 16px; font-weight: 600; font-family: inherit;
}
.badge {
  flex: none; padding: 4px 11px; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: #fff;
}
.badge-top { background: linear-gradient(160deg, var(--navy-600), var(--navy-900)); }
.badge-bottom { background: linear-gradient(160deg, var(--gold), var(--gold-deep)); }
/* そのチームの色をそのまま使うバッジ */
.badge-team { background: linear-gradient(160deg, hsl(var(--team-hue) 53% 35%), hsl(var(--team-hue) 58% 14%)); }

/* チームカラーの選択 */
.team-color-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.team-color-label { font-size: 9px; font-weight: 700; letter-spacing: 0.16em; color: var(--navy-300); }
.color-dot-sm { width: 26px; height: 26px; border-width: 2px; }

/* 控え選手 */
.bench-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 14px 0 8px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 9px; font-weight: 700; letter-spacing: 0.16em; color: var(--navy-300);
}
.bench-note { font-size: 10px; font-weight: 500; letter-spacing: 0; color: var(--faint); }
.bench-empty { margin: 0 0 10px; }
/* .lu-row より後ろに書かれる保証がないので、まとめて指定して優先度を上げる */
.lu-row.lu-row-bench { grid-template-columns: 22px 52px 1fr 34px; }
.lu-row.lu-row-bench .lu-name { grid-column: auto; }
.bench-del {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-size: 13px; font-family: inherit; cursor: pointer;
}
.bench-del:hover { border-color: var(--danger-line); color: var(--danger); background: var(--danger-bg); }

/* 設定画面のタブ（試合の設定 / 環境設定） */
.setup-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin: 4px 0 10px; padding: 5px;
  border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--line);
}
.setup-tab {
  padding: 11px 10px; border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.setup-tab.is-active {
  background: linear-gradient(160deg, var(--navy-600), var(--navy-900)); color: #fff;
  box-shadow: var(--shadow-1);
}

.lu-row {
  display: grid; grid-template-columns: 22px 52px 1fr; gap: 6px;
  align-items: center; margin-bottom: 7px;
}
.lu-row .lu-pos { grid-column: 2 / -1; }

/* 守備位置は、名前や背番号とは種類の違う欄。同じ見た目だと目が滑って、
   何が入っているのか分からないという声があった。
   ・押せる欄だと分かるよう、「選ぶ」ボタンと同じ色の札にする
   ・「8 中堅手」ではなく「8 中」。狭い画面でも名前と同じ行に収まり、
     9人ぶんを一度に見渡せる（抜けや重なりがその場で分かる）
   ・ブラウザ既定の▼は場所を取りすぎて字が切れるので消している */
.lu-pos {
  -webkit-appearance: none; appearance: none;
  padding-left: 0; padding-right: 0;
  text-align: center; text-align-last: center;
  font-weight: 700; color: var(--text-strong);
  background: var(--accent-soft); border-color: var(--navy-300);
}
.lu-pos:hover { border-color: var(--navy-500); }
/* 重なっているところ。いまは選んだ時点で入れ替わるので出ないが、
   前に付けた記録には残っていることがある */
.lu-pos.is-dup {
  /* 字まで赤くすると、赤地に赤字で読みにくくなる。
     赤いのは枠だけにして、番号は読める色のままにする */
  border-color: var(--danger); background: var(--danger-bg);
  box-shadow: 0 0 0 2px var(--danger-line);
}
/* 名簿から選ぶボタンを持つ行 */
/* 守備位置も同じ行に置く。2行に分かれていると9人を一度に見渡せず、
   どこが抜けているのか分からなくなる */
.lu-row.lu-row-pick { grid-template-columns: 20px 44px minmax(0, 1fr) 44px 62px; }
.lu-row.lu-row-pick .lu-pos { grid-column: auto; }
.lu-row.lu-row-roster { grid-template-columns: 20px 44px minmax(0, 1fr) 62px 30px; }
.lu-row.lu-row-roster .lu-pos { grid-column: auto; }
.lu-pick {
  padding: 9px 0; border-radius: var(--radius-sm);
  border: 1px solid var(--navy-300); background: var(--accent-soft); color: var(--navy-500);
  font-family: inherit; font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.lu-pick:hover { background: var(--surface); border-color: var(--navy-500); }
.lu-order {
  text-align: center; font-size: 12px; font-weight: 700; color: var(--navy-300);
}
.lu-no { text-align: center; }
.lu-row-dh { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.lineup-tools { display: flex; gap: 8px; margin-top: 10px; }
.lineup-tools .btn { flex: 1; }
.setup-actions { margin-top: 20px; }
.setup-actions .btn { width: 100%; }

/* ===========================================================================
   スコアブック
   =========================================================================== */
.book-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.book-actions { display: flex; gap: 7px; }
.book-team { margin-top: 16px; }
.book-team-head { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; flex-wrap: wrap; }
.book-team-name { font-size: 15px; font-weight: 600; color: var(--text-strong); }
.book-team-score { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }

/* --- スコアシート ---------------------------------------
   様式は NPB 公式スコアカードに合わせる。用紙なので、
   アプリがダークテーマでも中身は白地・黒インクのままにする。
   ------------------------------------------------------- */
.sheet-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet-svg { display: block; }
.sheet-wrap[data-zoom="fit"] .sheet-svg { width: 100%; height: auto; }
.sheet-wrap[data-zoom="real"] .sheet-svg { width: auto; height: auto; }

.sh-paper { fill: #fff; }
.sh-box { fill: none; stroke: #1a1a1a; stroke-width: 1.4; }
.sh-fill { fill: #f2f2f2; stroke: none; }
.sh-line { stroke: #1a1a1a; stroke-width: 1; }
.sh-line-thin { stroke: #7a7a7a; stroke-width: .6; }
.sh-dot-line { stroke: #b0b0b0; stroke-width: .5; stroke-dasharray: 3 2.5; }
.sh-dot { stroke: #b0b0b0; stroke-width: .5; stroke-dasharray: 2 2; }
.sh-split { stroke: #7a7a7a; stroke-width: .6; stroke-dasharray: 2 2; }
.sh-slash { stroke: #7a7a7a; stroke-width: .6; }

.sh-h { font-size: 11px; text-anchor: middle; fill: #111; font-weight: 700; }
.sh-h-inn { font-size: 13px; }
.sh-order { font-size: 12px; text-anchor: middle; fill: #111; font-weight: 700; font-style: italic; }
.sh-entry-no { font-size: 9px; text-anchor: end; fill: #111; font-weight: 700; }
.sh-pos { font-size: 9.5px; text-anchor: middle; fill: #111; }
.sh-name { font-size: 11px; fill: #111; }
.sh-no { font-size: 10px; text-anchor: middle; fill: #111; }
.sh-stat { font-size: 10px; text-anchor: middle; fill: #111; }
.sh-stat-total { font-weight: 700; }
.sh-lbl { font-size: 11px; fill: #333; }
.sh-val { font-size: 11.5px; fill: #111; }
.sh-sheet-label { font-size: 10px; fill: #444; font-weight: 700; letter-spacing: .1em; }
.sh-sheet-team { font-size: 17px; fill: #111; font-weight: 700; }
.sh-box-title { font-size: 11px; fill: #111; font-weight: 700; }
.sh-foot-label { font-size: 10px; text-anchor: end; fill: #111; font-weight: 700; }
.sh-foot-now { font-size: 9.5px; text-anchor: middle; fill: #111; }
.sh-foot-tot { font-size: 9.5px; text-anchor: middle; fill: #555; }

/* 打席マスの記号（用紙の中なので固定色） */
.sb-dia { fill: none; stroke: #9a9a9a; stroke-width: .7; }
.sb-run { fill: #e2e2e2; stroke: none; }
.sb-path { stroke: #000; stroke-linecap: round; }
.sb-sym { text-anchor: middle; fill: #000; font-weight: 700; }
.sb-mark { fill: none; stroke: #000; stroke-width: 1.1; }
.sb-under { stroke: #000; stroke-width: 1; }
.sb-badge { text-anchor: start; fill: #000; font-weight: 700; }
.sb-cause { text-anchor: middle; fill: #444; }
.sb-x { text-anchor: middle; fill: #000; font-weight: 700; }
.sb-outnum-c { fill: #fff; stroke: #000; stroke-width: .9; }
.sb-outnum { text-anchor: middle; fill: #000; font-weight: 700; }
.sb-rbi { fill: #000; }
.sb-entry { text-anchor: start; fill: #666; font-weight: 700; }

.linescore-wrap { overflow-x: auto; border-radius: var(--radius); }
.linescore {
  border-collapse: collapse; background: var(--surface);
  box-shadow: var(--shadow-1); border-radius: var(--radius); overflow: hidden;
}
.linescore th, .linescore td {
  border: 1px solid var(--line); padding: 6px 10px; text-align: center; font-size: 13px;
}
.linescore thead th {
  background: var(--surface-2); font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; color: var(--navy-300);
}
.linescore .ls-team { text-align: left; min-width: 116px; font-weight: 600; white-space: nowrap; }
.linescore .ls-tot { background: var(--surface-2); font-weight: 700; color: var(--text-strong); }


/* 凡例 */
.legend { margin-top: 16px; }
.legend-title { font-size: 13px; margin: 0 0 10px; color: var(--text-strong); font-weight: 600; }
.legend-list { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; font-size: 12px; }
.legend-list dt {
  font-weight: 700; color: var(--gold-deep); font-size: 12px;
}
.legend-list dd { margin: 1px 0 0; color: var(--muted); }

/* 印刷・PDF 保存の案内（印刷 / PDF を押すと出る板の中身）
   手順を読ませるものなので、.hint（11px）より大きくしてある */
.pdf-lead { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }
.pdf-h {
  font-size: 12.5px; font-weight: 600; color: var(--text-strong);
  margin: 0 0 8px; letter-spacing: 0.04em;
}
.pdf-steps {
  margin: 0 0 14px; padding-left: 1.5em;
  font-size: 13px; line-height: 1.85; color: var(--text);
}
.pdf-steps li { margin-bottom: 4px; }
.pdf-steps b { color: var(--gold-deep); font-weight: 700; }
.pdf-other { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.pdf-other summary {
  cursor: pointer; font-size: 12px; color: var(--muted); letter-spacing: 0.04em;
}
.pdf-other summary:hover { color: var(--text-strong); }
.pdf-other[open] summary { margin-bottom: 12px; }

/* ===========================================================================
   成績表
   =========================================================================== */
.stat-block { margin-bottom: 20px; }
.stat-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; margin: 0 0 9px; color: var(--text-strong); font-weight: 600; letter-spacing: 0.04em;
}
.stat-title::before { content: ""; width: 3px; height: 13px; border-radius: 2px;
  background: linear-gradient(hsl(var(--team-hue) 39% 47%), hsl(var(--team-hue) 56% 20%)); }
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-1);
}
.stat-table { border-collapse: collapse; width: 100%; min-width: 720px; }
.stat-table th {
  position: sticky; top: 0; z-index: 1;
  padding: 8px 9px; font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--navy-300); text-align: center; white-space: nowrap;
  background: var(--surface); border-bottom: 1px solid var(--navy-600);
}
.stat-table td {
  padding: 9px; font-size: 13px; text-align: center; white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
.stat-table .tl { text-align: left; }
.stat-table th.tl { text-align: left; }
/* 選手名の列は横スクロールしても左に残す */
.stat-table th:nth-child(2), .stat-table td:nth-child(2) {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface); border-right: 1px solid var(--line-soft);
}
.stat-table th:nth-child(2) { z-index: 2; }
.stat-table .row-sub td { background: var(--surface-2); color: var(--muted); }
.stat-table .row-sub td:nth-child(2) { background: var(--surface-2); }
.stat-table .row-total td { background: var(--surface-sunken); font-weight: 700; color: var(--text-strong); }
.stat-table .row-total td:nth-child(2) { background: var(--surface-sunken); }
.stat-table tbody tr:last-child td { border-bottom: none; }
.sub-mark {
  display: inline-block; padding: 1px 7px; margin-right: 5px;
  border-radius: var(--radius-pill); background: var(--accent-soft);
  color: var(--navy-500); font-size: 10px; font-weight: 700;
}
.pos-tag { margin-left: 6px; font-size: 10px; color: var(--faint); }
.uniform-number {
  display: inline-block; min-width: 26px; margin-right: 7px; padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: linear-gradient(160deg, hsl(var(--team-hue) 56% 26%) 0%, hsl(var(--team-hue) 61% 10%) 100%);
  color: #fff; font-size: 10px; font-weight: 700; text-align: center;
}
.avg { font-weight: 600; color: var(--text-strong); }

/* ===========================================================================
   モーダル（スマートフォンでは下から出るシート）
   =========================================================================== */
.modal-back {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(6, 14, 26, 0.5);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 2px solid var(--gold);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
  animation: sheet-up 0.22s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 11px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-strong);
}
.modal-close {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  width: 32px; height: 32px; border-radius: 50%; font-size: 15px; cursor: pointer; font-family: inherit;
}
.modal-close:hover { border-color: var(--navy-300); color: var(--text-strong); }
.modal-body { padding: 14px 16px calc(18px + var(--safe-b)); overflow-y: auto; }
.modal-body .wz-actions .btn { width: 100%; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-size: 14px; font-family: inherit; text-align: left; cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.menu-item:hover { border-color: var(--navy-300); background: var(--surface); }
.menu-item .mi-icon { font-size: 17px; width: 22px; text-align: center; flex: none; }
.menu-danger { color: var(--danger); border-color: var(--danger-line); background: var(--danger-bg); }

/* ===========================================================================
   場面が変わったときの表示
   タップの邪魔をしないよう pointer-events は切ってある
   =========================================================================== */
.fx {
  position: fixed; inset: 0; z-index: 150;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; pointer-events: none;
}
.fx:empty { display: none; }
/* 大きく出している間はタップを受け止める。
   演出の裏にあるボタンを連打してしまうのを防ぐ（タップで閉じる） */
.fx.is-dim { background: rgba(6, 14, 26, 0.42); transition: background 0.2s var(--ease); pointer-events: auto; }
.fx.is-leaving { background: transparent; pointer-events: none; }
.fx-card {
  text-align: center; max-width: 100%;
  animation: fx-pop 0.42s var(--ease) both;
}
.fx-main2 { font-weight: 800; letter-spacing: 0.08em; line-height: 1.15; margin-top: 2px; }
.fx.is-leaving .fx-card {
  opacity: 0; transform: scale(0.94);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  animation: none;
}
.fx-main { font-weight: 800; letter-spacing: 0.06em; line-height: 1.25; }
.fx-sub { margin-top: 6px; font-size: 14px; font-weight: 600; letter-spacing: 0.08em; opacity: 0.85; }

/* スリーアウト・チェンジ */
.fx-change {
  padding: 22px 26px; border-radius: var(--radius-lg);
  background: linear-gradient(150deg, var(--navy-700) 0%, var(--navy-900) 100%);
  border: 3px solid var(--gold); color: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.fx-change .fx-main { font-size: 23px; color: rgba(255, 255, 255, 0.9); }
.fx-change .fx-main2 { font-size: 33px; color: var(--gold-soft); }
.fx-change .fx-sub { color: var(--gold); }

/* ホームラン */
.fx-hr {
  position: relative; overflow: hidden;
  padding: 24px 30px; border-radius: var(--radius-lg);
  background: linear-gradient(150deg, #d8b86b 0%, var(--gold-deep) 100%);
  border: 3px solid #fff3d6; color: #2a1e05;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.fx-hr .fx-main { font-size: 34px; }
.fx-hr::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  animation: fx-shine 0.9s var(--ease) 0.15s both;
}

/* 得点・盗塁 */
.fx-run {
  padding: 15px 26px; border-radius: var(--radius-pill);
  background: linear-gradient(150deg, var(--navy-600), var(--navy-900));
  border: 2px solid var(--gold); color: #fff;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
}
.fx-run .fx-main { font-size: 25px; }

/* 選ぶ操作が必要になったとき */
.fx-ask {
  padding: 20px 26px; border-radius: var(--radius-lg);
  background: linear-gradient(150deg, var(--navy-700) 0%, var(--navy-900) 100%);
  border: 3px solid var(--gold); color: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.fx-ask .fx-main { font-size: 30px; color: var(--gold-soft); }
.fx-ask .fx-sub { font-size: 15px; color: #fff; }

/* 選手交代 */
.fx-sub-in {
  padding: 14px 24px; border-radius: var(--radius-pill);
  background: var(--surface); border: 2px solid var(--navy-400); color: var(--text-strong);
  box-shadow: var(--shadow-2);
}
.fx-sub-in .fx-main { font-size: 21px; }
.fx-sub-in .fx-sub { color: var(--muted); }

/* 次のイニング */
.fx-inning {
  width: 100%; padding: 18px 24px;
  background: linear-gradient(100deg, var(--navy-900), var(--navy-600) 60%, var(--navy-900));
  border-top: 3px solid var(--gold); border-bottom: 3px solid var(--gold);
  color: #fff; animation: fx-slide 0.4s var(--ease) both;
}
.fx-inning .fx-main { font-size: 30px; }
.fx-inning .fx-sub { color: var(--gold); }

@keyframes fx-pop {
  0%   { transform: scale(0.62) rotate(-3deg); opacity: 0; }
  55%  { transform: scale(1.06) rotate(1.2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes fx-slide {
  from { transform: translateX(-36px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes fx-drop {
  from { transform: translateY(-14px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes fx-shine {
  from { left: -70%; }
  to   { left: 110%; }
}

/* 打者が変わったときは、打者カードをそっと出し直す */
.now-card.is-new { animation: card-in 0.32s var(--ease) both; }
@keyframes card-in {
  from { transform: translateY(-6px); opacity: 0.35; }
  to   { transform: none; opacity: 1; }
}

/* ===========================================================================
   トースト
   =========================================================================== */
.toast {
  position: fixed; left: 12px; right: 12px; z-index: 120;
  bottom: calc(var(--navbar-h) + var(--safe-b) + 12px);
  margin: 0 auto; max-width: 460px;
  padding: 13px 18px; border-radius: var(--radius-pill);
  background: linear-gradient(160deg, var(--navy-700) 0%, var(--navy-900) 100%);
  border: 1px solid var(--gold);
  color: #fff; font-size: 13px; font-weight: 600; text-align: center;
  box-shadow: var(--shadow-2);
  animation: toast-in 0.2s var(--ease);
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===========================================================================
   タブレット
   =========================================================================== */
@media (min-width: 600px) {
  .wz-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-form { grid-template-columns: repeat(3, 1fr); }
  .lu-row { grid-template-columns: 24px 58px 1fr 132px; }
  .lu-row.lu-row-pick { grid-template-columns: 24px 58px minmax(0, 1fr) 52px 84px; }
  .lu-row.lu-row-pick .lu-pos { grid-column: auto; }
  .lu-row.lu-row-roster { grid-template-columns: 24px 58px minmax(0, 1fr) 84px 40px; }
  .lu-row.lu-row-roster .lu-pos { grid-column: auto; }
  .lu-row.lu-row-bench { grid-template-columns: 24px 58px 1fr 40px; }
  .lu-row .lu-pos { grid-column: auto; }
  .legend-list { grid-template-columns: 150px 1fr; gap: 6px 14px; }
  .legend-list dd { margin: 0; }
  /* 塁の図は「押して走者を動かす」場所。
     画面が広いほど指から遠くなるので、スマホと同じく幅いっぱいに置く。
     ここを 110px に縮めていたため、パソコンとタブレットで極端に狙いにくかった。 */
  .now-bases { width: 100%; }
  .theme-label { display: inline; }
}

/* ===========================================================================
   パソコン・大きなタブレット
   =========================================================================== */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }

  /* 場面の表示は広い画面ではもっと大きく */
  .fx-change .fx-main { font-size: 30px; }
  .fx-change .fx-main2 { font-size: 46px; }
  .fx-hr .fx-main { font-size: 48px; }
  .fx-inning .fx-main { font-size: 42px; }
  .fx-run .fx-main { font-size: 32px; }

  .page-header { padding: 18px 20px 16px; }
  .brand-logo, .brand-mark { height: 44px; width: auto; min-width: 44px; }
  .page-header h1 { font-size: 20px; letter-spacing: 0.08em; }
  .header-sub { font-size: 10px; letter-spacing: 0.32em; }

  .top-tabs { display: flex; gap: 4px; }
  .top-tab {
    padding: 9px 18px; border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(10, 23, 41, 0.4);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    color: rgba(255, 255, 255, 0.75);
    font-family: inherit; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; cursor: pointer;
    transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease);
  }
  .top-tab:hover { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
  .top-tab.is-active { background: var(--gold); border-color: var(--gold); color: var(--navy-900); }

  /* 広い画面ではスコアボードを中央にまとめる */
  .sbd-inner { justify-content: center; gap: 18px; }
  .sbd-teams { flex: 0 1 360px; }
  .scoreboard { padding: 11px 12px; }

  .wrap, .game-body { padding: 20px 20px 40px; }
  .wz-grid { grid-template-columns: repeat(4, 1fr); }
  .res-btn { min-height: 66px; }

  /* 入力画面は 2 段組み */
  .game-body { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start;
                grid-template-areas: "side main" "extra main"; grid-template-rows: auto 1fr; }
  .game-side { grid-area: side; }
  .game-main { grid-area: main; }
  .game-extra { grid-area: extra; display: flex; flex-direction: column; gap: 12px; }
  .game-side { display: flex; flex-direction: column; gap: 12px; }
  .now-card { margin-bottom: 0; }
  .now-batter { text-align: center; }
  .now-name { font-size: 21px; }

  /* パソコンは画面から離れて見るぶん、スマホと同じ大きさでは小さすぎる。
     入力に使うところ（塁の図・打者と投手・結果のボタン）だけを大きくする。
     スマホの見え方はこの指定の外なので変わらない。 */
  .sit-svg { max-width: 100%; }
  .mu-name { font-size: 22px; }
  .mu-count b { font-size: 23px; }
  .wz-title { font-size: 22px; }
  .res-btn { min-height: 74px; font-size: 15px; }
  /* スマホでは画面の下に貼り付く帯だが、パソコンでは左の列に置く。
     縦に 3 つ積むと左の列だけ長くなって画面から溢れるので、横に 3 つ並べる */
  .action-bar { position: static; grid-template-columns: repeat(3, 1fr); background: none; border: 0; box-shadow: none; padding: 0; gap: 8px; }
  .action-bar .btn { border-color: var(--line); background: var(--surface); padding: 12px; font-size: 13px; }
  .log-card { margin-top: 0; }
  .game-main { min-width: 0; }
  .wizard { padding: 22px 24px 24px; }
  .wz-title { font-size: 20px; }

  .lineup-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .lineup-card { margin-bottom: 0; }

  .modal-back { align-items: center; padding: 24px; }
  .modal { max-width: 760px; border-radius: var(--radius-lg); border-top-width: 1px; border: 1px solid var(--line); border-top: 2px solid var(--gold); }
  .toast { bottom: 24px; }
}

/* ===========================================================================
   大きなパソコンの画面（ノートの 1366px 以上）

   1180px のままだと左右が大きく余り、そのぶん入力のボタンが縦に伸びて
   画面に収まらなくなる。横を使って縦を詰め、スクロールせずに全部見えるようにする。
   =========================================================================== */
@media (min-width: 1300px) {
  :root { --shell: 1400px; }

  /* 左の列を広げて、塁の図をさらに大きくする */
  .game-body { grid-template-columns: 360px 1fr; }

  /* 結果のボタンを 6 列に。3 つの箱がそれぞれ 1 行ずつ減る */
  .wz-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ===========================================================================
   印刷（A4 横）。画面がダークでも紙は白地・黒字にする
   =========================================================================== */
@media print {
  :root {
    --sb-paper: #fff; --sb-paper-2: #fff; --sb-ink: #000;
    --sb-grid: #999; --sb-grid-strong: #333; --sb-run: #e8e8e8;
    --surface: #fff; --surface-2: #fff; --surface-sunken: #fff;
    --line: #bbb; --line-soft: #ddd; --text: #000; --text-strong: #000;
    --muted: #444; --faint: #777; --navy-300: #333; --navy-600: #333; --gold-deep: #000;
  }
  body { background: #fff; padding: 0; }
  .page-header, .tabbar, .scoreboard, .count-bar, .book-actions, .toast, .modal-back, .action-bar { display: none !important; }
  .screen { display: none !important; }
  #screen-book { display: block !important; }
  .wrap { max-width: none; padding: 0; }
  .sheet-wrap { border: 0; box-shadow: none; overflow: visible; padding: 0; }
  .sheet-wrap .sheet-svg { width: 100% !important; height: auto !important; }
  .card, .linescore, .table-scroll { box-shadow: none; }
  .book-head, .linescore-wrap, .book-team-head, .legend { display: none !important; }
  /* スコアシートは 1 チーム 1 ページ */
  .book-team { page-break-inside: avoid; page-break-after: always; margin: 0; }
  #book-bottom { page-break-after: auto; }
  @page { size: A4 landscape; margin: 8mm; }
}

/* ===========================================================================
   試合が終わったあとの案内
   =========================================================================== */
.ag-lead { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--text-strong); }

.ag-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.ag-list li { margin: 0; }

.ag-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  text-align: left;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
/* 必ずやってほしい2つは、はっきり見せる */
.ag-item.is-main { border-color: var(--navy-400); background: var(--accent-soft); }
.ag-item:hover { border-color: var(--gold); }
.ag-item:active { transform: translateY(1px); }

.ag-num {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 13px; font-weight: 700;
  color: #fff;
  background: hsl(var(--team-hue) 53% 35%);
}
.ag-text { display: grid; gap: 2px; min-width: 0; }
.ag-label { font-size: 15px; font-weight: 700; color: var(--text-strong); }
.ag-note { font-size: 11px; color: var(--muted); line-height: 1.6; }
.ag-go { font-size: 20px; color: var(--faint); }

.ag-warn { margin: 0 0 12px; }

/* 試合を始める前の見直し。直すところがあるときだけ出す */
.setup-problems {
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.9;
  text-align: left;
}
.setup-problems strong { display: block; margin-bottom: 4px; color: var(--danger); }
.setup-problems ul { margin: 0; padding-left: 1.3em; }

/* 押せないことが見て分かるようにする */

/* 名簿の取り込み（成績管理アプリと同じ場所にあるときだけ出す） */
.roster-state {
  margin: 12px 0 10px;
  padding: 11px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}
.roster-state .btn { margin: 8px 0; }

/* ===========================================================================
   ライブ配信
   =========================================================================== */

/* 時計の帯の右端に出す目印。押すとリンクの案内が開く */
.live-pill {
  flex: none;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  min-height: 26px;
  cursor: pointer;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}
/* まだ配信していないときの入口。押せることは分かるが、
   記録の邪魔にならないよう、輪郭だけの静かな見た目にしておく */
.live-pill.is-ready {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
}
.live-pill.is-ready:hover { border-color: #fff; background: rgba(255, 255, 255, 0.12); }

.live-pill.is-on { background: #2e7d4f; }
/* 送れていない間も入力は続けられる。焦らせないよう、色だけで静かに知らせる */
.live-pill.is-connecting,
.live-pill.is-retrying { background: var(--gold); color: #2a2107; }
.live-pill.is-error { background: var(--danger); }
.live-pill.is-on::first-letter { animation: live-blink 1.8s var(--ease) infinite; }

@keyframes live-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) {
  .live-pill.is-on::first-letter { animation: none; }
}

/* --- 環境設定の欄 --- */
.live-test-result { margin: 8px 0 0; font-size: 12px; color: var(--muted); min-height: 1.2em; }
.live-test-result.is-ok { color: #2e7d4f; font-weight: 700; }
.live-test-result.is-ng { color: var(--danger); font-weight: 700; }

/* 配信の許可（管理者パスワードの確認）の状態 */
.live-admin-state {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  margin: 8px 0 14px;
  font-size: 12px;
}
.las-off { color: var(--muted); }
.las-on { color: #2e7d4f; font-weight: 700; }

.live-policy { display: grid; gap: 6px; margin-bottom: 10px; }
.live-policy-opt {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}
.live-policy-opt:has(input:checked) { border-color: var(--navy-400); background: var(--accent-soft); }
.live-policy-opt input { width: 18px; height: 18px; margin: 0; grid-row: span 2; }
.lp-label { font-size: 14px; font-weight: 700; color: var(--text-strong); }
.lp-hint { font-size: 11px; color: var(--muted); grid-column: 2; }

/* 選んだ設定で実際にどう見えるかを出す。実名が出る設定かがその場で分かる */
.live-name-preview {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px dashed var(--line);
}
.lnp-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; }
.lnp-chip {
  font-size: 13px; font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

/* --- 配信の案内（メニューから開く） --- */
.live-on-note { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: #2e7d4f; }
.live-url-row {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 2px solid var(--gold);
  border-radius: var(--radius-sm);
  background: var(--gold-bg);
}
.live-url-label {
  display: block;
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--gold-deep);
  margin-bottom: 5px;
}

/* 配信キーの登録手順（まだ登録されていないとき） */
.live-setup-steps {
  margin: 0 0 12px;
  padding-left: 1.4em;
  font-size: 13px;
  line-height: 2;
  color: var(--text);
}
.live-setup-steps li { margin-bottom: 2px; }
.live-url-row code {
  display: block;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  user-select: all;               /* ひと触りで全部選べるように */
  color: var(--text-strong);
}
.live-btns { display: flex; gap: 8px; margin-bottom: 12px; }
.live-btns .btn { flex: 1; }
.live-facts { margin: 0 0 12px; padding-left: 1.2em; font-size: 13px; color: var(--muted); line-height: 1.9; }

/* ごく狭い画面では英字のラベルも省く。
   ロゴでチームは分かり、どちらのアプリかは切り替えボタンの行き先
   （⇄ スコアブック / ⇄ 成績アプリ）と本文のタブで分かるため。
   2つのアプリで同じ扱いにして、行き来しても高さが変わらないようにしている。 */
@media (max-width: 480px) {
  .header-sub { display: none; }
}
