:root {
  --bg: #0d0f12;
  --panel: #171a1f;
  --line: #2a2f37;
  --text: #e9edf2;
  --muted: #8a94a3;
  --ok: #3ddc84;
  --warn: #ffb020;
  --err: #ff5470;
  --a: #3aa0ff;
  --b: #ff7a2f;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  touch-action: manipulation;
}
button:disabled { opacity: .4; }

/* 状態表示 */
.status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 15px; font-weight: 600; }
.v.ok { color: var(--ok); }
.v.warn { color: var(--warn); }
.v.err { color: var(--err); }

/* A/B 表示（全体がタップ領域） */
.tracks {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr auto;
  gap: 12px;
  min-height: 320px;
  touch-action: manipulation;
  cursor: pointer;
}
.track {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto 1fr;
  column-gap: 16px;
  align-items: center;
  padding: 16px 20px;
  overflow: hidden;
  transition: border-color .08s, background-color .08s;
}
.track .tag {
  grid-row: 1 / 4;
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
}
.track .name { font-size: 22px; font-weight: 700; }
.track .mode { font-size: 12px; color: var(--muted); }
.track .state { font-size: 18px; font-weight: 600; color: var(--muted); align-self: end; }

.track.selected .tag, .track.selected .state { color: var(--text); }
/* iOS 15 は color-mix() 非対応のため rgba で指定 */
#track-A.playing { border-color: var(--a); background: rgba(58, 160, 255, .18); }
#track-A.playing .tag { color: var(--a); }
#track-B.playing { border-color: var(--b); background: rgba(255, 122, 47, .18); }
#track-B.playing .tag { color: var(--b); }
.track.selected:not(.playing) { border-color: var(--muted); }

.progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  background: transparent;
}
.progress .bar { height: 100%; width: 0; background: var(--b); }

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

.controls { display: flex; }
.controls button { flex: 1; }

/* メンテナンス */
.maint {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
}
.maint summary { color: var(--muted); }
.maint-body p { margin: 8px 0; }
.maint .row { display: flex; gap: 8px; }
.maint .row button { flex: 1; font-size: 14px; }
.small { font-size: 12px; color: var(--muted); white-space: pre-line; }
code { color: var(--text); }

/* START オーバーレイ */
#start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 15, 18, .94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}
#start-overlay.hidden { display: none; }
.start-box { text-align: center; max-width: 360px; width: 100%; }
.start-box h1 { font-size: 22px; margin: 0 0 8px; }
.start-box p { color: var(--muted); }
#btn-start {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: .05em;
  background: var(--ok);
  color: #04130a;
  border: none;
  margin: 16px 0;
}
#btn-start:disabled { background: var(--line); color: var(--muted); opacity: 1; }
.error { color: var(--err) !important; white-space: pre-line; }
