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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 2.5rem;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.5s ease-out;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2, #f093fb, #f5576c);
  background-size: 300%;
  animation: gradientMove 3s ease infinite;
}

@keyframes gradientMove {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

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

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

@keyframes confettiFall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(600px) rotate(720deg);
    opacity: 0;
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.screen {
  display: none;
}
.screen.active {
  display: block;
}

/* Welcome Screen */
.screen-welcome {
  text-align: center;
}
.screen-welcome .logo {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}
.screen-welcome h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}
.screen-welcome p {
  color: #666;
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.topic-selector {
  text-align: left;
}
.topic-label {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.5rem;
  font-weight: 500;
}
.topic-btns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
.topic-btn {
  padding: 0.6rem 0.8rem;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  background: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.topic-btn:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}
.topic-btn.selected {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.12);
  color: #667eea;
  font-weight: 600;
}

input {
  padding: 0.9rem 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
  outline: none;
}
input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.btn {
  padding: 0.9rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn:hover {
  transform: translateY(-2px);
}
.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.error-msg {
  color: #f5576c;
  font-size: 0.9rem;
  min-height: 1.3rem;
  margin-top: -0.5rem;
}

/* Quiz Screen */
.screen-quiz .quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.screen-quiz .quiz-header .user-greeting {
  font-weight: 600;
  color: #667eea;
}
.screen-quiz .quiz-header .class-greeting {
  font-size: 0.85rem;
  color: #999;
  margin-top: 2px;
}
.screen-quiz .quiz-header .question-count {
  color: #999;
  font-size: 0.9rem;
}

.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 4px;
  transition: width 0.4s ease;
  width: 0%;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 1.5rem;
  animation: fadeIn 0.3s ease-out;
}

.timer-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.timer-bar {
  flex: 1;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.timer-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.1s linear, background 0.3s;
  width: 100%;
}
.timer-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #666;
  min-width: 2.5rem;
  text-align: right;
}
.timer-text.urgent {
  color: #f5576c;
  animation: pulse 0.5s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.4; }
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.choice-btn {
  padding: 1rem 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  background: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.choice-btn:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
  transform: translateX(4px);
}
.choice-btn.correct {
  border-color: #43e97b;
  background: rgba(67, 233, 123, 0.1);
  animation: pop 0.3s;
}
.choice-btn.wrong {
  border-color: #f5576c;
  background: rgba(245, 87, 108, 0.1);
  animation: pop 0.3s;
}
.choice-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Results Screen */
.screen-results {
  text-align: center;
}
.screen-results .result-icon {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}
.screen-results h2 {
  font-size: 1.8rem;
  color: #333;
  margin-bottom: 0.5rem;
}
.screen-results .result-score {
  font-size: 3.5rem;
  font-weight: 800;
  margin: 0.5rem 0;
}
.screen-results .result-message {
  color: #666;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}
.screen-results .btn {
  min-width: 200px;
}

.review-wrap {
  display: none;
  margin: 1.5rem 0;
  text-align: left;
  max-height: 300px;
  overflow-y: auto;
  border-top: 1px solid #e0e0e0;
  padding-top: 1rem;
}
.review-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.review-item {
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid #e0e0e0;
  font-size: 0.85rem;
}
.review-item.review-correct {
  border-color: #43e97b;
  background: rgba(67, 233, 123, 0.06);
}
.review-item.review-wrong {
  border-color: #f5576c;
  background: rgba(245, 87, 108, 0.06);
}
.review-q {
  font-weight: 600;
  color: #333;
  margin-bottom: 0.3rem;
}
.review-detail {
  color: #666;
  margin-top: 2px;
  font-size: 0.8rem;
}
.review-answer {
  font-weight: 600;
}
.review-answer-correct {
  color: #43e97b;
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@media (max-width: 480px) {
  .card {
    padding: 1.5rem;
  }
  .screen-results .result-score {
    font-size: 2.5rem;
  }
}
