:root {
  --brand-purple: #46178f;
  --brand-purple-dark: #310f64;
  --brand-pink: #ff3355;
  --brand-blue: #2684ff;
  --brand-green: #66bf3c;
  --brand-yellow: #ffcd00;
  --brand-cyan: #00c3ff;
  --brand-orange: #ff8c00;

  --mcq-red: #e21b3c;
  --mcq-blue: #1368ce;
  --mcq-yellow: #d89e00;
  --mcq-green: #26890c;

  --bg-1: #46178f;
  --bg-2: #6b2fd1;

  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;

  --shadow: 0 8px 0 rgba(0, 0, 0, 0.18), 0 14px 26px rgba(0, 0, 0, 0.15);
  --shadow-hover: 0 12px 0 rgba(0, 0, 0, 0.2), 0 18px 30px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Nunito', 'Fredoka', sans-serif;
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
  color: #fff;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* === Helpers === */
.hidden { display: none !important; }

.logo {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(2.4rem, 8vw, 5rem);
  font-weight: 800;
  letter-spacing: -1.5px;
  text-align: center;
  text-shadow: 0 5px 0 rgba(0,0,0,0.18);
  margin-bottom: 8px;
}
.logo span {
  color: var(--brand-yellow);
}

.subtitle {
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 700;
  opacity: 0.95;
  text-align: center;
  margin-bottom: 36px;
}

.card {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 720px;
  box-shadow: var(--shadow);
  text-align: center;
}

/* === Buttons === */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  border-radius: var(--radius-md);
  padding: 16px 24px;
  min-width: 160px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 6px 0 rgba(0,0,0,0.18);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.18);
}

