/* igolive — dark clean UI */

:root {
  --bg: #101317;
  --panel: #191e24;
  --panel-border: #262d36;
  --text: #d7dde4;
  --muted: #7d8894;
  --accent: #4da3ff;
  --good: #3ecf6e;
  --bad: #e5544d;
  --warn: #e0a93c;
  --board-wood: #b98d4f;
  --board-wood-2: #a97f43;
  --board-line: #33230e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.status-strip {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.status-item { display: inline-flex; align-items: center; gap: 6px; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #555e68;
  display: inline-block;
}
.dot.ok { background: var(--good); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }

.layout {
  display: flex;
  gap: 18px;
  padding: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.board-pane { flex: 0 1 auto; }

#board {
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  cursor: crosshair;
}

.board-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* 画面変化を無視中 (held) — subtle */
.tracking-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--warn);
  text-align: center;
  opacity: 0.85;
}

.side-pane {
  flex: 1 1 320px;
  min-width: 300px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px 14px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.card h2.inline { display: inline; }

.winrate-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
#wr-black-label { color: #f0f2f4; font-weight: 600; }
#wr-white-label { color: var(--muted); font-weight: 600; }

.winrate-bar {
  height: 18px;
  border-radius: 9px;
  background: #e8e6e1; /* white share */
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

.winrate-black {
  height: 100%;
  width: 50%;
  background: #17191c;
  transition: width 0.4s ease;
}

.info-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.info-row strong { color: var(--text); font-weight: 600; }

#history { width: 100%; height: auto; display: block; }

.candidate-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.candidate-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 6px;
}
.candidate-list li.hover { background: #232a33; }
.cand-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #10131a;
  flex: none;
}
.cand-move { min-width: 42px; font-weight: 600; }
.cand-meta { color: var(--muted); font-size: 12px; }

/* 簡易解析 (quick tier: one NN eval, no search): the whole list is an
   estimate — dim it and label it once. */
.candidate-list.quick li:not(.quick-note) { opacity: 0.62; }
.candidate-list .quick-note { padding-bottom: 0; }

/* 直感 (policy filler) rows: greyed, badge without a rank color */
.candidate-list li.policy { opacity: 0.72; }
.candidate-list li.policy .cand-move { font-weight: 500; }
.cand-badge.policy {
  background: #3a424c;
  color: #aeb6bf;
  font-weight: 600;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* live preview (受信映像) */
.live-frame-wrap {
  position: relative;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
  background: #0a0c0f;
  min-height: 40px;
}
#live-img { display: block; width: 100%; height: auto; }
#live-img.hidden { display: none; }
#live-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.live-placeholder {
  display: none;
  padding: 28px 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.live-frame-wrap.no-frame .live-placeholder { display: block; }
.live-status { margin-top: 6px; font-size: 12px; color: var(--muted); }
.live-status strong { color: var(--text); font-weight: 600; }

/* calibration */
details summary { cursor: pointer; }

.calib-frame-wrap {
  position: relative;
  margin-top: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
  background: #0a0c0f;
  min-height: 40px;
}
#calib-img { display: block; width: 100%; height: auto; }
#calib-img.hidden { display: none; }
#calib-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.calib-status { margin-top: 6px; font-size: 12px; color: var(--muted); }

.calib-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  align-items: center;
  font-size: 13px;
}

button {
  background: #232a33;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #2c3540; }
button:disabled { opacity: 0.45; cursor: default; }
#calib-apply:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1017;
  font-weight: 600;
}

select {
  background: #232a33;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 4px 6px;
}

.hidden { display: none !important; }

/* 対局一覧 */
.games-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
#save-game:not(:disabled) {
  background: var(--good);
  border-color: var(--good);
  color: #0b1017;
  font-weight: 600;
}
#save-status { min-height: 16px; }

.games-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  max-height: 220px;
  overflow-y: auto;
}
.games-list .game-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.games-list .game-item:hover { background: #232a33; }
.games-list .game-item.selected {
  background: #232a33;
  border-color: var(--accent);
}
.game-title { font-weight: 600; white-space: nowrap; }
.game-meta { color: var(--muted); font-size: 12px; text-align: right; }
.games-hint { margin-top: 6px; }

/* メイン画面: 「すべての対局を見る (全N局) →」 */
.games-all-link {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.games-all-link:hover { text-decoration: underline; }

/* 対局一覧ページ (/games) */
.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}
.back-link:hover { text-decoration: underline; }

.games-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px;
}
#games-summary { margin-bottom: 8px; min-height: 16px; }

.all-games-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.all-games-list .game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}
.game-row-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.game-row-info .game-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-row-info .game-meta { text-align: left; }
.game-row-actions {
  display: flex;
  gap: 8px;
  flex: none;
}
.game-action {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: #232a33;
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}
.game-action:hover { background: #2c3540; }

.games-more-wrap { margin-top: 12px; text-align: center; }

/* transient toast (deep-link errors etc.) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--warn);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

/* 検討モード bar */
.review-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
}
.review-title {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.review-label { color: var(--muted); font-size: 12px; }
.review-pos {
  min-width: 62px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.review-visits-label { color: var(--muted); }
.review-sgf {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}
.review-sgf:hover { text-decoration: underline; }
#review-analyze:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1017;
  font-weight: 600;
}
.review-status {
  margin-top: 6px;
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
