:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --text: #f1f3f6;
  --muted: #9aa3b2;
  --accent: #2fbf71;
  --talk: #e5484d;
  --border: #2a2f3a;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

h1 { font-size: 20px; margin: 8px 0 16px; }

.badge {
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
}

.room, .hint, .url, .state { text-align: center; }
.hint, .url { color: var(--muted); font-size: 14px; }
.url { word-break: break-all; }

.back {
  display: block;
  width: 100%;
  padding: 14px;
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 700;
  background: var(--accent);
  color: #06130b;
}

.share {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 8px 0 16px;
}
.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.share-btn.line { background: #06c755; border-color: #06c755; color: #fff; }

#qr {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #fff;
  border-radius: 12px;
  width: fit-content;
  margin: 0 auto;
}

.tone {
  display: block;
  margin: 16px 0;
  color: var(--muted);
  font-size: 14px;
}

button {
  font: inherit;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.primary, .secondary {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 18px;
}

.primary { background: var(--accent); color: #06130b; font-weight: 700; }
.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border); margin-top: 16px; }

#ptt {
  display: block;
  width: min(80vw, 320px);
  aspect-ratio: 1;
  margin: 24px auto 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2b313d, #161920);
  border: 6px solid var(--border);
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.08s, border-color 0.08s;
}

#ptt.talking {
  border-color: var(--talk);
  background: radial-gradient(circle at 50% 40%, #5a2326, #2a1214);
  transform: scale(0.97);
}

.state { color: var(--muted); min-height: 1.5em; }
.state.receiving { color: var(--accent); }

#peers {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 8px;
}

#peers li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

#peers li.speaking { border-color: var(--accent); }

/* 自分の番号は一目でわかるよう大きく出す */
.me {
  text-align: center;
  margin: 0 0 12px;
  padding: 10px 12px 12px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 14px;
}
.me-label { display: block; color: var(--muted); font-size: 14px; }
.me-num { display: block; font-size: 44px; line-height: 1.15; color: var(--accent); }
.me-name { display: block; font-size: 26px; font-weight: 700; min-height: 0; }
.me-name:empty { display: none; }
.me-change { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }
.me input { width: 9em; }

/* 参加前の名前の入力 */
.name-field { display: block; margin: 16px 0 0; color: var(--muted); font-size: 14px; }
.name-field input {
  display: block;
  width: 100%;
  margin-top: 6px;
  font: inherit;
  font-size: 20px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.me select, .me input {
  font: inherit;
  font-size: 16px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
}

/* 話す相手の選択（全員／○号車） */
.targets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.targets button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 16px;
  min-width: 72px;
}
.targets button[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #06130b;
  font-weight: 700;
}
.targets button.private[aria-checked="true"] { background: #f5a524; border-color: #f5a524; }

/* 名簿にあるが、いまつながっていない番号 */
.targets button.offline,
#peers li.offline {
  color: #6b7280;
  background: transparent;
  border-style: dashed;
}
.targets button.offline { cursor: default; }

#ptt.private { border-color: #f5a524; }
#ptt .ptt-sub { display: block; font-size: 16px; font-weight: 400; margin-top: 6px; }

/* 個別に呼ばれた時の知らせ */
.call-banner {
  background: #f5a524;
  color: #1a1200;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.error { color: var(--talk); text-align: center; }

details { margin-top: 24px; color: var(--muted); }
pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12px;
  max-height: 240px;
  overflow: auto;
}
