/* ───────────────────────────────────────────
   リセット・ベース
─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d14;
  --bg2: #16161f;
  --bg3: #1e1e2a;
  --border: #2a2a3a;
  --accent: #c8962a;
  --accent2: #e5b84a;
  --text: #e8e8f0;
  --text2: #9090a8;
  --danger: #c84040;
  --speaking: #4aad5a;
  --radius: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
}

/* ───────────────────────────────────────────
   共通コンポーネント
─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--accent); color: #000; width: 100%; margin-top: 16px; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-small { padding: 8px 14px; font-size: 13px; }
.btn-mute { background: var(--bg3); color: var(--text); border: 1px solid var(--border); padding: 10px 16px; }
.btn-mute.muted { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-leave { background: var(--danger); color: #fff; padding: 10px 16px; }

.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }

.select {
  padding: 8px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}

.screen { padding: 24px 16px; min-height: 100vh; }

/* ───────────────────────────────────────────
   ホーム画面
─────────────────────────────────────────── */
.home-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

.logo { font-size: 2.5rem; font-weight: 700; color: var(--accent2); letter-spacing: 0.05em; }
.subtitle { color: var(--text2); font-size: 14px; }

.invite-box {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  text-align: left;
}
.invite-label { color: var(--text2); font-size: 13px; margin-bottom: 8px; }
.invite-url {
  word-break: break-all;
  font-size: 12px;
  color: var(--accent2);
  background: var(--bg2);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

/* ───────────────────────────────────────────
   ロビー画面
─────────────────────────────────────────── */
.lobby-screen h2 {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  color: var(--accent2);
}

.section { margin-bottom: 20px; }
.section-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.icon-btn {
  aspect-ratio: 1;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn img { width: 100%; height: 100%; object-fit: cover; }
.icon-btn.selected { border-color: var(--accent); }
.upload-btn { font-size: 20px; }

.upload-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.upload-preview img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }

.voice-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.voice-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}
.voice-option input { display: none; }
.voice-option.selected { border-color: var(--accent); }
.voice-label { font-weight: 600; font-size: 15px; flex-shrink: 0; }
.voice-desc { color: var(--text2); font-size: 13px; }

/* ───────────────────────────────────────────
   通話画面
─────────────────────────────────────────── */
.room-screen {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 100vh;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.room-title { font-size: 16px; font-weight: 700; color: var(--accent2); }
.participant-count { font-size: 13px; color: var(--text2); }
.room-timer { font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; }

.test-status { font-size: 13px; color: var(--accent2); margin-top: 8px; min-height: 20px; }
.test-note { font-size: 12px; color: var(--text2); margin-top: 4px; }

.participants-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
}

.participant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}
.participant-card.speaking { border-color: var(--speaking); }

.card-icon-wrap {
  position: relative;
  width: 60px;
  height: 60px;
}
.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg2);
}
.speaking-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: border-color 0.2s;
}
.participant-card.speaking .speaking-ring {
  border-color: var(--speaking);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.card-name { font-size: 12px; font-weight: 600; text-align: center; word-break: break-all; }
.card-voice { font-size: 11px; color: var(--text2); }

/* メモセクション */
.memo-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0 16px 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 160px;
}
.memo-header {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent2);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.memo-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
}
.memo-item { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.memo-author { color: var(--accent); font-weight: 600; flex-shrink: 0; }
.memo-text { color: var(--text); flex: 1; }
.memo-time { color: var(--text2); font-size: 11px; flex-shrink: 0; }
.memo-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.memo-input { flex: 1; margin: 0; padding: 8px 12px; font-size: 14px; }

/* フッター */
.room-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}
.voice-selector { display: flex; align-items: center; gap: 6px; flex: 1; }
.footer-label { font-size: 12px; color: var(--text2); white-space: nowrap; }
