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

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --correct: #16a34a;
  --incorrect: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

header h1 a {
  color: var(--primary);
  text-decoration: none;
}

nav { display: flex; gap: 0.5rem; }

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-secondary);
}

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

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

.view { display: none; }

.view.active { display: block; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

h2 { font-size: 1.25rem; margin-bottom: 1rem; }

h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; color: var(--text-secondary); }

.subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; }

.hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus { border-color: var(--primary); }

.btn-primary, .btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

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

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

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

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

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tense-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.tense-btn {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.tense-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tense-btn.compound {
  border-style: dashed;
  grid-column: 1 / -1;
}

#progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 0.5rem;
}

#progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-text {
  text-align: right;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

#question-card {
  text-align: center;
  padding: 1.5rem 0;
}

.q-pronoun {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.q-verb {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.q-tense {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.q-translation {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
}

#answer-form { margin-top: 1rem; }

#answer-input {
  font-size: 1.25rem;
  text-align: center;
}

.feedback {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
  font-weight: 500;
  text-align: center;
}

.feedback.correct {
  background: #dcfce7;
  color: var(--correct);
}

.feedback.incorrect {
  background: #fef2f2;
  color: var(--incorrect);
}

.feedback.hidden { display: none; }

.feedback .hint {
  margin-top: 0.5rem;
  font-weight: 400;
}

.score-big {
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
}

.score-detail {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.results-list { margin: 1rem 0; }

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.result-item:last-child { border-bottom: none; }

.result-item .result-left {
  display: flex;
  flex-direction: column;
}

.result-item .result-verb { font-weight: 600; }

.result-item .result-detail { color: var(--text-secondary); font-size: 0.8rem; }

.result-item .result-status {
  font-size: 1.25rem;
  font-weight: 700;
}

.result-item .result-status.correct { color: var(--correct); }
.result-item .result-status.incorrect { color: var(--incorrect); }

.result-item .result-answer { font-size: 0.8rem; color: var(--text-secondary); }

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

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

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.stats-list { margin-top: 0.5rem; }

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.stat-item:last-child { border-bottom: none; }

.stat-item .stat-name { font-weight: 500; }
.stat-item .stat-value { font-weight: 600; color: var(--primary); }
.stat-item .stat-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.accent-popup {
  position: fixed;
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
}

.accent-popup.hidden {
  display: none;
}

.accent-option {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s;
}

.accent-option:hover {
  background: var(--bg);
}

@media (max-width: 480px) {
  .tense-grid { grid-template-columns: 1fr 1fr; }
  header { padding: 0.5rem; }
  .card { padding: 1rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
