/* =================================================================
   MATCH NOTE — スタジアムのスコアボード風デザイン
   ・ダーク（標準）と、直射日光下向けの「明るい表示」の2種類
   ・文字のコントラストはどちらも高めに確保、ボタンは最低44px
   ================================================================= */

:root {
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  --font-num: "DIN Alternate", "DIN Condensed", "Bahnschrift", "Roboto Condensed", "Roboto", system-ui, sans-serif;

  /* スコアボードは両モード共通で暗い色（数字が最も読みやすい） */
  --board-bg: linear-gradient(180deg, #0f1c16 0%, #060c09 100%);
  --board-line: #22332b;
  --board-ink: #ffffff;
  --board-muted: #8fa398;
  --board-us: #8db4ff;
  --board-them: #ffad84;

  /* チームカラー（試合を開くと、選んだ色から計算した値で上書きされる） */
  --us-on: #ffffff;  --us-bink: #8db4ff;  --us-edge: #1844b0;
  --them-on: #0b0f0d; --them-bink: #ffad84; --them-edge: #c25a14;

  --accent: #c6f432;        /* ピッチのライン風のライム */
  --accent-ink: #0a1204;
  --warn: #ffd23f;
  --radius: 14px;
}

/* ---------- ダーク（標準） ---------- */
:root, :root[data-theme="dark"] {
  --bg: #07100c;
  --bg-glow: radial-gradient(120% 60% at 50% -10%, #12301f 0%, rgba(7, 16, 12, 0) 60%);
  --surface: #101915;
  --surface-2: #17221d;
  --line: #25342d;
  --ink: #f2f6f4;
  --muted: #94a69d;

  --us: #3a78ff;
  --us-ink: #a9c6ff;
  --us-soft: #102043;
  --us-line: #23417f;
  --them: #ff6a2b;
  --them-ink: #ffbf9f;
  --them-soft: #3a1a0d;
  --them-line: #74351b;

  --danger: #ff6b6b;
  --danger-line: #5a2626;
  --ok: #5ee08f;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --toast-bg: #f2f6f4;
  --toast-ink: #07100c;
  color-scheme: dark;
}

/* ---------- 明るい表示（屋外・直射日光向け） ---------- */
:root[data-theme="light"] {
  --bg: #eef2f0;
  --bg-glow: none;
  --surface: #ffffff;
  --surface-2: #f4f7f5;
  --line: #cfd8d3;
  --ink: #08110d;
  --muted: #4f5f57;

  --us: #1f5cff;
  --us-ink: #1544c4;
  --us-soft: #e2eaff;
  --us-line: #b3c7ff;
  --them: #e8560f;
  --them-ink: #a83b06;
  --them-soft: #ffe8dc;
  --them-line: #ffc3a3;

  --danger: #c81e1e;
  --danger-line: #f1bcbc;
  --ok: #15803d;
  --shadow: 0 6px 20px rgba(8, 17, 13, .12);
  --toast-bg: #08110d;
  --toast-ink: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

/* ===== iPhone 17 Pro 向けの調整 ===== */
/* 画面を引っぱったときの「弾むスクロール」を止める（記録中に画面がずれない） */
html, body { overscroll-behavior: none; }
/* ステータスバー（時計・電池）の文字は白なので、上端は常に暗くして読めるようにする */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 30; pointer-events: none;
  height: env(safe-area-inset-top); background: #07100c;
}
/* ボタンを長押ししても、文字選択・拡大鏡・リンクのメニューが出ないように */
button, .btn, .match-card, .resume { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* 横向きでは崩れるので案内を出す（撮影中に回転しても大丈夫なように） */
.rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate {
    display: grid; place-items: center; position: fixed; inset: 0; z-index: 100;
    background: #07100c; color: #fff; font-weight: 900; font-size: 18px; text-align: center; padding: 24px;
  }
}
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.tiny { font-size: 13px; }
.center { text-align: center; }

.boot { display: grid; place-items: center; min-height: 100dvh; }
.boot-mark { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view { min-height: 100dvh; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.pad { padding: 14px 16px 40px; max-width: 640px; margin: 0 auto; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink);
  font: inherit; font-weight: 800; text-decoration: none; letter-spacing: .02em;
  cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none;
  transition: transform .06s, filter .1s;
}
.btn:active { transform: scale(.97); filter: brightness(1.1); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 18px rgba(198, 244, 50, .18); }
.btn.big { min-height: 56px; width: 100%; font-size: 18px; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger-line); }
.btn.wide { width: 100%; margin-top: 28px; }
.btn:disabled { opacity: .35; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; padding: 14px; cursor: pointer; }
.armed { background: var(--warn) !important; border-color: var(--warn) !important; color: #111 !important; box-shadow: 0 0 0 3px rgba(255, 210, 63, .35) !important; }

/* ---------- フォーム ---------- */
label { display: block; font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 12px; letter-spacing: .03em; }
input, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-size: 16px; /* iOSの自動ズーム防止 */
  padding: 13px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.lbl-us { color: var(--us-ink); }
.lbl-them { color: var(--them-ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: var(--danger); font-weight: 800; min-height: 1.4em; margin: 12px 0 0; }
.form-note { margin: -4px 0 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }

/* ---------- ログイン ---------- */
.login { position: relative; overflow: hidden; display: grid; place-items: center; }
.pitch { /* ピッチのセンターサークル */
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background:
    radial-gradient(circle at 50% 30%, transparent 118px, rgba(198, 244, 50, .14) 119px, rgba(198, 244, 50, .14) 121px, transparent 122px),
    radial-gradient(circle at 50% 30%, rgba(198, 244, 50, .2) 0 5px, transparent 6px),
    linear-gradient(180deg, transparent calc(30% - 1px), rgba(198, 244, 50, .12) calc(30% - 1px), rgba(198, 244, 50, .12) calc(30% + 1px), transparent calc(30% + 1px));
}
:root[data-theme="light"] .pitch { opacity: .9; filter: saturate(.5) brightness(.6); }
.login-box { position: relative; width: 100%; max-width: 380px; padding: 40px 16px; text-align: center; }
.login-icon { width: 76px; height: 76px; border-radius: 20px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); }
.brand { font-size: 30px; font-weight: 900; margin-top: 14px; letter-spacing: .06em; }
.brand-sub { margin: 2px 0 26px; font-family: var(--font-num); font-size: 13px; letter-spacing: .4em; color: var(--accent); }
:root[data-theme="light"] .brand-sub { color: #3d6b00; }
.login-box form { text-align: left; }
.brand { letter-spacing: .08em; }

/* ログイン ／ 新規登録 の切り替え */
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.auth-tab {
  min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; touch-action: manipulation;
}
.auth-tab.on { background: var(--accent); color: var(--accent-ink); }
.agree { display: flex; align-items: flex-start; gap: 10px; color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.6; margin: 4px 0 16px; }
.agree input { width: 22px; height: 22px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.agree a { color: var(--accent); }
:root[data-theme="light"] .agree a { color: #3d6b00; }
.req { font-size: 11px; color: var(--accent-ink); background: var(--accent); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.err.info { color: var(--ink); font-weight: 600; white-space: pre-line; line-height: 1.7; }
.legal-links { font-size: 12px; color: var(--muted); margin-top: 18px; text-align: center; }
.legal-links a, .small-link { color: var(--muted); text-decoration: underline; font-size: 12px; padding: 4px; }
.home-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Pitch45（運営メディア）への導線。ロゴの文字が白なので、明るい表示でも暗い背景の上に置く */
.p45-promo {
  display: grid; justify-items: center; gap: 8px; margin-top: 18px; padding: 18px 16px 16px;
  border-radius: 18px; text-decoration: none; color: #fff;
  background: var(--board-bg); border: 1px solid var(--board-line); box-shadow: var(--shadow);
}
.p45-by { font-family: var(--font-num); font-size: 11px; letter-spacing: .35em; color: var(--board-muted); }
.p45-logo { width: 190px; height: auto; display: block; }
.p45-copy { font-size: 12px; line-height: 1.6; color: #c9d3ce; font-weight: 700; }
.p45-cta {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; margin-top: 4px;
  border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 15px;
}
.p45-promo:active { filter: brightness(1.15); }
/* 試合一覧の上：Pitch45の帯（コンパクト） */
.p45-banner {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 10px 14px;
  min-height: 56px; border-radius: 16px; text-decoration: none;
  background: var(--board-bg); border: 1px solid var(--board-line);
}
.p45-banner img { height: 22px; width: auto; display: block; flex-shrink: 0; }
.p45-banner-text { flex: 1; font-size: 12px; line-height: 1.45; font-weight: 700; color: #c9d3ce; }
.p45-banner-go { font-size: 26px; line-height: 1; color: var(--accent); font-weight: 900; }
.p45-banner:active { filter: brightness(1.15); }

/* アイコンボタン（使い方・表示切り替え） */
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  cursor: pointer; touch-action: manipulation;
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .fill { fill: currentColor; stroke: none; }
.icon-btn:active { background: var(--surface-2); }

/* 使い方ページ */
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.help-toc a {
  font-size: 13px; font-weight: 800; text-decoration: none; color: var(--ink);
  padding: 7px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line);
}
.help h2 { scroll-margin-top: calc(env(safe-area-inset-top) + 70px); }

.p45-mini {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: fit-content; min-height: 44px; margin: 0 auto 10px; padding: 6px 16px;
  border-radius: 99px; background: var(--board-bg); border: 1px solid var(--board-line); text-decoration: none;
}
.p45-mini span { font-family: var(--font-num); font-size: 11px; letter-spacing: .15em; color: var(--board-muted); }
.p45-mini img { height: 20px; width: auto; display: block; }
.action-msg { text-align: center; line-height: 1.8; font-weight: 700; margin-bottom: 14px; }
.verify-to { text-align: center; line-height: 1.8; margin: 0 0 16px; }
.verify-to b { word-break: break-all; font-size: 17px; }
#v-verify .link { display: block; margin: 0 auto; padding: 10px; }

/* 利用規約・プライバシーポリシー */
.doc { line-height: 1.85; font-size: 14px; }
.doc h2 { font-size: 16px; margin: 28px 0 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.doc ol, .doc ul { padding-left: 1.4em; margin: 8px 0; }
.doc li { margin: 4px 0; }
.doc ul ul, .doc ol ul { margin: 6px 0; }
.doc p { margin: 8px 0; }
.doc .contact { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.doc .contact p { margin: 2px 0; }
.doc-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- 上部バー ---------- */
.appbar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px;
  margin-top: calc(-1 * env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar-brand { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 18px; letter-spacing: .05em; padding-left: 4px; }
.appbar-icon { width: 30px; height: 30px; border-radius: 8px; }
.appbar-title { flex: 1; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .btn.ghost { color: var(--muted); }

/* ---------- 試合一覧 ---------- */
.home-actions { display: grid; gap: 8px; }
.home-note { margin: 8px 4px 0; }
.status.plan { background: rgba(198, 244, 50, .1); color: var(--accent); font-family: var(--font-num); font-size: 12px; }
.mc-score.vs { font-size: 16px; color: var(--board-muted); font-family: var(--font); font-weight: 800; }

/* 試合情報（登録・編集） */
.match-dialog { width: min(96vw, 520px); max-height: 92dvh; margin: 4dvh auto auto; overflow-y: auto; padding: 14px 16px 18px; }
.md-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.md-head h3 { margin: 0; font-size: 18px; }
.match-dialog > .muted { margin: 0 0 12px; }
.md-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; margin-top: 6px; }
.md-actions .btn { min-height: 54px; font-size: 16px; }
#md-delete { margin-top: 18px; }
.wide-top { width: 100%; margin: -2px 0 12px; font-size: 14px; }
/* 2行のボタン：1行目が見出し、2行目が補足。どちらも途中で折り返さない */
.btn.two-line { flex-direction: column; gap: 1px; padding: 8px 14px; line-height: 1.3; white-space: nowrap; }
.btn.two-line small { font-size: 12px; font-weight: 600; color: var(--muted); }
.team-block { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.team-input { border-left: 10px solid var(--team, var(--line)); }
.sw-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 800; color: var(--muted); margin: -2px 2px 6px; }
.sw-name { color: var(--ink); font-size: 14px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1; min-height: 44px; border-radius: 12px; cursor: pointer;
  background: var(--sw); border: 2px solid rgba(128, 128, 128, .45);
  touch-action: manipulation; position: relative;
}
.swatch.on { outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--bg); }
:root[data-theme="light"] .swatch.on { outline-color: #08110d; }
.swatch.on::after { /* 選択中のチェック */
  content: "✓"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 20px; font-weight: 900; color: #fff; text-shadow: 0 0 3px #000, 0 0 6px #000;
}

/* 記録中の試合に戻る */
.resume {
  display: grid; gap: 4px; margin-bottom: 12px; padding: 14px 16px;
  border-radius: 18px; text-decoration: none; color: var(--board-ink);
  background: var(--board-bg); border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(198, 244, 50, .12), var(--shadow);
}
.resume-label { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 900; font-size: 14px; letter-spacing: .04em; }
.resume-label i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.resume-teams { font-family: var(--font-num); font-size: 20px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-teams b { font-family: var(--font); font-size: 16px; }
.resume-teams .us { color: var(--us-bink); }
.resume-teams .them { color: var(--them-bink); }
.resume-phase { color: var(--board-muted); font-size: 13px; font-weight: 800; }
.list .month { font-size: 12px; font-weight: 900; color: var(--muted); letter-spacing: .1em; margin: 6px 4px -2px; }
#hist-count { font-weight: 700; margin-left: 4px; }

/* 時間の区切りを修正 */
.times { margin-top: 12px; }
.disclosure {
  width: 100%; min-height: 44px; display: flex; justify-content: space-between; align-items: center;
  background: none; border: 0; color: var(--ink); font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; padding: 0;
}
#times-body { margin-top: 8px; }
.times-rows { display: grid; gap: 8px; margin: 10px 0 4px; }
.time-row { display: grid; grid-template-columns: 6.6em 1fr 4.8em auto; align-items: center; gap: 6px; }
.time-row label { margin: 0; font-size: 14px; color: var(--ink); }
.time-row input, .time-row select {
  margin: 0; padding: 10px 8px; min-width: 0; min-height: 44px;
  font-family: var(--font-num); font-size: 18px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink);
}
.time-row select { -webkit-appearance: none; appearance: none; text-align: center; }
.time-row .btn { white-space: nowrap; padding: 0 8px; }

/* テキスト出力 */
.export { margin-bottom: 8px; }
.export-title { font-size: 14px; letter-spacing: .08em; margin-bottom: 8px; }
.export textarea {
  margin: 0 0 10px; font-size: 13px; line-height: 1.6; resize: vertical;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, var(--font);
  background: var(--bg); white-space: pre;
}
.sec { font-size: 13px; color: var(--muted); letter-spacing: .12em; margin: 26px 4px 10px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list .empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }
.match-card {
  display: block; padding: 12px 14px 14px; border-radius: 18px;
  background: var(--board-bg); border: 1px solid var(--board-line);
  color: var(--board-ink); text-decoration: none; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.match-card::before, .match-card::after { /* 左右にチームカラーの帯 */
  content: ""; position: absolute; top: 0; bottom: 0; width: 4px;
}
.match-card::before { left: 0; width: 6px; background: var(--us); }
.match-card::after { right: 0; width: 6px; background: var(--them); }
.match-card:active { filter: brightness(1.15); }
.mc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--board-muted); }
.mc-top > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 6px; }
.mc-team { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-team.us { color: var(--us-bink); }
.mc-team.them { color: var(--them-bink); text-align: right; }
.mc-score { font-family: var(--font-num); font-size: 30px; font-weight: 700; text-align: center; line-height: 1; font-variant-numeric: tabular-nums; }
.mc-score i, .score-digits i, .sum-score i { font-style: normal; color: var(--board-muted); margin: 0 .18em; }
.mc-pk { font-size: 12px; color: var(--accent); margin-top: 3px; letter-spacing: .05em; }
.status { flex-shrink: 0; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: rgba(255, 255, 255, .08); color: var(--board-muted); letter-spacing: .05em; }
.status.live { background: rgba(198, 244, 50, .14); color: var(--accent); display: inline-flex; align-items: center; gap: 5px; }
.status.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* =================================================================
   記録画面
   ================================================================= */
.rec {
  display: flex; flex-direction: column; gap: 7px;
  position: fixed; inset: 0; overflow: hidden; /* 画面に固定：指で引っぱっても動かない */
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  padding: calc(env(safe-area-inset-top) + 6px) 8px calc(env(safe-area-inset-bottom) + 8px);
}

/* スコアボード */
.board {
  position: relative; overflow: hidden; flex-shrink: 0;
  background: var(--board-bg); border: 1px solid var(--board-line);
  border-radius: 18px; padding: 6px 8px 10px; color: var(--board-ink);
  box-shadow: var(--shadow);
}
.board::before { /* センターライン＋サークル */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, transparent 52px, rgba(198, 244, 50, .09) 53px, rgba(198, 244, 50, .09) 54px, transparent 55px),
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(198, 244, 50, .07) calc(50% - .5px), rgba(198, 244, 50, .07) calc(50% + .5px), transparent calc(50% + .5px));
}
.board-top { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 32px; }
.board-back { color: var(--board-muted); text-decoration: none; font-weight: 800; font-size: 14px; padding: 6px 4px; }
.phase-pill {
  font-weight: 900; font-size: 13px; letter-spacing: .06em;
  padding: 4px 12px; border-radius: 99px;
  color: var(--accent); background: rgba(198, 244, 50, .1); border: 1px solid rgba(198, 244, 50, .35);
}
.phase-pill[data-phase="pk"] { color: #111; background: var(--warn); border-color: var(--warn); }
.phase-pill[data-phase="post"], .phase-pill[data-phase="pre"] { color: var(--board-muted); background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); }
.board-right { justify-self: end; display: flex; align-items: center; gap: 6px; }
.board-edit {
  min-height: 34px; padding: 0 10px; border-radius: 99px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16); color: var(--board-ink);
  font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; touch-action: manipulation; white-space: nowrap;
}
.team-side { cursor: pointer; border-radius: 12px; }
.team-side:active { background: rgba(255, 255, 255, .06); }
.sync { font-size: 11px; font-weight: 800; color: var(--ok); letter-spacing: .04em; }
:root[data-theme="light"] .sync { color: #5ee08f; }
.sync.pending { color: var(--warn); }
.sync.offline { color: var(--board-muted); }

.board-main { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; }
.team-side {
  min-width: 0; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: none; border: 0; padding: 4px; border-radius: 12px;
  font: inherit; cursor: pointer; touch-action: manipulation; color: inherit;
}
.team-side .tname { max-width: 100%; font-weight: 900; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-side.us .tname { color: var(--us-bink); }
.team-side.them .tname { color: var(--them-bink); }
.team-side::before { /* チームカラーの帯 */
  content: ""; width: 34px; height: 5px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .25);
}
.team-side.us::before { background: var(--us); }
.team-side.them::before { background: var(--them); }

.board-center { text-align: center; padding: 0 4px; }
.score-digits { font-family: var(--font-num); font-size: 48px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.pk-pill { display: inline-block; margin-top: 3px; font-size: 12px; font-weight: 900; color: #111; background: var(--warn); border-radius: 99px; padding: 1px 9px; }
.clock {
  font-family: var(--font-num); font-size: 28px; font-weight: 700; line-height: 1.1; margin-top: 2px;
  color: var(--accent); font-variant-numeric: tabular-nums; text-shadow: 0 0 14px rgba(198, 244, 50, .35);
}
.clock.dim { color: var(--board-muted); text-shadow: none; }
.wall { font-family: var(--font-num); font-size: 12px; color: var(--board-muted); font-variant-numeric: tabular-nums; letter-spacing: .05em; }

/* 時間帯の操作 */
.phase-actions { display: flex; gap: 6px; flex-shrink: 0; }
.pa { flex: 1; min-height: 50px; font-size: 16px; padding: 0 8px; }
.pa.main { flex: 1.5; }
.pa.go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pa.end { background: var(--surface); }
.pa.sub { background: transparent; color: var(--muted); }

/* PK戦の○×表示 */
.pk-board { display: grid; gap: 4px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; flex-shrink: 0; }
.pk-row { display: grid; grid-template-columns: 5.5em 1fr auto; align-items: center; gap: 8px; min-height: 28px; }
.pk-name { font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-row.us .pk-name { color: var(--us-ink); }
.pk-row.them .pk-name { color: var(--them-ink); }
.pk-dots { display: flex; flex-wrap: wrap; gap: 4px; }
.pk-dots i {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-style: normal; font-size: 10px; font-weight: 900; font-family: var(--font-num);
}
.pk-dots i.in { background: var(--ok); color: #04210f; }
.pk-dots i.miss { background: transparent; border: 2px solid var(--danger); color: var(--danger); }
.pk-row b { font-family: var(--font-num); font-size: 22px; min-width: 1.2em; text-align: right; }

/* 記録ボタン */
.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ev {
  position: relative; overflow: hidden;
  border-radius: var(--radius); border: 1px solid;
  font: inherit; font-size: 21px; font-weight: 900; letter-spacing: .04em;
  touch-action: manipulation; -webkit-user-select: none; user-select: none; cursor: pointer;
  transition: transform .06s, filter .1s;
}
/* ボタンはユニフォームの色で塗る（文字色は自動で白/黒を選択） */
.ev { border-width: 2px; }
.ev.us { background: var(--us); color: var(--us-on); border-color: var(--us-edge); }
.ev.them { background: var(--them); color: var(--them-on); border-color: var(--them-edge); }
.ev::after { /* 上から下へうっすら光沢 */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 55%, rgba(0, 0, 0, .1));
}
.ev.strong { font-size: 25px; }
.ev.strong::before { content: "⚽"; margin-right: 6px; font-size: 20px; }
.ev:active { transform: scale(.96); filter: brightness(1.15); }
/* 試合前・試合後・休憩中に押せないボタン */
.ev.off { opacity: .28; filter: grayscale(.7); }
.ev.off:active { transform: none; filter: grayscale(.7); }
.ev.hit { animation: hit .4s ease-out; }
@keyframes hit {
  0% { box-shadow: 0 0 0 4px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
/* PK戦のボタン */
.grid.pk .ev { font-size: 24px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.grid.pk .ev b { font-size: 34px; font-weight: 900; line-height: 1; }
/* PK失敗は「枠線だけ」にして成功と見分けやすく */
.grid.pk .ev.t-pk_miss { background: var(--surface); border-width: 3px; }
.grid.pk .ev.t-pk_miss.us { color: var(--us-ink); border-color: var(--us); }
.grid.pk .ev.t-pk_miss.them { color: var(--them-ink); border-color: var(--them); }
.grid.pk .ev.t-pk_miss::after { display: none; }

/* 直前の記録・取消・メモ */
.last-row { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; flex-shrink: 0; }
.last {
  min-height: 56px; min-width: 0; padding: 4px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  font: inherit; font-size: 14px; font-weight: 700; text-align: left; color: var(--ink); cursor: pointer;
}
.last span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.last.flash { animation: flash .7s ease-out; }
@keyframes flash { 0% { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(198, 244, 50, .35); } 100% { border-color: var(--line); box-shadow: none; } }
.undo, .memo { min-height: 56px; min-width: 70px; border-radius: var(--radius); background: var(--surface); }

/* 背の低い画面（iPhone SEなど）では、スコアボードを詰めてボタンの高さを確保 */
@media (max-height: 700px) {
  .rec { gap: 5px; }
  .board { padding: 4px 8px 6px; }
  .board-top { min-height: 28px; }
  .team-side { min-height: 54px; gap: 3px; }
  .score-digits { font-size: 40px; }
  .clock { font-size: 24px; margin-top: 0; }
  .pa { min-height: 46px; }
  .last, .undo, .memo { min-height: 50px; }
}

/* =================================================================
   記録一覧
   ================================================================= */
.summary { display: grid; gap: 10px; margin-bottom: 12px; }
.sum-board {
  position: relative; overflow: hidden;
  background: var(--board-bg); border: 1px solid var(--board-line); border-radius: 18px;
  padding: 14px; color: var(--board-ink); box-shadow: var(--shadow);
}
.sum-meta { font-size: 12px; color: var(--board-muted); text-align: center; }
.sum-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 6px; }
.sum-team { font-weight: 900; font-size: 16px; overflow-wrap: anywhere; }
.sum-team.us { color: var(--us-bink); text-align: right; }
.sum-team.them { color: var(--them-bink); }
.sum-score { font-family: var(--font-num); font-size: 46px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.sum-pk { text-align: center; margin-top: 6px; }
.sum-pk { color: #111; background: var(--warn); font-weight: 900; font-size: 13px; border-radius: 99px; padding: 2px 10px; width: fit-content; margin: 6px auto 0; }
.goals { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--board-line); font-size: 14px; display: grid; gap: 4px; }
.goals li::before { content: "⚽ "; }
.goals li.us { color: var(--us-bink); }
.goals li.them { color: var(--them-bink); }
.goals .gt { font-family: var(--font-num); color: var(--board-ink); }
.goals .muted { color: var(--board-muted); }


.actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.actions .btn { padding: 0 6px; white-space: nowrap; }

.log { list-style: none; margin: 4px 0 0; padding: 0; position: relative; }
.log::before { content: ""; position: absolute; left: 58px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.log li.empty { color: var(--muted); text-align: center; padding: 24px; border: 1px dashed var(--line); border-radius: 14px; }
.log li.marker { position: relative; display: flex; align-items: center; gap: 8px; margin: 10px 0; padding-left: 34px; }
.log li.marker span { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-weight: 900; font-size: 13px; padding: 4px 12px; border-radius: 99px; letter-spacing: .04em; }
.log li.marker small { color: var(--muted); font-family: var(--font-num); font-size: 12px; }
.row {
  position: relative; display: grid; grid-template-columns: 46px 1fr auto; gap: 2px 26px; align-items: baseline;
  padding: 10px 8px 10px 4px; cursor: pointer; border-radius: 12px;
}
.row:active { background: var(--surface-2); }
.row::before { /* タイムライン上の点（チームカラー） */
  content: ""; position: absolute; left: 53px; top: 15px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 3px var(--bg);
}
.row.us::before { background: var(--us); border: 2px solid var(--us-edge); }
.row.them::before { background: var(--them); border: 2px solid var(--them-edge); }
.row.is-goal::before, .row.t-pk_in::before { width: 16px; height: 16px; left: 51px; top: 13px; }
.row.is-goal .what { font-size: 17px; }
.row .t { font-family: var(--font-num); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; }
.row .what { font-weight: 800; }
.row .who { font-size: 13px; margin-right: 6px; }
.row.us .who { color: var(--us-ink); }
.row.them .who { color: var(--them-ink); }
.row .w { font-family: var(--font-num); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .note { grid-column: 2 / 4; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.row.t-goal .what { font-size: 17px; }

/* =================================================================
   背番号・詳細の選択パネル
   ================================================================= */
/* 後ろの記録ボタンが見えるよう薄めに（押すとそのまま次の記録になる） */
.detail-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 5; }
.detail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  max-width: 640px; margin: 0 auto; max-height: 84dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 10px);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(40px); } to { transform: none; } }
.handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 10px; }
.detail-title { font-weight: 900; font-size: 16px; margin: 0 4px 10px; }
.detail.us .detail-title { color: var(--us-ink); }
.detail.them .detail-title { color: var(--them-ink); }
.dgroup { margin-bottom: 10px; }
.dname { font-size: 12px; font-weight: 900; color: var(--muted); margin: 0 4px 5px; letter-spacing: .1em; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.chip {
  min-height: 46px; padding: 0 4px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 800;
  touch-action: manipulation; -webkit-user-select: none; user-select: none; cursor: pointer;
}
.chip:active { filter: brightness(1.2); }
/* 結果の「ゴール」は目立たせる（選ぶと得点になる） */
.chip[data-o="ゴール"] { border: 2px solid var(--accent); font-weight: 900; }
.chip[data-o="ゴール"]::before { content: "⚽ "; }
.chip[data-o="ノーゴール"] { color: var(--muted); }
/* エリア・形・部位の開け閉め */
.more-toggle {
  width: 100%; min-height: 44px; margin: 0 0 10px; border-radius: 12px;
  border: 1px dashed var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; touch-action: manipulation;
}
.chips.four .chip { white-space: nowrap; letter-spacing: -.02em; }
.slot[data-slot] small { white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.detail.us .chip.on { background: var(--us); border-color: var(--us-edge); color: var(--us-on); }
.detail.them .chip.on { background: var(--them); border-color: var(--them-edge); color: var(--them-on); }
.detail.us { border-top: 6px solid var(--us); }
.detail.them { border-top: 6px solid var(--them); }

/* 試合後の修正：チーム・種類の変更 */
.edit-group { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.chips.two { grid-template-columns: 1fr 1fr; }
.chips.four { grid-template-columns: repeat(4, 1fr); }
.chips.four .chip { font-size: 14px; padding: 0 2px; }
.detail .chip.tchip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail .chip.tchip.us.on { background: var(--us); border-color: var(--us-edge); color: var(--us-on); }
.detail .chip.tchip.them.on { background: var(--them); border-color: var(--them-edge); color: var(--them-on); }

/* 背番号の入力（よく使う番号＋数字キー） */
.num-head { display: flex; align-items: stretch; gap: 8px; margin: 0 0 6px; }
.slots { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.slot-arrow { font-size: 20px; font-weight: 900; color: var(--muted); }
.slot { /* 番号の入力欄（交代は OUT / IN の2つ） */
  flex: 1; min-width: 0; min-height: 54px; padding: 4px 10px;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink);
  font: inherit; cursor: pointer; touch-action: manipulation; text-align: left;
}
.slot small { font-size: 11px; font-weight: 900; color: var(--muted); letter-spacing: .04em; }
.slot b { font-family: var(--font-num); font-size: 28px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.detail.us .slot.active { border-color: var(--us); box-shadow: 0 0 0 2px var(--us); }
.detail.them .slot.active { border-color: var(--them); box-shadow: 0 0 0 2px var(--them); }
.detail.us .slot.active b { color: var(--us-ink); }
.detail.them .slot.active b { color: var(--them-ink); }
.slot b.typing::after { content: "_"; animation: pulse 1s steps(2) infinite; margin-left: 2px; }
.chips.recent { grid-template-columns: repeat(6, 1fr); margin-bottom: 6px; }
.chip.num { font-family: var(--font-num); font-size: 22px; min-height: 48px; }
.keypad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.key {
  min-height: 50px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--ink);
  font-family: var(--font-num); font-size: 24px; font-weight: 700;
  touch-action: manipulation; -webkit-user-select: none; user-select: none; cursor: pointer;
}
.key:active { background: var(--accent); color: var(--accent-ink); }
.key-clear { min-height: 54px; min-width: 60px; font-size: 20px; }
.detail-hint { margin: 2px 4px 8px; }
.detail-foot { /* 内容が長くてスクロールしても、完了ボタンは常に見える位置に固定 */
  position: sticky; bottom: 0; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 6px;
  padding-top: 8px; background: var(--surface);
}
.detail-foot .btn { min-height: 54px; padding: 0 6px; white-space: nowrap; }

/* メモ入力 */
dialog {
  border: 1px solid var(--line); border-radius: 20px; padding: 16px;
  width: min(92vw, 480px); margin-top: 8vh;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h3 { font-size: 16px; margin-bottom: 10px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%);
  background: var(--toast-bg); color: var(--toast-ink); padding: 11px 18px; border-radius: 99px;
  font-weight: 800; font-size: 14px; z-index: 10; max-width: 90vw; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
