:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --accent: #2563eb;
  --good: #16a34a;
  --improve: #ca8a04;
  --bad: #dc2626;
  --border: #e5e7eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --card: #1b1e26;
    --text: #e8eaf0;
    --muted: #9aa1ad;
    --accent: #4f8bff;
    --border: #2c303a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
}

.label {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.word {
  margin: 0 0 28px;
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 700;
  word-break: break-word;
}

.mic {
  width: 88px;
  height: 88px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: transform 0.15s, background 0.15s;
}
.mic svg { width: 40px; height: 40px; fill: currentColor; }
.mic:hover:not(:disabled) { transform: scale(1.05); }
.mic:disabled { opacity: 0.5; cursor: not-allowed; }
.mic.recording { background: var(--bad); animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  100% { box-shadow: 0 0 0 22px rgba(220, 38, 38, 0); }
}

.status {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.status.error { color: var(--bad); }

.result {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.score { margin: 0; font-size: 3rem; font-weight: 700; line-height: 1.1; }
.out-of { font-size: 1.25rem; color: var(--muted); font-weight: 500; }

.verdict { margin: 8px 0 20px; font-size: 1.1rem; font-weight: 600; }
.verdict.good { color: var(--good); }
.verdict.improve { color: var(--improve); }
.verdict.incorrect { color: var(--bad); }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 16px;
}
.metrics div { background: var(--bg); border-radius: 12px; padding: 10px 4px; }
.metrics dt { font-size: 0.75rem; color: var(--muted); }
.metrics dd { margin: 4px 0 0; font-size: 1.25rem; font-weight: 600; }

.heard { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }

.phonemes {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.phonemes li {
  padding: 6px 10px;
  border-radius: 8px;
  font-family: "Segoe UI", "Lucida Sans Unicode", "Arial Unicode MS", sans-serif;
  font-size: 1rem;
  border: 1px solid var(--border);
}
.phonemes li small { display: block; font-size: 0.7rem; color: var(--muted); }
.phonemes li.good { border-color: var(--good); }
.phonemes li.improve { border-color: var(--improve); }
.phonemes li.incorrect { border-color: var(--bad); }

.next {
  margin-top: 28px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.next:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.next:disabled { opacity: 0.5; cursor: not-allowed; }

.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 28px;
  background: var(--bg);
  border-radius: 12px;
}
.level {
  padding: 10px 4px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.level[aria-checked="true"] { background: var(--card); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.level:disabled { cursor: not-allowed; }

.donation {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: left;
  font-size: 0.9rem;
}
.donation-title { margin: 0; text-align: center; font-size: 1rem; color: var(--muted); }
.donation-message { margin: 14px 0 10px; color: var(--muted); }
.donation-details { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.donation-details dt { color: var(--muted); }
.donation-details dd { margin: 0; font-weight: 600; word-break: break-all; }
.copy {
  margin-left: 6px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}
