/* === RESET & BASE === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f1a14;
  --bg-secondary: #162019;
  --bg-card: #1a2b22;
  --bg-card-hover: #223828;
  --bg-elevated: #243a2c;
  --border: #2d4a38;
  --border-light: #3a5c48;
  --text-primary: #e8f0eb;
  --text-secondary: #9ab3a4;
  --text-muted: #6b8b7b;
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --accent-glow: rgba(74, 222, 128, 0.15);
  --correct: #4ade80;
  --correct-bg: rgba(74, 222, 128, 0.12);
  --wrong: #f87171;
  --wrong-bg: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* === SCREENS === */
.screen {
  display: none;
  min-height: 100dvh;
}
.screen.active {
  display: flex;
}

#quiz-screen {
  flex-direction: column;
}

/* === START SCREEN === */
#start-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(74, 222, 128, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(34, 197, 94, 0.04) 0%, transparent 50%),
    var(--bg-primary);
}

.start-content {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.logo-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 80px;
  height: 80px;
  color: var(--accent);
  margin-bottom: 8px;
}

.title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* === SETTINGS CARD === */
.settings-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.toggle-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-btn {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.toggle-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* === BUTTONS === */
.start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 32px;
  background: linear-gradient(135deg, var(--accent-dim), #16a34a);
  border: none;
  border-radius: var(--radius-md);
  color: #052e16;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.25);
}

.start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(34, 197, 94, 0.35);
}

.start-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.secondary-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* === QUIZ HEADER === */
.quiz-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 26, 20, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.quiz-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.back-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.score-display {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}

.question-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-bar-container {
  height: 3px;
  background: var(--bg-secondary);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.4s ease;
}

/* === QUIZ BODY (PHOTO MODE) === */
.quiz-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  width: 100%;
  padding-bottom: 24px;
}

.photo-container {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 16px 16px 8px;
}

.photo-wrapper {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.bird-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.bird-photo.loaded {
  opacity: 1;
}

.photo-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.photo-loading.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.photo-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: var(--radius-lg);
}

.photo-overlay.correct {
  opacity: 1;
  box-shadow: inset 0 0 0 4px var(--correct);
  background: rgba(74, 222, 128, 0.08);
}

.photo-overlay.wrong {
  opacity: 1;
  box-shadow: inset 0 0 0 4px var(--wrong);
  background: rgba(248, 113, 113, 0.08);
}

.question-text {
  text-align: center;
  padding: 16px 16px 12px;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-secondary);
  width: 100%;
}

/* === OPTIONS (TEXT MODE) === */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.option-btn {
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  line-height: 1.3;
}

.option-btn:hover:not(.disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.option-btn:active:not(.disabled) {
  transform: translateY(0);
}

.option-btn.disabled {
  cursor: default;
  pointer-events: none;
}

.option-btn.correct {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
  animation: pulse-correct 0.5s ease;
}

.option-btn.wrong {
  background: var(--wrong-bg);
  border-color: var(--wrong);
  color: var(--wrong);
  animation: shake 0.4s ease;
}

.option-btn.dimmed {
  opacity: 0.35;
}

@keyframes pulse-correct {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* === NAME MODE === */
.name-display {
  text-align: center;
  padding: 32px 16px 8px;
  width: 100%;
}

.bird-name-text {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.bird-sci-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.photo-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.photo-option {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-secondary);
}

.photo-option:hover:not(.disabled) {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.photo-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: opacity 0.4s ease;
  opacity: 0;
}

.photo-option img.loaded {
  opacity: 1;
}

.photo-option .photo-option-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-option .photo-option-loading.hidden {
  display: none;
}

.photo-option.disabled {
  cursor: default;
  pointer-events: none;
}

.photo-option.correct {
  border-color: var(--correct);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.3);
  animation: pulse-correct 0.5s ease;
}

.photo-option.wrong {
  border-color: var(--wrong);
  animation: shake 0.4s ease;
}

.photo-option.dimmed {
  opacity: 0.3;
}

.photo-option-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  font-size: 0.75rem;
  font-weight: 500;
  color: #fff;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.photo-option.answered .photo-option-label {
  opacity: 1;
}

/* === RESULTS SCREEN === */
#results-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(74, 222, 128, 0.06) 0%, transparent 50%),
    var(--bg-primary);
}

.results-content {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.results-header {
  text-align: center;
}

.results-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.results-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.results-subtitle {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 0.95rem;
}

/* Score ring */
.results-score-ring {
  position: relative;
  width: 140px;
  height: 140px;
}

.score-ring-svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.score-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}

.score-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 1.2s ease;
}

.score-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-ring-pct {
  font-size: 2rem;
  font-weight: 700;
}

/* Stats */
.results-stats {
  display: flex;
  gap: 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-number {
  font-size: 1.6rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-item.correct .stat-number { color: var(--correct); }
.stat-item.wrong .stat-number { color: var(--wrong); }
.stat-item.streak .stat-number { color: var(--warning); }

/* Missed birds */
.results-missed {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.results-missed h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.missed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.missed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.missed-item-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-primary);
}

.missed-item-info {
  flex: 1;
}

.missed-item-da {
  font-weight: 600;
  font-size: 0.9rem;
}

.missed-item-en {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* === RESPONSIVE === */
@media (max-width: 500px) {
  .title {
    font-size: 2rem;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .photo-options-grid {
    grid-template-columns: 1fr 1fr;
  }

  .settings-card {
    padding: 18px;
  }

  .toggle-group {
    flex-direction: column;
  }

  .toggle-btn {
    text-align: center;
  }

  .bird-name-text {
    font-size: 1.6rem;
  }
}

@media (min-width: 768px) {
  .photo-wrapper {
    max-width: 640px;
    aspect-ratio: 16 / 10;
  }

  .options-grid {
    max-width: 640px;
  }
}

/* === TRANSITIONS BETWEEN SCREENS === */
.screen {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Question fade transition */
.quiz-body.fade-out {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.quiz-body.fade-in {
  opacity: 1;
  transition: opacity 0.3s ease;
}
