:root {
  --bg: #0f1720;
  --card: #182230;
  --card2: #1f2c3d;
  --accent: #2dd4bf;
  --accent2: #f59e0b;
  --text: #e8eef5;
  --muted: #93a3b5;
  --danger: #f87171;
  --ok: #34d399;
  --border: #2a3a4d;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 14px 80px; }

header.site {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15,23,32,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
header.site .bar { max-width: 860px; margin: 0 auto; padding: 10px 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
header.site .logo { font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; }
header.site .logo .ball { color: var(--accent2); }
header.site nav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
header.site nav a { padding: 6px 10px; border-radius: 999px; font-size: .9rem; color: var(--text); background: var(--card); }
header.site nav a:hover { background: var(--card2); text-decoration: none; }

h1 { font-size: 1.5rem; margin: 18px 0 6px; }
h2 { font-size: 1.2rem; margin: 26px 0 10px; border-left: 4px solid var(--accent); padding-left: 10px; }
h3 { font-size: 1.02rem; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.open { background: rgba(52,211,153,.18); color: var(--ok); }
.badge.closed { background: rgba(248,113,113,.18); color: var(--danger); }
.badge.elim { background: rgba(248,113,113,.18); color: var(--danger); }
.badge.cat { background: var(--card2); color: var(--accent); }

.btn { display: inline-block; cursor: pointer; border: 1px solid var(--border); background: var(--card2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: .95rem; font-weight: 600; }
.btn:hover { background: #28384c; text-decoration: none; }
.btn.primary { background: var(--accent); color: #04211d; border-color: var(--accent); }
.btn.primary:hover { background: #25b8a6; }
.btn.warn { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn.full { display: block; width: 100%; text-align: center; }

input[type=text], input[type=number], textarea, select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; font-size: 1rem; font-family: inherit;
}
textarea { resize: vertical; min-height: 60px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; }

/* チーム選択グリッド */
.group { margin: 14px 0; }
.group .glabel { font-weight: 700; color: var(--accent2); margin-bottom: 6px; }
.teams-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .teams-grid { grid-template-columns: repeat(3, 1fr); } }

.team-pick { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--card); cursor: pointer; user-select: none; }
.team-pick .flag { font-size: 1.5rem; line-height: 1; }
.team-pick .name { font-size: .92rem; font-weight: 600; }

/* 国旗SVG画像（Windowsでも確実に表示） */
.flag-img { width: 1.7em; height: 1.27em; object-fit: cover; border-radius: 3px;
  vertical-align: -0.22em; box-shadow: 0 0 0 1px rgba(0,0,0,.25); background: #2a3a4d; flex: 0 0 auto; }
.flag-img.lg { width: 2.2em; height: 1.65em; }
.team-pick input { position: absolute; opacity: 0; pointer-events: none; }
.team-pick.checked { border-color: var(--accent); background: rgba(45,212,191,.12); box-shadow: 0 0 0 1px var(--accent) inset; }
.team-pick.elim { opacity: .55; }
.team-pick.elim .name { text-decoration: line-through; }

.counter { font-variant-numeric: tabular-nums; font-weight: 700; }
.counter.over { color: var(--danger); }

.cat-block { margin: 22px 0; }

/* チーム選択チップ（選択済み） */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; min-height: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px;
  background: rgba(45,212,191,.12); border: 1px solid var(--accent); font-size: .95rem; font-weight: 600; }
.chip.elim { opacity: .6; border-color: var(--danger); background: rgba(248,113,113,.1); }
.chip .chip-x { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem;
  line-height: 1; padding: 0 0 0 2px; }
.chip .chip-x:hover { color: var(--danger); }

/* 検索コンボボックス */
.combo { position: relative; margin-top: 4px; }
.combo-input { width: 100%; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 320px; overflow-y: auto; background: var(--card2); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.combo-item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border); }
.combo-item:last-child { border-bottom: none; }
.combo-item:hover { background: #28384c; }
.combo-item .ci-name { font-weight: 600; flex: 1; }
.combo-item.elim .ci-name { text-decoration: line-through; opacity: .7; }
.cat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  position: sticky; top: 52px; background: var(--bg); padding: 8px 0; z-index: 5; }
.cat-head .title { font-weight: 800; font-size: 1.08rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .85rem; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rank { font-weight: 800; font-size: 1.05rem; width: 2.4em; }
.rank.r1 { color: #ffd24a; }
.rank.r2 { color: #cfd8e3; }
.rank.r3 { color: #d8a06a; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.switch { position: relative; width: 50px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--card2); border: 1px solid var(--border); border-radius: 999px; transition: .15s; }
.slider:before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: rgba(45,212,191,.3); border-color: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(22px); background: var(--accent); }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 5px 0; }
.bar-row .lab { width: 40%; min-width: 120px; }
.bar-track { flex: 1; background: var(--card2); border-radius: 999px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.bar-row .cnt { width: 3.5em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.stat-team { padding: 4px 0 8px; border-bottom: 1px solid rgba(42,58,77,.5); margin-bottom: 4px; }
.cmt-preview { display: block; margin: 2px 0 0 calc(40% + 0px); padding: 4px 0 0; font-size: .85rem; color: var(--text); text-decoration: none; }
@media (max-width: 559px) { .cmt-preview { margin-left: 0; } }
.cmt-preview:hover { text-decoration: none; }
.cmt-preview .cmt-count { font-weight: 700; color: var(--accent); }
.cmt-preview .cmt-body { color: var(--muted); }
.cmt-preview:hover .cmt-body { color: var(--text); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.tabs a, .tabs button { padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); color: var(--text); cursor: pointer; }
.tabs .active { background: var(--accent); color: #04211d; border-color: var(--accent); }

.flash { padding: 10px 14px; border-radius: 10px; margin: 10px 0; }
.flash.ok { background: rgba(52,211,153,.15); color: var(--ok); border: 1px solid rgba(52,211,153,.4); }

.comment { border-top: 1px solid var(--border); padding: 9px 0; }
.comment .meta { font-size: .8rem; color: var(--muted); }
.comment.anon .who { font-style: italic; color: var(--muted); }

.url-cell { font-family: ui-monospace, monospace; font-size: .8rem; word-break: break-all; }

details.team-comment > summary { cursor: pointer; color: var(--accent); font-size: .85rem; list-style: none; }
details.team-comment > summary::-webkit-details-marker { display: none; }

footer.site { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 0; }
