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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.container {
  width: 100%;
  max-width: 640px;
}

/* Screen visibility */
.screen {
  display: none;
}
.screen.active {
  display: block;
}

/* Card */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  padding: 2rem;
}

/* Start screen */
.start-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #4f46e5;
}

.start-subtitle {
  font-size: 1rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary {
  background: #4f46e5;
  color: #fff;
}
.btn-primary:hover {
  background: #4338ca;
}

.btn-secondary {
  background: #e5e7eb;
  color: #374151;
}
.btn-secondary:hover {
  background: #d1d5db;
}

/* Progress */
.progress-text {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.progress-bar-track {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #4f46e5;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Topic tag */
.topic-tag {
  display: inline-block;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

/* Question text */
.question-text {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* Input group */
.input-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.input-group input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.15s;
}

.input-group input:focus {
  border-color: #4f46e5;
}

.input-unit {
  font-size: 0.95rem;
  color: #6b7280;
  white-space: nowrap;
}

.input-error {
  color: #dc2626;
  font-size: 0.85rem;
  min-height: 1.25rem;
  margin-bottom: 1rem;
}

/* Button row */
.btn-row {
  display: flex;
  gap: 0.75rem;
}

/* Feedback screen */
.fb-icon {
  font-size: 3rem;
  font-weight: 700;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}
.fb-icon.correct {
  background: #d1fae5;
  color: #059669;
}
.fb-icon.incorrect {
  background: #fee2e2;
  color: #dc2626;
}
.fb-icon.skipped {
  background: #e5e7eb;
  color: #6b7280;
}

.fb-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.fb-hint {
  text-align: center;
  font-size: 0.95rem;
  color: #dc2626;
  margin-bottom: 1rem;
  min-height: 1.25rem;
}

.fb-yours {
  font-size: 0.95rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.fb-reference {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.fb-explanation {
  background: #f9fafb;
  border-left: 3px solid #4f46e5;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  border-radius: 0 6px 6px 0;
}

.fb-tip {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  border-radius: 0 6px 6px 0;
}

.fb-btn-row {
  text-align: center;
}

/* Results screen */
.results-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.results-score {
  font-size: 2rem;
  font-weight: 700;
  color: #4f46e5;
}

.results-accuracy {
  font-size: 1rem;
  color: #6b7280;
}

.breakdown-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.breakdown-topic {
  font-size: 0.875rem;
  font-weight: 500;
}

.breakdown-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  background: #4f46e5;
  border-radius: 4px;
  transition: width 0.3s;
}

.breakdown-score {
  font-size: 0.8rem;
  color: #6b7280;
  white-space: nowrap;
  text-align: right;
}

.results-btn-row {
  text-align: center;
  margin-top: 1.5rem;
}

/* History */
.history-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

#start-history {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.history-list {
  margin-bottom: 0.75rem;
}

.history-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.875rem;
  color: #4b5563;
}

.history-date {
  color: #6b7280;
}

.history-score {
  font-weight: 500;
}

.history-avg {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 0.75rem;
  text-align: center;
}

code {
  background: #eef2ff;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Responsive */
@media (max-width: 480px) {
  .card {
    padding: 1.25rem;
  }
  .start-title {
    font-size: 1.4rem;
  }
  .breakdown-row {
    grid-template-columns: 100px 1fr auto;
    gap: 0.5rem;
  }
}
