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

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-overlay: rgba(0, 0, 0, 0.85);
  --primary: #e94560;
  --primary-hover: #d63851;
  --accent: #0f3460;
  --text: #eaeaea;
  --text-muted: #a0a0b0;
  --success: #4ecca3;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: "Hiragino Kaku Gothic Pro", "Yu Gothic", "Meiryo", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 20px;
}

.screen.active {
  display: flex;
}

/* Home Screen */
header {
  text-align: center;
  padding: 24px 0 16px;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
}

.stats-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.primary-btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  margin-top: auto;
  margin-bottom: 12px;
  transition: background 0.2s;
}

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

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

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

.message {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: 16px;
}

.hidden {
  display: none !important;
}

/* Review Screen */
.review-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.progress-text {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.review-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.kanji-info {
  text-align: center;
}

.source-word {
  font-size: 20px;
  font-weight: 600;
}

.source-reading {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 4px;
}

.source-meaning {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

#writer-target {
  width: 300px;
  height: 300px;
  background: var(--bg-card);
  border-radius: var(--radius);
  position: relative;
  transition: box-shadow 0.4s ease;
}

#writer-target svg {
  border-radius: var(--radius);
}

#writer-target.correct-glow {
  box-shadow: 0 0 20px var(--success), 0 0 40px rgba(78, 204, 163, 0.3);
}

.next-btn {
  padding: 12px 48px;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}

.next-btn:hover {
  background: var(--accent);
}

.review-status {
  font-size: 14px;
  color: var(--text-muted);
  min-height: 20px;
  text-align: center;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.success-content {
  text-align: center;
  padding: 32px;
  max-width: 320px;
  width: 100%;
}

.completion-label {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 4px;
}

.completion-stats {
  margin: 24px 0;
}

.completion-stats .stat-value {
  font-size: 48px;
  color: var(--success);
}
