/* 管理画面スタイル。スマートフォンを基準に設計し、PC はレスポンシブで広げる。
   トークン（色・角R・余白・タップ最小サイズ）は既存ランキングサイトの管理画面と揃えてある。 */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1a1d21;
  --text-muted: #626a72;
  --border: #dfe3e8;
  --primary: #2f6df0;
  --primary-ink: #ffffff;
  --danger: #d9463e;
  --warn: #b7791f;
  --warn-bg: #fff5e0;
  --ok: #1f8a52;
  --ok-bg: #e6f5ec;
  --info-bg: #e8f0fe;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --space: 16px;
  --tap: 46px; /* タップ最小サイズ */
  --shadow: 0 1px 3px rgba(20, 24, 33, .08), 0 4px 16px rgba(20, 24, 33, .05);
  --header-h: 56px;
  font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); }

/* --- ヘッダー --- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 var(--space);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header .brand { font-weight: 700; font-size: 16px; text-decoration: none; color: inherit; }
.app-header .brand small { color: var(--text-muted); font-weight: 500; font-size: 12px; }
.app-header nav { display: flex; align-items: center; gap: 10px; }

.container { max-width: 960px; margin: 0 auto; padding: var(--space); }

/* --- ボタン（全ボタンの基本サイズを統一） --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: filter .12s ease;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-block { display: flex; width: 100%; }

/* --- カード --- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: var(--space); margin-bottom: var(--space);
}
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .meta { color: var(--text-muted); font-size: 13px; }

/* --- 状態ピル（色だけに依存せず文字でも示す） --- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.pill.status-draft { background: var(--surface-2); color: var(--text-muted); }
.pill.status-published { background: var(--ok-bg); color: var(--ok); }
.pill.status-finished { background: var(--surface-2); color: var(--text); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: #fdecea; color: var(--danger); border-color: var(--danger); }

/* --- タブ（大会内のページ切替） --- */
.topbar { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; }
.topbar::-webkit-scrollbar { display: none; }
.topbar .tb {
  flex: 0 0 auto; display: flex; align-items: center; min-height: 44px;
  padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
  text-decoration: none; border: 1px solid var(--border); background: #fff; color: var(--text);
}
.topbar .tb.active { background: var(--primary); color: #fff; border-color: transparent; }

/* --- フォーム --- */
.field { margin-bottom: var(--space); }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .help { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.field .req { color: var(--danger); font-weight: 700; margin-left: 3px; }
input[type=text], input[type=password], input[type=url], input[type=number],
input[type=datetime-local], input[type=date], input[type=time], select, textarea {
  width: 100%; min-width: 0; max-width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 16px; background: var(--surface); color: var(--text);
  box-sizing: border-box;
}
input[type=date], input[type=time], input[type=datetime-local] {
  -webkit-appearance: none; appearance: none;
}
input[type=color] { width: 56px; min-height: 44px; padding: 2px; border-radius: var(--radius-sm); }
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; min-width: 0; }
.row > .fixed { flex: 0 0 auto; }

/* --- アラート --- */
.alert { border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: var(--space); font-size: 14px; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid var(--danger); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #e6c66a; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #a9d9bd; }
.alert-info { background: var(--info-bg); color: var(--primary); border: 1px solid #b9d0fb; }

/* --- リスト --- */
.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rowlist li:last-child { border-bottom: none; }
.rowlist .grow { flex: 1; min-width: 0; }
/* 長いライバー名・固有IDでも行が横へはみ出さない（inline のままだと省略が効かない）。 */
.rowlist .grow .sub,
.rowlist .name {
  display: block; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rowlist .grow .sub { color: var(--text-muted); font-size: 12px; }
.thumb { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: 0 0 auto; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; border: 1px solid var(--border); }

/* --- 空状態 --- */
.empty { text-align: center; padding: 36px 20px; color: var(--text-muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.inline-form { display: inline; margin: 0; }

/* --- 表 --- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* --- トーナメント配置（管理画面） --- */
.slot-grid { display: grid; gap: 12px; }
.slot-box { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; background: #fff; }
.slot-box h4 { margin: 0 0 8px; font-size: 14px; }
.slot-line { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.slot-line label { flex: 0 0 34px; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.slot-line select { flex: 1 1 auto; }

/* --- 個人戦の入力行 --- */
.bout-row { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px; background: #fff; }
.bout-row .no { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.bout-side { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.bout-side .who { flex: 1 1 auto; min-width: 0; }
.bout-side .pts { flex: 0 0 120px; }
.bout-vs { text-align: center; font-size: 12px; font-weight: 800; color: var(--text-muted); letter-spacing: .1em; margin: 4px 0; }

/* --- PC 拡張 --- */
@media (min-width: 768px) {
  .container { padding: 24px; }
  .grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space); }
  .grid-2 > .card { margin-bottom: 0; }
  .slot-grid { grid-template-columns: repeat(2, 1fr); }
}
