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

:root {
  --bg: #0a0a0a;
  --surface: #161616;
  --surface-hover: #1e1e1e;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #4ade80;
  --accent-glow: rgba(74, 222, 128, 0.3);
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  max-width: 420px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Logo / Home */
.logo {
  text-align: center;
  margin-bottom: 16px;
}

.logo-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.hint {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
  margin-top: 8px;
}

/* Buttons */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
}

.btn-primary:hover {
  box-shadow: 0 0 24px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 12px 20px;
  font-size: 14px;
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-small {
  padding: 10px 20px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  width: auto;
}

.btn-icon {
  font-size: 18px;
}

/* QR Code screen */
#screen-qr h2 {
  font-size: 20px;
  font-weight: 600;
}

.code-label {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

#qr-container {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
}

#qr-canvas {
  display: block;
  width: 200px;
  height: 200px;
}

.room-code {
  font-size: 24px;
  font-weight: 700;
  font-family: "SF Mono", "Fira Code", monospace;
  letter-spacing: 2px;
  color: var(--accent);
}

/* Pulse animation for waiting */
#waiting-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}

#status-text {
  color: var(--text-muted);
  font-size: 14px;
}

.pulse-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.8); opacity: 0.4; }
  50%      { transform: scale(1.1); opacity: 1; }
}

/* Join screen */
#screen-join h2 {
  font-size: 20px;
  font-weight: 600;
}

.code-input-group {
  display: flex;
  gap: 10px;
  width: 100%;
}

#join-code {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  font-family: "SF Mono", "Fira Code", monospace;
  letter-spacing: 1px;
  outline: none;
  transition: border-color 0.15s;
}

#join-code:focus {
  border-color: var(--accent);
}

#join-code::placeholder {
  color: var(--text-muted);
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

#btn-connect {
  padding: 14px 20px;
  width: auto;
  border-radius: var(--radius-sm);
}

/* Talk screen */
.talk-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.status-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.3);
}

#status-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* Audio visualizer */
.audio-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

#audio-meter {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

#remote-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.wave-icon {
  font-size: 16px;
}

/* PTT Button */
.ptt-button {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.1s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ptt-button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 32px var(--accent-glow);
}

.ptt-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #0a0a0a;
  transform: scale(0.95);
  box-shadow: 0 0 48px var(--accent-glow);
}

.ptt-icon {
  font-size: 32px;
}

.ptt-text {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

#btn-disconnect {
  margin-top: 8px;
}

/* Responsive */
@media (min-width: 480px) {
  #app {
    padding: 40px;
  }
}
