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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-raised: #242838;
  --text: #e8e6e3;
  --text-muted: #8b8d95;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --correct: #00b894;
  --correct-glow: rgba(0, 184, 148, 0.25);
  --wrong: #e17055;
  --wrong-glow: rgba(225, 112, 85, 0.25);
  --radius: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app { height: 100%; }

.screen {
  display: none;
  height: 100%;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

/* Login */
.login-card {
  margin: auto;
  text-align: center;
  padding: 3rem 2rem;
  max-width: 360px;
  width: 100%;
}

.logo {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe, #fd79a8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.tagline {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 2.5rem;
}

#player-name {
  width: 100%;
  padding: 0.9rem 1.2rem;
  background: var(--surface);
  border: 2px solid var(--surface-raised);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}
#player-name:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 0.6rem 1.5rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--surface-raised);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s;
}
.btn-secondary:hover { color: var(--text); }

.btn-icon {
  padding: 0.4rem 0.8rem;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--surface-raised);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s;
}
.btn-icon:hover { color: var(--text); }

/* Game Header */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-raised);
  gap: 0.8rem;
  flex-wrap: wrap;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.streak-badge {
  background: var(--accent);
  color: white;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 26px;
  text-align: center;
}
.streak-badge.hot {
  background: linear-gradient(135deg, #e17055, #fdcb6e);
  animation: pulse-glow 1s infinite alternate;
}

@keyframes pulse-glow {
  from { box-shadow: 0 0 4px rgba(225, 112, 85, 0.4); }
  to { box-shadow: 0 0 12px rgba(225, 112, 85, 0.7); }
}

.difficulty-selector {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
}

.diff-btn {
  padding: 0.35rem 0.7rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.diff-btn.active {
  background: var(--accent);
  color: white;
}

.header-actions {
  display: flex;
  gap: 0.4rem;
}

/* Game Area */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  gap: 1.2rem;
}

.score-bar {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.feedback-zone {
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: var(--radius);
  padding: 0.8rem 1.5rem;
  transition: all 0.3s;
  text-align: center;
}
.feedback-zone.correct {
  color: var(--correct);
  background: var(--correct-glow);
}
.feedback-zone.wrong {
  color: var(--wrong);
  background: var(--wrong-glow);
}

.btn-speak {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-speak:hover {
  background: var(--accent);
  color: white;
  box-shadow: 0 0 30px var(--accent-glow);
}
.btn-speak:active {
  transform: scale(0.95);
}
.btn-speak.speaking {
  background: var(--accent);
  color: white;
  animation: speaking-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes speaking-pulse {
  from { box-shadow: 0 0 10px var(--accent-glow); transform: scale(1); }
  to { box-shadow: 0 0 30px var(--accent-glow); transform: scale(1.05); }
}

.hint-text {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 400px;
}

#word-input {
  flex: 1;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 2px solid var(--surface-raised);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
#word-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
#word-input.correct {
  border-color: var(--correct);
  box-shadow: 0 0 0 4px var(--correct-glow);
}
#word-input.wrong {
  border-color: var(--wrong);
  box-shadow: 0 0 0 4px var(--wrong-glow);
}

.input-row .btn-primary {
  width: auto;
  padding: 0.85rem 1.5rem;
}

/* Stats */
.stats-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-raised);
}

.stats-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.stat-card h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.8rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.8rem;
}

.stat-item {
  text-align: center;
}
.stat-item .value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}
.stat-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.word-list {
  list-style: none;
}
.word-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--surface-raised);
  font-size: 0.9rem;
}
.word-list li:last-child { border-bottom: none; }
.word-list .word { font-weight: 600; }
.word-list .ratio { color: var(--text-muted); }

.leaderboard {
  padding: 0 1.5rem 1.5rem;
}
.leaderboard h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.8rem;
}
.leader-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 0.4rem;
}
.leader-row .rank { color: var(--text-muted); margin-right: 0.8rem; font-weight: 700; }
.leader-row .name { flex: 1; font-weight: 600; }
.leader-row .acc { color: var(--accent); font-weight: 700; }

/* Mobile */
@media (max-width: 500px) {
  .game-header { padding: 0.6rem 0.8rem; }
  .difficulty-selector { order: 3; width: 100%; justify-content: center; }
  .game-area { padding: 1rem; gap: 0.8rem; }
  .logo { font-size: 2.2rem; }
  .btn-speak { width: 80px; height: 80px; }
  .btn-speak svg { width: 36px; height: 36px; }
}
