/* 暗い地に、選んだサーバーのゲームの色（--accent）を1つだけ効かせる。
   広い画面では、左にサーバーの一覧、右に選んだサーバー。せまい画面では、一覧が上に来る。 */
:root {
  color-scheme: dark;
  --bg: #101319;
  --rail: #0c0e13;
  --surface: #181c24;
  --line: #2a303b;
  --fg: #e9ecf1;
  --muted: #98a1af;
  --accent: #f0a23a;      /* 選んだサーバーの色に、画面の側で入れ替える */
  --accent-ink: #14110a;
  --on: #5fc58a;
  --off: #6f7886;
  --warn: #e8756a;
  --radius: 14px;
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  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;
}
h1, h2, p, ul, ol { margin: 0; }

.brand { color: var(--muted); font-size: 0.85rem; letter-spacing: 0.08em; }
.brand b { color: var(--fg); font-weight: 800; letter-spacing: 0.02em; }
.note, .hint, .foot, .since { color: var(--muted); font-size: 0.9rem; }

/* ---- パスワードを入れる前 ---- */
.door { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.panel {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 12px;
}
.panel h1 { font-size: 1.3rem; }

/* ---- 一覧と、選んだサーバー ---- */
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }

.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: max(22px, env(safe-area-inset-top)) 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.rail .brand { padding: 0 8px; }
.rail .foot { margin-top: auto; padding: 0 8px; font-size: 0.8rem; }

.list { display: grid; gap: 16px; }
.group { display: grid; gap: 4px; }
.group h2 {
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 2px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--muted);
}
.group h2::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }

.item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 400;
}
.item:hover { background: var(--surface); }
.item[aria-current="true"] {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: inset 3px 0 0 var(--accent);
}
.item .text { display: grid; min-width: 0; line-height: 1.35; }
.item .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: 0.8rem; }

.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--off); }
.dot[data-state="running"] { background: var(--on); box-shadow: 0 0 0 3px color-mix(in srgb, var(--on) 22%, transparent); }
.dot[data-state="starting"], .dot[data-state="stopping"] { background: var(--accent); }
.dot[data-state="failed"] { background: var(--warn); }

.stage {
  padding: max(28px, env(safe-area-inset-top)) clamp(16px, 4vw, 44px) max(48px, env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
  align-content: start;
  max-width: 860px;
  width: 100%;
  background: radial-gradient(900px 260px at 0% 0%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%);
}

.hero { display: grid; gap: 4px; padding: 6px 0 10px; }
.game { color: var(--accent); font-size: 0.82rem; font-weight: 800; letter-spacing: 0.14em; }
.title { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.title h1 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.since { min-height: 1.5em; }

.badge {
  flex: none;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 3px 14px;
  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); }

.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 10px;
}
.block h2 { font-size: 1.02rem; font-weight: 700; }

.names { 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.92rem;
  overflow-wrap: anywhere;
}
.names .empty { background: transparent; border-color: transparent; padding-left: 0; color: var(--muted); }

.action { display: grid; gap: 8px; margin-top: 4px; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.action-buttons button { min-height: 44px; }
.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.big { padding: 14px 18px; font-size: 1.08rem; }
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
button.ghost:hover { border-color: var(--accent); }
/* 停止は起動の差し色と区別する。文字でも「停止」と示し、色だけに頼らない。 */
button.danger { background: var(--warn); color: var(--accent-ink); }
button.small { font-weight: 400; }
button:disabled { opacity: 0.5; cursor: default; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.steps, .notes { padding-left: 1.4em; font-size: 0.93rem; display: grid; gap: 4px; }
.notes { color: var(--muted); }
.copy { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copy .label { flex: none; width: 5.5em; color: var(--muted); font-size: 0.9rem; }
.copy code {
  flex: 1 1 12em; min-width: 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.9rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  overflow-wrap: anywhere; user-select: all;
}
.copy button { flex: none; padding: 6px 14px; }

.message { min-height: 1.4em; color: var(--warn); font-size: 0.9rem; }
.message.ok { color: var(--on); }
.message:empty { min-height: 0; }
.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--warn); border-radius: 10px; padding: 8px 14px;
  max-width: calc(100vw - 32px);
}

.events { 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 (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); gap: 12px; padding-bottom: 14px; }
  .rail .foot { display: none; }
  .list { gap: 10px; }
  .stage { padding-top: 18px; }
}

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

/* ---- ログインの入口のボタン、一覧の下の道具、アカウントの名前 ---- */
a { color: var(--accent); }
a.button {
  display: block; text-align: center; text-decoration: none;
  font-weight: 700; color: var(--accent-ink); background: var(--accent);
  border-radius: 10px; padding: 14px 18px; font-size: 1.05rem;
}
a.button:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.tools { display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 12px; }
.item .mark { flex: none; width: 10px; text-align: center; color: var(--muted); font-weight: 700; line-height: 1; }
.rail .foot { display: grid; gap: 4px; }
.rail .foot a { color: var(--muted); }
.empty-list { padding: 0 8px; }

/* ---- サーバーを足す ---- */
.stack { display: grid; gap: 8px; max-width: 420px; }

/* ---- 管理 ---- */
.stage.wide { max-width: 1100px; }
.scroll { overflow-x: auto; }
.grid { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
.grid th, .grid td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.grid tr:first-child th { color: var(--muted); font-weight: 700; font-size: 0.82rem; }
.grid th:first-child { text-align: left; }
.grid .who { font-weight: 700; }
.grid .who span + span { margin-left: 8px; }
.grid td.empty { color: var(--muted); text-align: left; }
.grid input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); vertical-align: middle; padding: 0; }
.grid .via { display: block; color: var(--muted); font-size: 0.72rem; line-height: 1.3; }
.chip { font-size: 0.72rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.chip.warn, .note.warn { color: var(--warn); }
.pwlist { display: grid; gap: 14px; }
.pw { display: grid; gap: 6px; max-width: 520px; }
.pwname { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }

@media (max-width: 760px) {
  .rail .foot { display: grid; margin-top: 0; }
  .rail .foot #rule { display: none; }
}
