/* VALORANT 登傑戦 — 運営システム
   墨と和紙を思わせる配色で、数字が読みやすいことを最優先にしている。 */

:root {
  --ink:        #14110E;
  --paper:      #F7F3EA;
  --paper-alt:  #EFE8DA;
  --line:       #D8CDB8;
  --sumi:       #1B1611;
  --accent:     #C1441E;
  --gold:       #A87D1E;
  --muted:      #5E564D;  /* 背景（和紙色）とのコントラストを十分に取る */
  --ok:         #4B7A46;
  --info:       #6B6259;  /* 図の補助色（押せる色の青とまぎれないよう灰色） */
  /* 押せるもの（ボタン・リンク・開閉）だけに使う色。Apple のガイドラインの
     「色の意味を1つに保つ」に合わせ、押せない文字・図には使わない。 */
  --tint:         #1A5FB4;
  --tint-pressed: #144A8C;
  --tint-soft:    #E3ECF8;  /* 控えめなボタンの地 */
  --tint-soft-pressed: #CFDDF2;
  --danger:       #B8361A;  /* 取り消せない操作・エラーだけに使う赤 */
  --danger-soft:  #FBE9E4;
  --danger-soft-pressed: #F5D3C9;
  --radius:     2px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP",
               system-ui, sans-serif;
  font-size: 17px;  /* Apple の本文の標準サイズ */
  line-height: 1.7;
}

/* 文中のリンク（ページの移動だけ）。押せる色の青に下線も付け、色だけに頼らない。
   操作（押すと何かが始まるもの）はリンクではなくボタンにする。 */
a {
  color: var(--tint); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: .22em;
}
a:hover { color: var(--tint-pressed); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--tint);
  outline-offset: 2px;
}

/* --- ヘッダー --- */

