:root {
  --bg: #0f1218;
  --panel: #171b23;
  --line: #2a303c;
  --text: #e6e9ef;
  --muted: #8a93a3;
  --accent: #4da3ff;
  --kill: #ff5a5a;
  --down: #ffb347;
  font-family: system-ui, -apple-system, "Hiragino Sans", sans-serif;
  font-size: 13px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr); /* 中身の長さで画面より広がらないように */
  height: 100vh;
}

button, input, select { font: inherit; color: inherit; }

.muted { color: var(--muted); font-weight: normal; }

/* --- 上のバー */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 700; letter-spacing: 0.04em; }
.match-form { display: flex; gap: 6px; flex: none; }
.match-form button { white-space: nowrap; }
.match-form input {
  width: 300px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-family: ui-monospace, monospace;
}
.match-form button, .play {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #222836;
  cursor: pointer;
}
.match-form button:hover, .play:hover { background: #2b3243; }
.match-info { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- マップと右の欄 */
.main {
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 0;
}
.map-wrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #0b2a4a; }
#map { display: block; width: 100%; height: 100%; cursor: grab; }
#map.dragging { cursor: grabbing; }
.message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: rgba(15, 18, 24, 0.72);
  color: var(--text);
  font-size: 15px;
  text-align: center;
  pointer-events: none;
}
.progress {
  width: 220px;
  max-width: 70%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}
.progress-fill { width: 0; height: 100%; background: var(--accent); transition: width 0.6s ease; }
/* 解析中は止まって見えないように、回る輪を出す */
.message.busy::before {
  content: "";
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.map-hint {
  position: absolute;
  left: 10px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  color: #cfd5df;
  font-size: 11px;
  pointer-events: none;
}
.zone-badge {
  position: absolute;
  right: 10px;
  bottom: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(10, 12, 16, 0.72);
  text-align: right;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.zone-phase { font-size: 18px; font-weight: 700; }
.zone-phase .total { color: var(--muted); font-size: 13px; font-weight: 600; }
.zone-state { color: #cfd5df; font-size: 12px; }
.zone-state.shrinking { color: #d9b3ff; }
.tooltip {
  position: absolute;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(10, 12, 16, 0.92);
  border: 1px solid var(--line);
  pointer-events: none;
  white-space: nowrap;
  line-height: 1.5;
}

/* チームとキルフィードは、すき間（ページの背景色）と見出しの帯で区切る */
.side {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--bg);
}
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.panel h2 {
  margin: 0;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  font-weight: 700;
  background: #1f2531;
  border-bottom: 1px solid var(--line);
}
.teams, .feed { list-style: none; margin: 0; padding: 6px 6px 8px; overflow-y: auto; }

.team {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 6px;
  align-items: start;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.team:hover { background: #1f2430; }
.team.focus { background: #243049; }
.team.out { opacity: 0.45; }
.team .place { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.team .members { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.member { display: flex; align-items: center; gap: 6px; min-width: 0; }
.member .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member.dead .name { text-decoration: line-through; color: var(--muted); }
.member.knocked .name { color: var(--down); }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; }
.team .kills { color: var(--muted); font-variant-numeric: tabular-nums; }

.feed li {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.feed li:hover { background: #1f2430; }
.feed .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.feed .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .kind-self { color: var(--muted); }
.feed .icon { display: inline-block; width: 15px; height: 15px; margin: 0 5px; vertical-align: -3px; }
.feed .icon svg { display: block; width: 100%; height: 100%; }

/* --- 下のシークバー */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.play { width: 40px; height: 32px; padding: 0; font-size: 14px; }
.seek { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.timeline { width: 100%; height: 18px; display: block; cursor: pointer; }
#seek { width: 100%; margin: 0; accent-color: var(--accent); }
.clock { font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
.speed { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.toggle { display: flex; align-items: center; gap: 4px; color: var(--muted); white-space: nowrap; }

@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 1fr 240px; }
  .side { grid-template-rows: none; grid-template-columns: 1fr 1fr; border-left: 0; border-top: 1px solid var(--line); }
  .match-form input { width: 180px; }
  /* 狭いときはシークバーを1段目に、ボタン類を2段目に */
  .controls { flex-wrap: wrap; row-gap: 6px; }
  .seek { order: -1; flex-basis: 100%; }
}
