*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a472a 0%, #2d5a1e 50%, #1a472a 100%);
  color: #fff;
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; min-height: 100dvh;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  width: 100%; max-width: 480px; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.screen {
  display: none; flex-direction: column;
  width: 100%; height: 100%;
  padding: 20px;
  position: absolute; top: 0; left: 0;
  overflow-y: auto;
}
.screen.active { display: flex; }

.logo {
  text-align: center; padding: 30px 0 20px;
  animation: fadeInDown 0.6s ease;
}
.logo-icon { font-size: 72px; line-height: 1; margin-bottom: 10px; }
.logo h1 {
  font-size: 42px; font-weight: 900; letter-spacing: 4px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
  background: linear-gradient(180deg, #ffd700, #ff8c00);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle { font-size: 14px; color: rgba(255,255,255,0.7); margin-top: 4px; }

.menu-form { display: flex; flex-direction: column; gap: 12px; padding: 0 20px; }
#player-name {
  padding: 14px 18px; font-size: 18px; border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px; background: rgba(255,255,255,0.1);
  color: #fff; outline: none; text-align: center; transition: border-color 0.3s;
}
#player-name::placeholder { color: rgba(255,255,255,0.4); }
#player-name:focus { border-color: #ffd700; }

.btn {
  padding: 16px; font-size: 20px; font-weight: 700; border: none; border-radius: 12px;
  cursor: pointer; transition: all 0.3s; text-transform: uppercase; letter-spacing: 1px;
}
.btn:active { transform: scale(0.96); }
.btn-start {
  background: linear-gradient(135deg, #ffd700, #ff8c00); color: #1a472a;
  box-shadow: 0 4px 20px rgba(255,215,0,0.4);
}
.btn-start:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-again {
  background: linear-gradient(135deg, #4CAF50, #2E7D32); color: #fff;
  box-shadow: 0 4px 20px rgba(76,175,80,0.4); margin-top: 16px;
}

.rankings { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.ranking-section {
  background: rgba(0,0,0,0.2); border-radius: 12px; padding: 14px;
  animation: fadeInUp 0.6s ease;
}
.ranking-section h3 { font-size: 14px; margin-bottom: 8px; color: #ffd700; }
.ranking-list { font-size: 13px; }
.ranking-list .loading, .ranking-list .empty { color: rgba(255,255,255,0.5); text-align: center; padding: 8px; }
.ranking-row {
  display: flex; justify-content: space-between; padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ranking-row:last-child { border-bottom: none; }
.ranking-row .pos { color: rgba(255,255,255,0.5); width: 24px; }
.ranking-row .name { flex: 1; }
.ranking-row .pts { font-weight: 700; color: #ffd700; }
.ranking-row.top-1 .pts { color: #ffd700; }
.ranking-row.top-2 .pts { color: #C0C0C0; }
.ranking-row.top-3 .pts { color: #CD7F32; }

.game-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; font-size: 18px; font-weight: 700;
}
.timer { color: #ffd700; font-size: 24px; }
.timer.warning { color: #ff4444; animation: pulse 0.5s ease infinite; }
.score-display { font-size: 18px; }

#question-area {
  flex: 1; display: flex; flex-direction: column; padding-top: 8px;
  animation: fadeIn 0.3s ease;
}
.animal-display {
  text-align: center; margin-bottom: 12px;
  animation: fadeInUp 0.4s ease;
}
.animal-display img {
  width: 100%; max-height: 220px; object-fit: contain;
  border-radius: 16px; background: rgba(255,255,255,0.05);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  aspect-ratio: 2/1;
}
.animal-display h2 {
  margin-top: 6px; font-size: 18px; color: #ffd700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.question-prompt {
  text-align: center; font-size: 14px; color: rgba(255,255,255,0.7);
  margin-bottom: 12px;
}

.options-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  flex: 1; align-content: center;
}
.option-card {
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.15);
  border-radius: 14px; padding: 10px; text-align: center;
  cursor: pointer; transition: all 0.25s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.option-card:active { transform: scale(0.95); }
.option-card img {
  width: 100%; aspect-ratio: 1/1; object-fit: contain;
  border-radius: 8px; background: rgba(0,0,0,0.2);
}
.option-card.correct {
  background: rgba(76,175,80,0.3); border-color: #4CAF50;
  animation: correctFlash 0.4s ease;
}
.option-card.incorrect {
  background: rgba(244,67,54,0.3); border-color: #f44336;
  animation: shake 0.4s ease;
}
.option-card.disabled { pointer-events: none; }

.result-box {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center;
  animation: fadeInUp 0.6s ease;
}
.result-box h2 { font-size: 28px; margin-bottom: 16px; }
.final-score { margin: 16px 0; }
.big-score { font-size: 72px; font-weight: 900; color: #ffd700; display: block; }
.score-label { font-size: 16px; color: rgba(255,255,255,0.6); }
.stats { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.stat { font-size: 16px; }
.correct-stat { color: #4CAF50; }
.incorrect-stat { color: #f44336; }
.position-stat { color: #ffd700; font-weight: 700; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes correctFlash { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@media (max-height: 640px) {
  .logo { padding: 10px 0; }
  .logo-icon { font-size: 48px; }
  .logo h1 { font-size: 32px; }
  .animal-display img { max-height: 150px; }
  .options-grid { gap: 6px; }
  .option-card { padding: 6px; }
}
