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

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #E3F2FD 0%, #F3E5F5 50%, #E8F5E9 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}
.screen.active { display: block; }

/* ===== HOME SCREEN ===== */
.home-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  gap: 16px;
}

.mascot {
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.15));
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-16px); }
}

.main-title {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 900;
  line-height: 1.1;
  background: linear-gradient(135deg, #FF7043, #E91E63, #9C27B0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: bounce-in 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes bounce-in {
  0%   { transform: scale(0.3); opacity: 0; }
  50%  { transform: scale(1.08); }
  70%  { transform: scale(0.96); }
  100% { transform: scale(1); opacity: 1; }
}

.subtitle {
  font-size: 1.2rem;
  color: #555;
  line-height: 1.5;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: linear-gradient(135deg, #FF7043, #E91E63);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 18px 48px;
  font-size: 1.4rem;
  font-weight: 900;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(233,30,99,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover  { transform: translateY(-3px) scale(1.04); box-shadow: 0 10px 28px rgba(233,30,99,0.5); }
.btn-primary:active { transform: translateY(0) scale(0.97); }

.btn-secondary {
  background: white;
  color: #E91E63;
  border: 3px solid #E91E63;
  border-radius: 50px;
  padding: 15px 36px;
  font-size: 1.2rem;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.btn-secondary:hover { background: #fce4ec; transform: translateY(-2px); }

.btn-back {
  background: rgba(255,255,255,0.7);
  border: 2px solid #ddd;
  border-radius: 50px;
  padding: 8px 20px;
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  color: #555;
  transition: background 0.15s;
}
.btn-back:hover { background: white; }

/* ===== SCREEN HEADER ===== */
.screen-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0 24px;
}
.screen-header h2 {
  font-size: 1.8rem;
  font-weight: 900;
  color: #333;
}

/* ===== CATEGORY CARDS ===== */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding-bottom: 32px;
}

.category-card {
  background: var(--card-color);
  border: 4px solid var(--card-dark);
  border-radius: 24px;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}
.category-card:hover {
  transform: translateY(-6px) rotate(-1deg) scale(1.04);
  box-shadow: 0 14px 30px rgba(0,0,0,0.18);
  animation: wiggle 0.4s ease;
}
@keyframes wiggle {
  0%,100% { transform: translateY(-6px) rotate(-1deg) scale(1.04); }
  25%      { transform: translateY(-6px) rotate(1.5deg) scale(1.04); }
  75%      { transform: translateY(-6px) rotate(-2deg) scale(1.04); }
}

.cat-icon  { font-size: 3.5rem; }
.cat-name  { font-size: 1.5rem; font-weight: 900; color: #222; }
.cat-units { font-size: 0.9rem; font-weight: 700; color: #444; letter-spacing: 1px; }

/* ===== LEARN SCREEN ===== */
.learn-section {
  background: white;
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.section-label {
  font-size: 1.3rem;
  font-weight: 900;
  color: #333;
  margin-bottom: 20px;
}

/* Staircase */
.staircase {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  padding: 16px 0;
  overflow-x: auto;
}

.stair-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  animation: step-appear 0.5s forwards;
}

@keyframes step-appear {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stair-block {
  width: 100px;
  border-radius: 12px 12px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 6px 8px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.15);
  cursor: default;
}
.stair-unit  { font-size: 1.5rem; font-weight: 900; color: white; text-shadow: 0 2px 4px rgba(0,0,0,0.25); }
.stair-label { font-size: 0.7rem; font-weight: 700; color: rgba(255,255,255,0.9); text-align: center; }

.stair-factor {
  font-size: 0.8rem;
  font-weight: 800;
  color: #555;
  background: #f0f0f0;
  border-radius: 12px;
  padding: 3px 8px;
  margin: 6px 0 0;
  white-space: nowrap;
}

.stair-arrow {
  font-size: 1.4rem;
  padding: 0 4px;
  color: #aaa;
  align-self: center;
  margin-bottom: 30px;
}

/* Converter */
.converter {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.converter-input-group,
.converter-result-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.conv-input {
  width: 130px;
  font-size: 2rem;
  font-weight: 900;
  font-family: 'Nunito', sans-serif;
  border: 3px solid #81D4FA;
  border-radius: 14px;
  padding: 10px 12px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.conv-input:focus { border-color: #039BE5; }
.conv-select {
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 6px 12px;
  background: #f9f9f9;
  cursor: pointer;
}
.conv-equals {
  font-size: 2.5rem;
  font-weight: 900;
  color: #aaa;
}
.conv-result {
  font-size: 2.5rem;
  font-weight: 900;
  color: #E91E63;
  min-width: 130px;
  text-align: center;
  animation: pop-result 0.3s ease;
}
@keyframes pop-result {
  0%   { transform: scale(0.8); opacity: 0.5; }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.conv-example {
  margin-top: 16px;
  font-size: 1rem;
  font-weight: 700;
  color: #666;
  text-align: center;
  background: #f5f5f5;
  border-radius: 10px;
  padding: 10px 16px;
}

/* ===== QUIZ SCREEN ===== */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 20px;
  flex-wrap: wrap;
}
.quiz-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.quiz-cat-label {
  font-size: 1.1rem;
  font-weight: 900;
  color: #555;
}
#quiz-progress {
  font-size: 0.9rem;
  font-weight: 700;
  color: #888;
}
.quiz-scores {
  display: flex;
  gap: 10px;
}
.score-badge {
  background: #FFF176;
  border: 2px solid #F9A825;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 1rem;
  font-weight: 900;
  color: #333;
}
.highscore-badge {
  background: #FFE0B2;
  border: 2px solid #FF8F00;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 1rem;
  font-weight: 900;
  color: #333;
}

.quiz-question-area {
  background: white;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.quiz-question {
  font-size: 1.5rem;
  font-weight: 900;
  color: #222;
  line-height: 1.4;
  margin-bottom: 24px;
  text-align: center;
}

.quiz-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.answer-btn {
  background: #F3F4F6;
  border: 3px solid #E5E7EB;
  border-radius: 16px;
  padding: 18px 12px;
  font-size: 1.2rem;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  text-align: center;
}
.answer-btn:hover:not(:disabled) {
  background: #E0F2FE;
  border-color: #81D4FA;
  transform: scale(1.03);
}
.answer-btn.correct {
  background: #DCFCE7;
  border-color: #22C55E;
  animation: correct-bounce 0.5s ease;
}
.answer-btn.wrong {
  background: #FEE2E2;
  border-color: #EF4444;
  animation: wrong-shake 0.4s ease;
}
@keyframes correct-bounce {
  0%,100% { transform: scale(1); }
  30%      { transform: scale(1.08); }
  60%      { transform: scale(0.96); }
}
@keyframes wrong-shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}

.quiz-feedback {
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  animation: pop-in 0.3s ease;
}
@keyframes pop-in {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.quiz-feedback.feedback-correct {
  background: #DCFCE7;
  color: #15803D;
  border: 2px solid #22C55E;
}
.quiz-feedback.feedback-wrong {
  background: #FEE2E2;
  color: #B91C1C;
  border: 2px solid #EF4444;
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.btn-hint {
  background: #FFF9C4;
  border: 2px solid #F9A825;
  border-radius: 50px;
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: transform 0.15s;
}
.btn-hint:hover:not(:disabled) { transform: scale(1.05); }
.btn-hint:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-next {
  background: linear-gradient(135deg, #66BB6A, #43A047);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 12px 30px;
  font-size: 1.1rem;
  font-weight: 900;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(67,160,71,0.4);
  transition: transform 0.15s;
}
.btn-next:hover { transform: translateY(-2px); }

.hint-box {
  background: #FFF8E1;
  border: 2px dashed #F9A825;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  color: #555;
  margin-top: 14px;
  animation: pop-in 0.3s ease;
}

/* ===== QUIZ RESULT ===== */
.quiz-result {
  text-align: center;
  padding: 20px 0;
}
.result-content {
  background: white;
  border-radius: 28px;
  padding: 40px 28px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
}
.result-mascot { font-size: 5rem; animation: bounce-in 0.6s ease; margin-bottom: 12px; }
.result-content h2 { font-size: 2rem; font-weight: 900; color: #333; margin-bottom: 12px; }
.result-score-text { font-size: 1.4rem; font-weight: 800; color: #E91E63; margin-bottom: 8px; }
.result-highscore-text { font-size: 1rem; font-weight: 700; color: #888; margin-bottom: 28px; }
.result-buttons { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ===== CONFETTI ===== */
#confetti-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 12px;
  height: 12px;
  top: -20px;
  border-radius: 3px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
  .category-grid { grid-template-columns: 1fr; }
  .quiz-answers  { grid-template-columns: 1fr; }
  .stair-block   { width: 76px; }
  .converter     { gap: 8px; }
  .conv-input, .conv-result { font-size: 1.5rem; width: 100px; }
}
