:root {
  --bg: #0b0d0c;
  --panel: #121614;
  --line: #24302a;
  --text: #cfe3d6;
  --muted: #6f8a7b;
  --accent: #5dff9d;
  --warn: #ffb347;
  --danger: #ff5a52;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* hidden 属性は、display を指定したクラスより優先する */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.brand { letter-spacing: 0.08em; color: var(--accent); }

.pill {
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}
.pill.ok { color: var(--accent); border-color: var(--accent); }
.pill.bad { color: var(--danger); border-color: var(--danger); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  padding: 16px;
  max-width: 1280px;
  margin: 0 auto;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.screen {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--line);
  overflow: hidden;
}

.screen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.overlay[hidden] { display: none; }

.standby {
  flex-direction: column;
  gap: 10px;
  background: #050606;
  color: var(--muted);
  font-size: 26px;
  letter-spacing: 0.3em;
}
.standby small { font-size: 13px; letter-spacing: 0.05em; max-width: 80%; }

.turn-info { min-height: 1.4em; margin: 4px 0 8px; color: var(--accent); }
.primary.offer { border-color: var(--warn); color: var(--bg); background: var(--warn); }

.blackout {
  flex-direction: column; /* 「SIGNAL LOST」と「RECONNECTING...」を 2 行に */
  background: #000;
  color: var(--danger);
  font-size: 28px;
  letter-spacing: 0.2em;
}

.side { display: flex; flex-direction: column; gap: 16px; }

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

.panel h2 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.telemetry {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 4px 8px;
  margin: 0;
}
.telemetry dt { color: var(--muted); }
.telemetry dd { margin: 0; }
.telemetry dd.ok { color: var(--accent); }
.telemetry dd.warn { color: var(--warn); }
.telemetry dd.bad { color: var(--danger); }
.timestamp dd { font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

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

.name { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.name input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 6px 8px;
  font-family: inherit;
}

button {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 8px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.primary { width: 100%; border-color: var(--accent); color: var(--accent); }
.primary.active { border-color: var(--warn); color: var(--warn); }

.message { min-height: 1.4em; color: var(--warn); margin: 8px 0; }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 64px);
  gap: 6px;
  justify-content: center;
  margin: 12px 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.pad button { font-size: 20px; padding: 0; }
.pad .up { grid-column: 2; grid-row: 1; }
.pad .left { grid-column: 1; grid-row: 2; }
.pad .stop { grid-column: 2; grid-row: 2; color: var(--danger); }
.pad .right { grid-column: 3; grid-row: 2; }
.pad .down { grid-column: 2; grid-row: 3; }
.pad button.held { background: var(--accent); color: var(--bg); }
.pad[aria-disabled="true"] button { opacity: 0.35; pointer-events: none; }

.speed { display: flex; gap: 6px; }
.speed button { flex: 1; }
.speed button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* 画面下のステータス・ティッカー */
body { padding-bottom: 44px; }

.ticker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32px;
  overflow: hidden;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--accent);
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.ticker-track {
  display: inline-flex;
  animation: ticker var(--ticker-duration, 30s) linear infinite;
  will-change: transform;
}

.ticker-text { padding-right: 3em; white-space: pre; } /* 英語の区切りの空白を詰めない */

/* 同じ文字列を 2 つ並べ、半分動いたところで最初に戻すと切れ目なく流れる */
@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; padding-left: 16px; }
  .ticker-text + .ticker-text { display: none; }
}