.btn-primary { background: var(--brand-pink); }
.btn-primary:hover { background: #ff1a40; }

.btn-secondary { background: var(--brand-blue); }
.btn-secondary:hover { background: #1a5fd6; }

.btn-yellow { background: var(--brand-yellow); color: #2a1a5e; }
.btn-yellow:hover { background: #ffdb33; }

.btn-green { background: var(--brand-green); }
.btn-green:hover { background: #5aa835; }

.btn-answer {
  width: 100%;
  text-align: left;
  padding: 20px 24px;
  font-size: 1.15rem;
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-answer .shape {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.1rem;
}

.answer-red    { background: var(--mcq-red); }
.answer-blue   { background: var(--mcq-blue); }
.answer-yellow { background: var(--mcq-yellow); color: #2a1a5e; }
.answer-green  { background: var(--mcq-green); }

.answer-red:hover    { background: #c4122f; }
.answer-blue:hover   { background: #1057ad; }
.answer-yellow:hover { background: #c08b00; color: #2a1a5e; }
.answer-green:hover  { background: #1f7007; }

/* === Forms === */
.form-group {
  margin-bottom: 22px;
  text-align: left;
}

.form-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  opacity: 0.95;
}

.form-control {
  width: 100%;
  padding: 16px 18px;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
  border: 3px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.92);
  color: #2a1a5e;
  font-family: inherit;
  font-weight: 700;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-yellow);
  background: #fff;
}

/* === Screens === */
.screen {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.35s ease;
}

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

/* === Home Screen === */
.home-screen .card {
  max-width: 520px;
}

/* === Subject Screen === */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
  width: 100%;
  margin-top: 28px;
}

.subject-card {
  background: #fff;
  color: #2a1a5e;
  border-radius: var(--radius-md);
  padding: 24px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12);
  text-align: center;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.subject-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 14px 0 rgba(0,0,0,0.12), 0 18px 30px rgba(0,0,0,0.15);
}

.subject-icon {
  font-size: 3rem;
}

.subject-name {
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1.2;
}

.subject-desc {
  font-size: 0.85rem;
  opacity: 0.75;
}

/* === Quiz Screen === */
.quiz-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}

.timer {
  background: #fff;
  color: var(--brand-purple);
  font-weight: 900;
  font-size: 1.6rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.timer.danger {
  color: var(--mcq-red);
  animation: pulse 0.8s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.progress-bar {
  flex: 1;
  height: 18px;
  background: rgba(0,0,0,0.22);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--brand-green);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.question-card {
  width: 100%;
  background: #fff;
  color: #2a1a5e;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  text-align: left;
}

.question-number {
  font-weight: 700;
  opacity: 0.6;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.question-text {
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 800;
  line-height: 1.35;
  margin: 0;
}

.answers-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: 100%;
}

@media (min-width: 640px) {
  .answers-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.answer-locked {
  pointer-events: none;
  opacity: 0.85;
}

.answer-correct {
  outline: 5px solid var(--brand-green) !important;
  transform: scale(1.02);
}

.answer-wrong {
  outline: 5px solid var(--brand-pink) !important;
  opacity: 0.6;
}

/* === Feedback === */
.feedback {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  font-weight: 900;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.feedback.show {
  opacity: 1;
  transform: scale(1);
}

.feedback.correct { background: rgba(102, 191, 60, 0.92); color: #fff; }
.feedback.wrong   { background: rgba(226, 27, 60, 0.92); color: #fff; }

/* === Result Screen === */
.result-screen .card {
  max-width: 520px;
  padding: 40px 32px;
}

.result-score {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  margin: 18px 0;
  color: var(--brand-yellow);
  text-shadow: 0 5px 0 rgba(0,0,0,0.15);
}

.result-label {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.rewards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0;
}

.reward-box {
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  padding: 16px 8px;
}

.reward-value {
  font-size: 1.8rem;
  font-weight: 900;
  display: block;
}

.reward-label {
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.85;
}

.perfect-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--brand-yellow);
  margin-bottom: 12px;
}

/* === Confetti === */
.confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 20px;
  top: -20px;
  animation: fall 2.5s ease-out forwards;
}

@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* === Loading === */
.spinner {
  width: 56px;
  height: 56px;
  border: 6px solid rgba(255,255,255,0.25);
  border-top-color: var(--brand-yellow);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 24px auto;
}

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

/* === Error / Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 14px 22px;
  border-radius: 99px;
  font-weight: 700;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.toast.show { opacity: 1; }

/* === Responsive tweaks === */
@media (max-width: 480px) {
  .card { padding: 24px 18px; }
  .subject-grid { grid-template-columns: repeat(2, 1fr); }
  .rewards-grid { grid-template-columns: 1fr; }
  .btn { width: 100%; margin-bottom: 10px; }
}

.avatar-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.avatar-option {
  width: 56px;
  height: 56px;
  font-size: 1.8rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, border-color 0.15s;
}
.avatar-option:hover { transform: scale(1.1); }
.avatar-option.selected { border-color: var(--brand-yellow); transform: scale(1.15); }

.avatar-option[draggable="true"] {
  cursor: grab;
  user-select: none;
}

.avatar-option[draggable="true"]:active {
  cursor: grabbing;
}

.avatar-option.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  border: 2px dashed var(--brand-yellow);
}

.avatar-option.drag-over {
  transform: scale(1.05);
  border: 2px solid var(--brand-yellow);
}

#arrangeBlocks {
  min-height: 70px;
  padding: 12px;
  background: rgba(0,0,0,0.05);
  border-radius: 16px;
}

.fill-blank {
  text-align: center;
}

.fill-blank:focus {
  border-color: var(--brand-blue);
  outline: none;
}

.back-link {
  display: inline-block;
  margin-top: 20px;
  color: rgba(255,255,255,0.85);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}
.back-link:hover { color: #fff; }

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.12);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.top-bar .brand {
  font-family: 'Fredoka', sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
}
.top-bar .brand span { color: var(--brand-yellow); }

.top-bar .stats {
  display: flex;
  gap: 16px;
  font-weight: 800;
  font-size: 0.95rem;
}

.top-bar .stats span {
  background: rgba(255,255,255,0.15);
  padding: 6px 12px;
  border-radius: 99px;
}
