* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.app {
  width: 100%;
  max-width: 500px;
  min-height: 600px;
}

/* Screens */
.screen {
  display: none;
  background: #fff;
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Welcome */
.welcome-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-top: 1rem;
}

.welcome-logo {
  max-width: 280px;
  width: 100%;
  height: auto;
  margin-bottom: 0.5rem;
}

.welcome-header h1 {
  font-size: 2.5rem;
  color: #333;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: #666;
  font-size: 1.1rem;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Buttons */
.btn {
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-ghost {
  background: transparent;
  color: #666;
}

.btn-ghost:hover {
  background: #f5f5f5;
  box-shadow: none;
  transform: none;
}

/* Forms */
.form-field {
  margin-bottom: 1.5rem;
}

.form-field label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #333;
  font-size: 1rem;
}

.form-field input {
  width: 100%;
  padding: 0.9rem 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-field input:focus {
  border-color: #667eea;
}

h2 {
  font-size: 1.5rem;
  color: #333;
  margin-bottom: 1.5rem;
  text-align: center;
}

/* Players List */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.player-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  background: #f8f9fa;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.player-card:hover {
  border-color: #667eea;
  background: #f0f0ff;
}

.player-card-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 1.1rem;
}

.player-card-name {
  font-weight: 600;
  color: #333;
}

.player-card-age {
  color: #888;
  font-size: 0.85rem;
}

/* Levels */
.levels-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.levels-header h2 {
  margin-bottom: 0;
  text-align: left;
}

.player-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.85rem;
}

#player-display-name {
  font-weight: 600;
  color: #333;
}

#player-display-stars {
  color: #f59e0b;
}

.levels-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.level-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid #e0e0e0;
}

.level-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.level-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.level-card.locked:hover {
  transform: none;
  box-shadow: none;
}

.level-card-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.level-number {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  color: white;
}

.level-1 .level-number { background: #10b981; }
.level-2 .level-number { background: #3b82f6; }
.level-3 .level-number { background: #f59e0b; }
.level-4 .level-number { background: #ef4444; }
.level-5 .level-number { background: #8b5cf6; }

.level-info h3 {
  font-size: 1rem;
  color: #333;
  margin-bottom: 0.2rem;
}

.level-info p {
  font-size: 0.8rem;
  color: #888;
}

.level-stars {
  color: #f59e0b;
  font-size: 1.2rem;
}

.levels-footer {
  display: flex;
  gap: 0.75rem;
}

.levels-footer .btn {
  flex: 1;
}

/* Game */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.game-progress {
  flex: 1;
  margin-right: 1rem;
}

#game-question-num {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.3rem;
  display: block;
}

.progress-bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.game-score {
  font-weight: 600;
  color: #10b981;
  font-size: 1.1rem;
}

.game-content {
  text-align: center;
}

.question-emoji {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.question-text {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 2rem;
  line-height: 1.5;
  min-height: 3rem;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.option-btn {
  padding: 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  background: white;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #333;
}

.option-btn:hover {
  border-color: #667eea;
  background: #f0f0ff;
}

.option-btn.correct {
  border-color: #10b981;
  background: #d1fae5;
  color: #065f46;
  animation: pulse 0.3s ease;
}

.option-btn.wrong {
  border-color: #ef4444;
  background: #fee2e2;
  color: #991b1b;
  animation: shake 0.3s ease;
}

.option-btn.disabled {
  pointer-events: none;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.game-feedback {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 1.5rem;
  min-height: 2rem;
}

.feedback-wrong {
  font-size: 1rem;
  text-align: center;
}

.feedback-answer {
  color: #ef4444;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.feedback-explanation {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  color: #92400e;
  line-height: 1.4;
  text-align: left;
}

.btn-continue {
  margin-top: 1rem;
  padding: 0.7rem 1.5rem;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 1rem;
  width: auto;
}

/* Results */
.results-content {
  text-align: center;
}

#results-title {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.results-stars {
  font-size: 3rem;
  margin-bottom: 1.5rem;
}

.results-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: bold;
  color: #333;
}

.stat-label {
  font-size: 0.85rem;
  color: #888;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Leaderboard */
.leaderboard-table {
  margin-bottom: 1.5rem;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
}

.leaderboard-row:nth-child(1) { background: #fef3c7; }
.leaderboard-row:nth-child(2) { background: #f3f4f6; }
.leaderboard-row:nth-child(3) { background: #fed7aa; }
.leaderboard-row:nth-child(odd):not(:nth-child(1)):not(:nth-child(3)) { background: #f9fafb; }

.leaderboard-rank {
  width: 30px;
  font-weight: bold;
  color: #666;
}

.leaderboard-name {
  flex: 1;
  font-weight: 600;
  color: #333;
}

.leaderboard-age {
  color: #888;
  font-size: 0.85rem;
  margin-right: 1rem;
}

.leaderboard-score {
  color: #f59e0b;
  font-weight: 600;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: #888;
}

.empty-state-emoji {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Subjects */
.subjects-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.subject-card {
  display: flex;
  align-items: center;
  padding: 1.1rem;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid #e0e0e0;
  gap: 1rem;
}

.subject-card.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #667eea;
}

.subject-card.coming-soon {
  opacity: 0.55;
  cursor: default;
}

.subject-card.coming-soon:hover {
  cursor: not-allowed;
}

.subject-icon {
  font-size: 2rem;
  width: 48px;
  text-align: center;
}

.subject-info {
  flex: 1;
}

.subject-info h3 {
  font-size: 1rem;
  color: #333;
  margin-bottom: 0.15rem;
}

.subject-info p {
  font-size: 0.8rem;
  color: #888;
}

.subject-status {
  font-size: 1.2rem;
}

/* Feedback */
.feedback-subtitle {
  text-align: center;
  color: #666;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.form-select {
  width: 100%;
  padding: 0.9rem 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
  background: white;
  transition: border-color 0.2s;
  cursor: pointer;
}

.form-select:focus {
  border-color: #667eea;
}

textarea {
  width: 100%;
  padding: 0.9rem 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s;
}

textarea:focus {
  border-color: #667eea;
}

.feedback-success-msg {
  text-align: center;
  padding: 2rem 0;
}

.feedback-success-msg .success-emoji {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.feedback-success-msg p {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 400px) {
  .app {
    min-height: auto;
  }

  .screen {
    padding: 1.5rem;
  }

  .welcome-header h1 {
    font-size: 2rem;
  }

  .question-text {
    font-size: 1.1rem;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }
}
