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

:root {
  --bg: #f5f5fa;
  --surface: #ffffff;
  --surface-2: #e8e8f0;
  --primary: #6c4ce0;
  --primary-hover: #7c5cfc;
  --accent: #e85d8a;
  --accent-hover: #ff6b9d;
  --text: #1a1a2e;
  --text-dim: #6b6b80;
  --danger: #dc2626;
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-2: #232340;
  --primary: #7c5cfc;
  --primary-hover: #9578ff;
  --accent: #ff6b9d;
  --accent-hover: #ff8db5;
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --danger: #ef4444;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  padding: 32px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

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

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

.logo { text-align: center; margin-bottom: 24px; }
.logo h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 6px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline { color: var(--text-dim); font-size: 1rem; margin-top: 8px; }

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  max-width: 320px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--surface); filter: brightness(0.92); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-small { padding: 10px 20px; font-size: 0.9rem; }
.hidden { display: none !important; }

.player-badge {
  background: var(--primary);
  color: white;
  padding: 6px 20px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.player-badge.p2 { background: var(--accent); }

.instruction {
  color: var(--text-dim);
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 360px;
}

.prompt-card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  width: 100%;
  max-width: 380px;
}
.prompt-label {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.prompt-text {
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 16px;
}

.recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.btn-record {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--danger);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.btn-record:hover { background: rgba(239, 68, 68, 0.1); }

.record-icon {
  width: 32px;
  height: 32px;
  background: var(--danger);
  border-radius: 50%;
  transition: all 0.2s ease;
}

.btn-record.recording .record-icon {
  border-radius: 6px;
  width: 28px;
  height: 28px;
}
.btn-record.recording {
  animation: pulse-ring 1.5s ease infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.record-status { color: var(--text-dim); font-size: 0.85rem; }

.waveform {
  width: 100%;
  max-width: 280px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.waveform .bar {
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
  transition: height 0.1s ease;
  min-height: 4px;
}

.playback {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.audio-section {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.audio-section h3 { font-size: 1rem; font-weight: 600; }
.hint { color: var(--text-dim); font-size: 0.8rem; line-height: 1.4; }

.guess-section {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.guess-section h3 { font-size: 1rem; font-weight: 600; }

#input-guess {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--surface-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s ease;
}
#input-guess:focus { border-color: var(--primary); }
#input-guess::placeholder { color: var(--text-dim); }

.result-card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.result-row { display: flex; flex-direction: column; gap: 6px; }
.result-label {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.result-value { font-size: 1.3rem; font-weight: 600; line-height: 1.4; }

.result-playback {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.result-playback-group {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.result-playback-group .group-label {
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.handoff-icon { font-size: 4rem; animation: spin 2s linear infinite; }
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
#screen-handoff h2 { text-align: center; }

.rules {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 380px;
}
.rule {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.rule-number {
  background: var(--primary);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.rule p { font-size: 0.9rem; line-height: 1.5; color: var(--text-dim); }
.rule strong { color: var(--text); }

.btn.playing { pointer-events: none; opacity: 0.8; }

.theme-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10000;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--surface-2);
  border-radius: 8px;
  padding: 6px;
  line-height: 0;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-dim); }
.theme-toggle .icon { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

#screen-p2-guess {
  max-height: 100dvh;
  overflow-y: auto;
  padding-bottom: 40px;
}

@media (max-height: 700px) {
  #app { padding: 16px 20px; }
  .screen { gap: 16px; }
  .logo h1 { font-size: 2.4rem; }
}
