:root {
  --bg: #0e1016;
  --bg-soft: #151923;
  --card: #1a1f2c;
  --card-border: #262d3d;
  --text: #e6e9f0;
  --text-dim: #8b93a7;
  --accent-1: #22d3ee;
  --accent-2: #6366f1;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(700px 500px at 85% 20%, rgba(99, 102, 241, 0.12), transparent 60%),
    radial-gradient(500px 500px at 50% 100%, rgba(52, 211, 153, 0.06), transparent 60%);
}

.hidden { display: none !important; }

.entry {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.entry-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
}

.logo svg { width: 36px; height: 36px; }

.logo-sm { width: 34px; height: 34px; border-radius: 10px; margin: 0; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35); }
.logo-sm svg { width: 18px; height: 18px; }

.entry-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1px;
}

.subtitle {
  margin: 10px 0 28px;
  color: var(--text-dim);
  font-size: 13px;
}

.entry-card input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.entry-card input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-lg {
  width: 100%;
  margin-top: 18px;
  padding: 15px;
  font-size: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.hint { margin-top: 14px; color: var(--text-dim); font-size: 12px; }

.app {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 140px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 20px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }

.online-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  font-size: 13px;
}

.online-badge svg { width: 15px; height: 15px; color: var(--green); }
.online-badge #onlineCount { color: var(--green); font-weight: 700; }

.phase-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  margin-bottom: 22px;
  font-size: 13px;
}

.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  animation: phasePulse 1.6s ease-in-out infinite;
}

@keyframes phasePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.phase-badge {
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.phase-timer {
  margin-left: auto;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.phase-grab { color: var(--green); }
.phase-grab .phase-badge { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.phase-refill { color: #38bdf8; }
.phase-refill .phase-badge { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.phase-locked { color: var(--text-dim); }
.phase-locked .phase-dot { animation: none; opacity: 0.5; }
.phase-locked .phase-badge { background: rgba(139, 147, 167, 0.15); color: var(--text-dim); }

.btn-locked {
  background: var(--card) !important;
  border: 1px solid var(--card-border) !important;
  color: var(--text-dim) !important;
  box-shadow: none !important;
}

.section { margin-bottom: 26px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title h2 {
  font-size: 16px;
  font-weight: 700;
  position: relative;
  padding-left: 12px;
}

.section-title h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-1), var(--accent-2));
}

.section-hint { font-size: 12px; color: var(--text-dim); }
.section-hint b { color: var(--accent-1); }

.mic-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.mic-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.2s, transform 0.15s;
}

.mic-card.empty {
  border-style: dashed;
  border-color: #2c3448;
  background: transparent;
}

.mic-card.me {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.slot-num {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  position: relative;
  flex-shrink: 0;
}

.avatar .mic-state {
  position: absolute;
  bottom: -2px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar .mic-state svg { width: 12px; height: 12px; }
.avatar .mic-state.speaking { color: var(--green); }
.avatar .mic-state.muted { color: var(--red); }

.mic-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mic-role {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}

.host-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.kick-btn {
  margin-top: 2px;
  padding: 2px 10px;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.kick-btn:hover { background: rgba(248, 113, 113, 0.25); }

.empty-label { color: var(--text-dim); font-size: 12px; }

.queue-list {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.queue-empty {
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
}

.queue-item:last-child { border-bottom: none; }

.queue-pos {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.queue-item .avatar { width: 36px; height: 36px; font-size: 15px; }
.queue-item .queue-name { font-size: 14px; font-weight: 600; }
.queue-item .queue-me { color: var(--accent-1); font-size: 11px; margin-left: 6px; }
.queue-item .queue-wait { margin-left: auto; color: var(--text-dim); font-size: 12px; }

.stats-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
}

.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stats-main {
  font-size: 14px;
  font-weight: 700;
}

.stats-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}

.stats-divider {
  height: 1px;
  background: var(--card-border);
  margin: 16px 0;
}

.stats-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.stats-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 13px;
}

.stats-history-item:last-child { border-bottom: none; }

.btn-sm { padding: 9px 16px; font-size: 13px; }
.btn-xs { padding: 6px 12px; font-size: 12px; }

.btn-ghost {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost:hover { border-color: var(--accent-1); color: var(--accent-1); }

.stats-row .btn { text-decoration: none; flex-shrink: 0; }

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: rgba(14, 16, 22, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: center;
  gap: 12px;
  z-index: 10;
}

.btn-join {
  width: min(100%, 320px);
  padding: 16px;
  font-size: 17px;
  background: linear-gradient(135deg, var(--green), #10b981);
  color: #06281c;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.3);
}

.btn-join svg { width: 20px; height: 20px; }

.on-mic-actions { display: flex; gap: 12px; }
.on-mic-actions .btn { padding: 16px 26px; }

.btn-secondary {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary svg { width: 18px; height: 18px; }
.btn-secondary.muted { color: var(--red); border-color: rgba(248, 113, 113, 0.4); }

.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--red);
}

.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.25s ease;
}

.toast.error { color: var(--red); border-color: rgba(248, 113, 113, 0.5); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 720px) {
  .mic-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .section-title h2 { font-size: 15px; }
}

@media (max-width: 480px) {
  .mic-grid { grid-template-columns: repeat(2, 1fr); }
  .app { padding: 14px 14px 130px; }
  .brand-name { display: none; }
}
