/* 暗い地に、状態の色を1つだけ効かせる。スマホの縦持ちで読める大きさにする。 */
:root {
  color-scheme: dark;
  --bg: #14171c;
  --surface: #1d2128;
  --line: #2e343e;
  --fg: #e8ebf0;
  --muted: #9aa3b0;
  --accent: #f0a23a;      /* Factorio の機械の橙 */
  --accent-ink: #1b1305;
  --on: #5fc58a;
  --off: #7c8593;
  --warn: #e8756a;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", "Meiryo", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(40px, env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
}

.top h1 { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: 0.02em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 10px;
}
.card h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.note, .hint, .foot { margin: 0; color: var(--muted); font-size: 0.9rem; }
.foot { text-align: center; }

.servers { display: grid; gap: 16px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.server .name { font-size: 1.3rem; }

.badge {
  flex: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
  color: var(--off);
}
.badge[data-state="running"] { color: var(--on); }
.badge[data-state="starting"], .badge[data-state="stopping"] { color: var(--accent); }
.badge[data-state="failed"] { color: var(--warn); }

.players { margin: 0; font-variant-numeric: tabular-nums; }
.names { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.names li {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1px 10px;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.action { display: grid; gap: 8px; margin-top: 4px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

input {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
button {
  font: inherit;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
}
button.start { padding: 14px 18px; font-size: 1.05rem; }
button:disabled { opacity: 0.5; cursor: default; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.message { margin: 0; min-height: 1.4em; color: var(--warn); font-size: 0.9rem; }
.message.ok { color: var(--on); }
.center { text-align: center; }

.events { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.events li { display: grid; grid-template-columns: auto 1fr; gap: 12px; font-size: 0.9rem; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.events .empty { color: var(--muted); display: block; }

@media (prefers-reduced-motion: no-preference) {
  .badge[data-state="starting"], .badge[data-state="stopping"] { animation: pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.45; } }
}