.site-header {
  background: var(--sumi);
  color: #F3EDE0;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--gold);
}
.site-header .brand { display: flex; align-items: center; gap: 14px; }
.site-header .brand-logo { height: 52px; width: 52px; display: block; }
.site-header .brand-text { display: flex; flex-direction: column; gap: 5px; }
.site-header .brand-text span { font-size: 20px; letter-spacing: .16em; font-weight: 700; }
.site-header .brand-wordmark { height: 16px; width: auto; display: block; opacity: .9; }
.site-nav { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; font-size: 13px; }
.site-nav a { color: #E6DCC8; text-decoration: none; }
.site-nav a:hover { color: #E6DCC8; text-decoration: underline; text-decoration-thickness: 1px; }
/* ログアウトは<a>ではなくPOSTフォームのボタン（CSRF対策）だが、見た目は
   他のnavリンクと揃える。formはdisplay:contentsで自身の箱を消し、中の
   buttonが直接.site-navのflex項目として並ぶようにする */
.site-nav form { display: contents; }
.site-nav button.link-btn {
  background: none; border: none; padding: 0; margin: 0;
  color: #E6DCC8; font: inherit; cursor: pointer;
  /* 共通のボタンの見た目（高さ44px・角丸など）は、メニューのログアウトには当てない */
  display: inline; min-height: 0; border-radius: 0; line-height: inherit;
}
.site-nav button.link-btn:hover, .site-nav button.link-btn:active { background: none; color: #E6DCC8; text-decoration: underline; }

/* --- レイアウト --- */

.container { max-width: 1060px; margin: 0 auto; padding: 30px 22px 70px; }

/* 文字は Apple の UI デザインのヒント（読みやすい大きさ・十分なコントラスト・
   ゆとりのある行間）に合わせる。本文は16px、小さい文字も13px以上。日本語は
   字間を広げると読みにくくなるので、見出しも字間はほぼ詰めたままにする。 */
h1 { font-size: 26px; letter-spacing: .02em; line-height: 1.4; margin-bottom: 6px; }
h2 {
  font-size: 20px; letter-spacing: .02em; margin: 34px 0 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
h3 { font-size: 17px; margin: 18px 0 8px; }
h4 { font-size: 16px; }

.lead { color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.hint { font-size: 14px; color: var(--muted); }
.text-right { text-align: right; }

/* --- 表 --- */

table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 10px 0; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--paper-alt); font-weight: 700; font-size: 14px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- フォーム --- */

/* 入力欄・ボタンは指で押しやすいよう高さ44px以上（Apple のタップ領域の目安）。
   入力欄の文字は16px（スマホで入力時に画面が勝手に拡大されないため）。 */
input, select, button, textarea { font-family: inherit; font-size: 16px; }
input[type=text], input[type=password], input[type=date],
input[type=number], select, textarea {
  min-height: 44px; padding: 9px 12px; border: 1px solid #BFB29A;
  background: #fff; border-radius: 8px; width: 100%; color: var(--ink);
}
input[type=number] { width: 84px; text-align: right; }
input[type=checkbox] { width: 20px; height: 20px; vertical-align: middle; margin-right: 6px; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.field-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field-inline select { width: auto; min-width: 180px; max-width: 100%; }
.form-narrow { max-width: 460px; }

/* ボタンは1つの形（高さ44px・角丸10px・太字16px）にそろえ、役割は塗り方だけで分ける
   （Apple のボタンの指針：大きさではなくスタイルで、いちばん押す操作を示す）。
   - 塗り（既定）：その画面でいちばん押す操作。1画面に1〜2個まで。
   - 控えめ（secondary）：それ以外の操作。同じ青の薄い地。
   - 取り消せない操作（destructive）：赤の薄い地。いちばん押す操作にはしない。
   押したとき（:active）は色を濃くして、押せたことが分かるようにする。 */
button, .button {
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 20px; background: var(--tint); color: #fff;
  border: none; border-radius: 10px; cursor: pointer;
  font-size: 16px; font-weight: 700; line-height: 1.3; text-align: center;
}
button:hover, .button:hover { background: var(--tint-pressed); color: #fff; text-decoration: none; }
button:active, .button:active { background: #0F3A6E; }
button.secondary, .button.secondary { background: var(--tint-soft); color: var(--tint); }
button.secondary:hover, .button.secondary:hover { background: var(--tint-soft-pressed); color: var(--tint-pressed); }
button.secondary:active, .button.secondary:active { background: #B9CDEB; }
button.destructive, .button.destructive { background: var(--danger-soft); color: var(--danger); }
button.destructive:hover, .button.destructive:hover { background: var(--danger-soft-pressed); color: #8E2812; }
button.destructive:active, .button.destructive:active { background: #EDBFB2; }
button:disabled, .button[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }

/* 取り消せない操作の確認（app.js が data-confirm のフォームで出す）。
   キャンセルを左、実行を右に置き、最初はキャンセルに合わせておく。 */
dialog.confirm {
  border: none; border-radius: 14px; padding: 22px 22px 18px; max-width: 420px; width: calc(100% - 32px);
  color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
dialog.confirm::backdrop { background: rgba(20, 17, 14, .45); }
dialog.confirm h3 { margin: 0 0 6px; font-size: 18px; }
dialog.confirm p { font-size: 15px; color: var(--muted); }
dialog.confirm .confirm-actions { display: flex; gap: 10px; margin-top: 18px; }
dialog.confirm .confirm-actions button { flex: 1; }

/* --- 部品 --- */

.card {
  background: #fff; border: 1px solid var(--line);
  padding: 20px; margin-bottom: 16px; border-radius: 12px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.metric { background: #fff; border: 1px solid var(--line); padding: 14px 16px; border-radius: 12px; }
.metric .metric-label { font-size: 13px; color: var(--muted); }
.metric .metric-value {
  font-size: 26px; font-weight: 700;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.metric .metric-value.compact { font-size: 17px; }
.metric .metric-note { font-size: 13px; color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 10px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 999px; vertical-align: middle;
}
.badge-division { background: var(--sumi); color: #F3EDE0; border-color: var(--sumi); }
.badge-title { background: #fff; color: var(--gold); border-color: var(--gold); }
/* 豪傑戦の称号「豪傑」専用。badge-title より格上に見えるよう、塗りつぶしにする */
.badge-elite { background: var(--gold); color: #fff; border-color: var(--gold); }

/* 状態のバッジ（完了・進行中・受付中・休み など）。色だけに頼らず文字でも状態を書く */
.pill {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  font-size: 14px; font-weight: 700; white-space: nowrap; vertical-align: middle;
}
.pill-done { background: #E4E0D8; color: #4A433B; }
.pill-live { background: #E5EFE3; color: #2F5A2B; }
.pill-open { background: #F6EBCF; color: #6E500C; }  /* 自分がやること（注目の金） */
.pill-wait { background: #EFE8DA; color: #5E564D; }
.pill-gold { background: var(--gold); color: #fff; }

.notice {
  padding: 13px 16px; margin-bottom: 18px; border-radius: 8px;
  border-left: 4px solid var(--danger); background: #FBF1EE; font-size: 15px;
}
.notice.notice-ok { border-color: var(--ok); background: #F0F5EF; }

.empty {
  color: var(--muted); font-size: 15px; padding: 22px; text-align: center;
  border: 1px dashed #BFB29A; background: #fff; border-radius: 12px;
}

/* 押せる一覧（Apple のリストと同じく、行全体を押せて、右端の「›」で先に進めることを示す）。
   行の高さは60px（タップ領域の目安44px以上）。 */
.list { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 10px 0; }
.list-row {
  text-decoration: none;
  display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding: 10px 16px; color: var(--ink); border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
a.list-row:hover { background: #FBF8F1; text-decoration: none; }
.list-row .list-main { flex: 1; min-width: 0; }
.list-row .list-title { display: block; font-size: 17px; font-weight: 700; }
.list-row .list-sub { display: block; font-size: 14px; color: var(--muted); }
.list-row .chev { color: var(--muted); font-size: 24px; line-height: 1; }
.list-row form { display: inline; }

/* 長い説明は「詳しく」を押したときだけ開く */
details.more { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; }
details.more > summary {
  list-style: none; cursor: pointer; min-height: 44px; padding: 10px 16px;
  display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "詳しく ▾"; margin-left: auto; color: var(--tint); font-weight: 400; font-size: 14px; }
details.more[open] > summary::after { content: "閉じる ▴"; }
details.more > .more-body { padding: 0 16px 14px; font-size: 15px; color: var(--muted); }
details.more > .more-body p + p { margin-top: 8px; }

/* ホームの「次にやること」 */
.next-card { background: var(--sumi); color: #F3EDE0; border-radius: 14px; padding: 18px 20px; margin: 8px 0 20px; }
.next-card .next-where { display: block; color: #D9CDB4; font-size: 14px; margin-bottom: 2px; }
.next-card .next-what { display: block; font-size: 21px; font-weight: 700; margin-bottom: 4px; }
.next-card .next-detail { color: #E6DCC8; font-size: 15px; margin-bottom: 12px; }
/* 暗い地の上でも、ボタンはほかの画面と同じ見た目のまま（青の塗り）にする */
.next-card .button { box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }

/* ラウンドページの「あなたの試合」 */
.my-match { background: #fff; border: 2px solid var(--gold); border-radius: 14px; padding: 18px; margin: 12px 0 20px; }
.my-match h3 { margin-top: 0; font-size: 19px; }
/* 手順の進み具合（押せないので、ボタンに見えない「進捗バー」の形にする） */
.steps { display: flex; gap: 6px; margin: 6px 0 14px; }
.step { flex: 1 1 0; min-width: 0; font-size: 13px; padding-top: 6px; border-top: 4px solid var(--line); color: var(--muted); }
.step.step-done { border-top-color: var(--ok); color: #2F5A2B; }
.step.step-done::before { content: '✓ '; }
.step.step-now { border-top-color: var(--gold); color: var(--ink); font-weight: 700; }
.step.step-now::before { content: '今：'; color: #6E500C; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.team-card { border: 1px solid var(--line); background: #fff; padding: 14px; border-radius: 10px; }
.team-card h4 { font-size: 16px; margin-bottom: 8px; }
.team-card ul { list-style: none; font-size: 15px; }
.team-card li {
  padding: 5px 0; border-bottom: 1px dotted var(--line);
  display: flex; justify-content: space-between; gap: 10px;
}
.team-card li:last-child { border-bottom: none; }
.team-card li .role { color: var(--muted); font-size: 13px; }
.team-card.team-mine { background: #FBF6E9; border-color: var(--gold); }
.team-card li.me span:first-child { font-weight: 700; }

.versus {
  text-align: center; color: var(--muted); font-size: 13px;
  letter-spacing: .3em; margin: 6px 0;
}
.match-block { padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.match-block:last-child { border-bottom: none; }
.match-block-locked { border: 1px dashed #BFB29A; border-radius: 12px; padding: 16px; background: #fff; }

.warning-text { color: var(--danger); }

/* 運営だけが使う操作パネルのまとまり */
.admin-zone { margin-top: 30px; padding-top: 6px; border-top: 3px solid var(--sumi); }
.admin-zone > h2 { border-bottom: none; margin-top: 12px; }

/* --- トーナメント表（横向きSVGブラケット図） -------------------------------
   列＝木構造上の深さ。ボックスの中身はSVGのforeignObjectに通常のHTMLを
   そのまま入れており、線（コネクタ）だけを素のSVGで描いている。
   決勝トーナメントは毎ラウンド勝者チームがそのまま次の試合に入るため
   試合単位の線が事実と一致するが、最強・最弱決定（勝敗ブロック）は毎ラウンド
   全員のチームを組み直すため、ラウンド（ブロック）全体を1つのかたまりとして
   次のブロックへまとめて線をつなぐ表現にしている。勝ち上がりの流れは金
   （勝者の箱と同じ色）で描く。赤・青は「危ない操作」「押せるもの」の色なので使わない。 */

.swiss-svg { overflow-x: auto; padding: 10px 10px 24px; }
.swiss-svg svg { display: block; }

/* foreignObject内はSVGドキュメント側のスコープになるらしく、:root で定義した
   CSS変数(var(--line)等)を素直に継承しない環境があったため、この節の中だけは
   カスタムプロパティに頼らず実際の色値を直書きする */
.bracket-link { opacity: .8; }
.bracket-col-label {
  font-size: 12.5px; letter-spacing: .06em; font-weight: 600; fill: #A87D1E;
}
.bracket-champion-label { font-size: 12px; fill: #A87D1E; }

.svg-box-wrap { display: block; width: 100%; height: 100%; overflow: hidden; }
.svg-box {
  box-sizing: border-box; width: 100%; height: 100%; overflow-y: auto;
  border: 1px solid #D8CDB8; background: #ffffff; padding: 10px;
  font-size: 12px; line-height: 1.5; font-family: "Hiragino Kaku Gothic ProN",
  "Yu Gothic", "Noto Sans JP", system-ui, sans-serif; color: #14110E;
}
.svg-box-bye { display: flex; flex-direction: column; }
.svg-team { border-bottom: 1px dotted #D8CDB8; padding: 4px; margin-bottom: 6px; }
.svg-team:last-of-type { border-bottom: none; margin-bottom: 0; }
.svg-team strong { display: block; font-size: 12px; margin-bottom: 3px; }
.svg-team ul { list-style: none; }
.svg-team li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.svg-team li .role { color: #7A7168; font-size: 10.5px; }
.svg-team-winner { background: #FBF6E9; border: 1px solid #A87D1E; border-radius: 2px; }
.svg-box .versus { margin: 2px 0; font-size: 10px; letter-spacing: .2em; color: #7A7168; }
.svg-box .button {
  /* トーナメント表の箱は高さが決まっているので44pxは当てないが、色と角丸は
     ほかのボタンと同じにする（foreignObject内なので色は直書き） */
  min-height: 28px; line-height: 1.3;
  display: inline-flex; padding: 4px 12px; font-size: 12px; background: #1A5FB4;
  color: #fff; border: none; border-radius: 8px; text-decoration: none; font-weight: 700;
}
.svg-box .button.secondary { background: #E3ECF8; color: #1A5FB4; }
.svg-box .hint { font-size: 11px; color: #7A7168; }

.bar-chart { max-width: 100%; height: auto; }
.bar-chart .bar-label { font-size: 11px; fill: var(--sumi); }
.bar-chart .bar-value { font-size: 11px; fill: var(--muted); }
.bar-chart .bar-zero-line { stroke: var(--line); stroke-width: 1; }

.site-footer {
  border-top: 1px solid var(--line); margin-top: 40px; padding: 18px 22px;
  text-align: center; font-size: 11px; color: var(--muted); letter-spacing: .1em;
}

/* --- 画面幅の対応 --- */

@media (max-width: 640px) {
  .site-header { gap: 12px; }
  .site-header .brand-logo { height: 40px; width: 40px; }
  .site-nav { margin-left: 0; gap: 12px; }
  .container { padding: 20px 14px 60px; }
  h1 { font-size: 23px; }
  table { font-size: 14px; }
  th, td { padding: 9px 8px; }
  .scroll-x { overflow-x: auto; }
  .list-row { padding: 10px 14px; }
  .field-inline select, .field-inline button { width: 100%; }
}

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

/* --- 参加者管理：1人1行。行を押すと、その人の変更・操作が開く --- */
details.player { border-bottom: 1px solid var(--line); }
details.player:last-child { border-bottom: none; }
details.player > summary { list-style: none; cursor: pointer; border-bottom: none; }
details.player > summary::-webkit-details-marker { display: none; }
details.player > summary:hover { background: #FBF8F1; }
.player-toggle { color: var(--tint); font-size: 15px; white-space: nowrap; }
.player-toggle::after { content: " ▾"; }
details.player[open] > summary { background: #FBF8F1; }
details.player[open] .player-toggle::after { content: " ▴"; }
.player-body { padding: 4px 16px 18px; background: #FBF8F1; }
.player-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 20px; }
.player-forms .field-inline { flex-wrap: nowrap; }
.player-forms .field-inline input, .player-forms .field-inline select { flex: 1; min-width: 0; width: auto; }
.player-danger {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed #BFB29A;
}

/* 成績ページの「直近の試合」：行を押すとポイントの内訳が開く */
.history .history-points { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.breakdown { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; padding-top: 12px; font-size: 15px; }
.breakdown dt { color: var(--muted); }
.breakdown dd .hint { display: block; font-size: 13px; }

/* 順位表：階級の切り替え（Apple のセグメントコントロールの形） */
.segmented { display: inline-flex; border: 1px solid var(--tint); border-radius: 10px; overflow: hidden; margin: 6px 0 10px; }
.segmented a {
  min-height: 44px; min-width: 64px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--tint); text-decoration: none; font-weight: 700; border-left: 1px solid var(--tint);
}
.segmented a:first-child { border-left: none; }
.segmented a:hover { background: var(--tint-soft); }
.segmented a[aria-current="page"] { background: var(--tint); color: #fff; }
h2 .role-count { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 10px; }
table.ranking th small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
table.ranking th { white-space: nowrap; }
/* ロールごとの表で列の位置がそろうよう、列幅を固定する */
table.ranking { table-layout: fixed; min-width: 600px; }
table.ranking col.c-pos { width: 8%; }
table.ranking col.c-name { width: 26%; }
table.ranking col.c-avg { width: 14%; }
table.ranking col.c-games { width: 9%; }
table.ranking col.c-rate { width: 10%; }
table.ranking col.c-rel { width: 16%; }
table.ranking col.c-zone { width: 17%; }
table.ranking td { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  /* スマホでは横にはみ出さないよう詰める（昇格圏・降格圏の列を隠さない） */
  table.ranking { min-width: 0; }
  table.ranking th { white-space: normal; font-size: 12px; }
  table.ranking th small { display: none; }
  table.ranking th, table.ranking td { padding: 8px 4px; }
  table.ranking col.c-pos { width: 9%; }
  table.ranking col.c-name { width: 24%; }
  table.ranking col.c-avg { width: 14%; }
  table.ranking col.c-games { width: 10%; }
  table.ranking col.c-rate { width: 12%; }
  table.ranking col.c-rel { width: 13%; }
  table.ranking col.c-zone { width: 18%; }
  table.ranking .pill { font-size: 12px; padding: 2px 6px; }
}
table.ranking .you { white-space: nowrap; }
table.ranking .sort-key { background: #FBF6E9; }
table.ranking thead th.sort-key { background: #F3E6C4; }
table.ranking tr.zone-up td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
table.ranking tr.zone-down td:first-child { box-shadow: inset 4px 0 0 #9E958B; }
table.ranking tr.mine td { font-weight: 700; }
table.ranking .you { margin-left: 6px; font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--sumi); color: #fff; }
.pill-down { background: #ECE7E1; color: #5E564D; }
.unplayed { font-size: 15px; line-height: 2; }

/* --- クリップ --- */
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 12px 0; }
.clip-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.clip-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #2b2f3a; text-decoration: none; overflow: hidden; }
.clip-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.clip-thumb .ph { position: absolute; inset: 0; background: linear-gradient(135deg, #2b2f3a, #5b4a6e); }
.clip-thumb .ph-twitch { background: linear-gradient(135deg, #2d1f4d, #6441a5); }
.clip-thumb .play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%; background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff;
}
.clip-thumb .src { position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .65); padding: 2px 8px; border-radius: 4px; }
.clip-thumb.small { width: 120px; flex: none; border-radius: 8px; }
.clip-thumb.small .play { width: 32px; height: 32px; font-size: 13px; }
.clip-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.clip-title { font-size: 15px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.clip-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.clip-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; }
button.like { min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 15px; }
button.like.liked, button.like.liked:hover { background: var(--tint); color: #fff; }
.like-count { font-variant-numeric: tabular-nums; }
.rank-no { font-size: 13px; font-weight: 700; color: #6E500C; }
button.small-button { min-height: 36px; padding: 0 12px; font-size: 14px; margin-top: 8px; }
.clip-row { gap: 12px; }
.approve-row { display: grid; grid-template-columns: 180px 1fr auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.approve-row:last-child { border-bottom: none; }
.approve-row .clip-thumb { border-radius: 8px; }
.approve-actions { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 640px) {
  .approve-row { grid-template-columns: 1fr; }
  .clip-thumb.small { width: 96px; }
}

/* --- 「仕組みを見る」 --- */
/* 要点の箇条書き（本文の大きさで、項目のあいだに余白をとる） */
.points-list { margin-left: 1.3em; font-size: 16px; }
.points-list li + li { margin-top: 8px; }
/* 1試合のポイントの式 */
.formula { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 6px 0 14px; }
.formula-term {
  flex: 1; min-width: 150px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; font-weight: 700; font-size: 16px;
}
.formula-term small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.formula-op { display: flex; align-items: center; font-size: 22px; color: var(--muted); }
h2[id] { scroll-margin-top: 12px; }

/* 図（押せないので、ボタンと見分けられるよう角の丸い四角・青を使わない） */
.diagram { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 12px 0; }
.diagram-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.diagram-note { font-size: 14px; color: var(--muted); margin-top: 12px; }
.chain { display: flex; align-items: stretch; gap: 6px; }
.chain-node {
  flex: 1 1 0; min-width: 0; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; background: var(--paper);
}
.chain-node b { display: block; font-size: 15px; line-height: 1.4; }
.chain-node .sub { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.chain-node .no {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; border: 1.5px solid var(--sumi); font-size: 12px; font-weight: 700; margin-bottom: 4px;
}
.chain-node.goal { border-color: var(--gold); background: #FBF6E9; }
.chain-node.goal .no { border-color: var(--gold); color: var(--gold); }
.chain-arrow { align-self: center; flex: none; color: var(--muted); font-size: 18px; }
.minis { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.mini { font-size: 12px; padding: 1px 8px; border: 1px dashed #BFB29A; border-radius: 4px; background: #fff; }

svg.dg { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; }
.dg-box { fill: #fff; stroke: var(--sumi); stroke-width: 1.5; }
.dg-box.dg-out { stroke: #BFB29A; fill: var(--paper-alt); }
.dg-small { font-size: 13px; text-anchor: middle; fill: var(--ink); }
.dg-out-text { fill: #8C8279; text-decoration: line-through; }
.dg-tiny { font-size: 11px; text-anchor: middle; fill: var(--muted); }
.dg-win { fill: none; stroke: var(--gold); stroke-width: 2.5; }
.dg-lose { fill: none; stroke: #BFB29A; stroke-width: 1.5; stroke-dasharray: 4 3; }
.dg-trophy { font-size: 20px; text-anchor: middle; }

.diagram-title small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
table.team-rule { margin: 12px 0 0; }
table.team-rule tbody th { background: none; white-space: nowrap; font-size: 14px; }
table.team-rule thead th:first-child { white-space: nowrap; }

table.rr-matrix { margin: 0 auto; width: auto; min-width: 260px; }
table.rr-matrix th, table.rr-matrix td { text-align: center; padding: 10px 14px; border: 1px solid var(--line); font-size: 14px; }
table.rr-matrix td { background: #fff; font-weight: 700; }
table.rr-matrix td.self {
  background: var(--paper-alt) linear-gradient(to top right, transparent calc(50% - 1px), #BFB29A, transparent calc(50% + 1px));
}

.map-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.map-tile { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--paper-alt); }
.map-tile .map-name { display: block; font-weight: 700; font-size: 14px; }
.map-tile .map-mark { display: block; font-size: 12px; color: var(--muted); }
.map-tile.banned .map-name { text-decoration: line-through; color: #8C8279; }
.map-tile.picked { border: 2px solid var(--gold); background: #FBF6E9; }

table.rest-grid { margin: 0; }
table.rest-grid th, table.rest-grid td { text-align: center; padding: 8px 6px; font-size: 13px; white-space: nowrap; }
table.rest-grid tbody th { text-align: left; background: none; font-weight: 700; }
table.rest-grid td.on { color: #2F5A2B; background: #EEF5EC; }
table.rest-grid td.off { color: var(--muted); background: var(--paper-alt); font-weight: 700; }

.scale-bar { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #E4E0D8, #F6EBCF 50%, var(--gold)); }
.scale-marks { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.scale-marks span { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.scale-marks span:nth-child(2) { align-items: center; text-align: center; }
.scale-marks span:last-child { align-items: flex-end; text-align: right; }
.scale-marks b { font-size: 18px; color: var(--ink); }

.rank-list { list-style: none; margin-top: 6px; font-size: 14px; }
.rank-list li { padding: 3px 0; border-bottom: 1px dotted var(--line); display: flex; gap: 8px; align-items: baseline; }
.rank-list li:last-child { border-bottom: none; }
.rank-list em { font-style: normal; font-size: 12px; padding: 0 6px; border-radius: 4px; }
.rank-list li.q em { background: var(--gold); color: #fff; }
.rank-list li.w em { border: 1px solid var(--gold); color: #6E500C; }

.ladder { display: flex; flex-direction: column; align-items: stretch; max-width: 420px; }
.ladder-step { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; background: var(--paper); display: flex; justify-content: space-between; align-items: baseline; }
.ladder-step.top { border-color: var(--gold); background: #FBF6E9; }
.ladder-step b { font-size: 17px; }
.ladder-step .sub { font-size: 13px; color: var(--muted); }
.ladder-move { display: flex; justify-content: space-between; gap: 8px; padding: 6px 14px; font-size: 13px; }
.ladder-move span:first-child { color: #2F5A2B; }
.ladder-move span:last-child { color: var(--muted); }

@media (max-width: 640px) {
  /* 縦に並べ、番号を左に置いて1つの手順を短くする */
  .chain { flex-direction: column; gap: 2px; }
  .chain-arrow { transform: rotate(90deg); font-size: 14px; line-height: 1.2; }
  .chain-node { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 8px 12px; }
  .chain-node .no { grid-row: span 2; margin: 0; }
  .chain-node > :not(.no) { grid-column: 2; }
}

/* --- 小さな部品（HTML の style="..." 属性の代わり） ----------------------------
   CSP で style 属性を禁止している（style-src に 'unsafe-inline' を入れない）ため、
   見た目の調整はすべてここのクラスで行う。テンプレートに style="..." を書かないこと
   （書いてもブラウザが無視する。test_security で検査している）。
   ほかの部品の余白を上書きできるよう、このファイルの最後に置く。 */

/* 余白（数字は px） */
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-28 { margin-top: 28px; }
.mb-0  { margin-bottom: 0; }
.mb-6  { margin-bottom: 6px; }
.ml-8  { margin-left: 8px; }
.my-6  { margin-top: 6px; margin-bottom: 6px; }
.my-16 { margin-top: 16px; margin-bottom: 16px; }

/* 入力欄・まとまりの最大幅 */
.w-sm { max-width: 260px; }
.w-md { max-width: 320px; }
.w-lg { max-width: 420px; }
.w-xl { max-width: 520px; }

/* 並べ方 */
.block { display: block; }
.grow { flex: 1; }
.min-w-200 { min-width: 200px; }
.inline-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

/* 個別の部品 */
.card-compact { padding: 14px 16px; }
.card-alert { border-left: 4px solid var(--danger); }   /* 運営が見るべき報告 */
.card-danger { border-color: var(--danger); }           /* 差し戻し・エラーの案内 */
.row-muted { opacity: .55; }                            /* 表で対象外の行 */
.points-list-lg { font-size: 15px; }
.invite-code { max-width: 220px; font-size: 20px; letter-spacing: .2em; }
.division-links a[aria-current="page"] { font-weight: 700; }
