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

:root {
  --c1: #FF6B6B; --c2: #FFD93D; --c3: #6BCB77; --c4: #4D96FF; --c5: #C77DFF;
  --bg: #FFF9F0; --white: #ffffff; --gray: #888; --dark: #333;
  --radius: 18px; --radius-sm: 12px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

html, body { height: 100%; background: var(--bg); font-family: var(--font); }

.screen { display: none; min-height: 100vh; padding: 16px; max-width: 480px; margin: 0 auto; }
.screen.active { display: flex; flex-direction: column; }
.screen-content { display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; }

.app-icon { font-size: 56px; text-align: center; margin-top: 24px; }
.app-title { font-size: 32px; font-weight: 900; color: #FF6B35; text-align: center; }
.subtitle { text-align: center; color: var(--gray); font-size: 14px; }

.grade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grade-btn {
  background: var(--color, #eee);
  border: none; border-radius: var(--radius); padding: 14px 10px;
  color: white; font-size: 14px; font-weight: 900; cursor: pointer;
  box-shadow: 0 4px 0 var(--shadow, #999);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform 0.1s, box-shadow 0.1s;
}
.grade-btn span { font-size: 10px; font-weight: 400; opacity: 0.85; }
.grade-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--shadow, #999); }
.grade-btn--wide { grid-column: 1/-1; }

.back-btn { background: none; border: none; color: var(--c3); font-weight: 800; font-size: 13px; cursor: pointer; text-align: left; padding: 4px 0; }
.screen-title { font-size: 20px; font-weight: 900; color: var(--dark); }
.topic-list { display: flex; flex-direction: column; gap: 10px; }
.topic-item {
  background: var(--white); border: 2px solid var(--border, #eee);
  border-radius: var(--radius); padding: 14px; display: flex; align-items: center;
  gap: 12px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.1s;
}
.topic-item:active { transform: scale(0.98); }
.topic-icon { font-size: 26px; }
.topic-name { font-size: 13px; font-weight: 800; color: var(--dark); }
.topic-count { font-size: 10px; color: var(--gray); margin-top: 2px; }

.progress-row { display: flex; align-items: center; gap: 10px; }
.progress-bar { flex: 1; height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #FFD93D, #FF6B35); border-radius: 4px; transition: width 0.3s; }
.progress-label { font-size: 11px; color: var(--gray); font-weight: 700; }

.question-card {
  background: var(--white); border-radius: var(--radius); padding: 20px;
  border: 2px solid #FFD93D; box-shadow: 0 3px 12px rgba(255,179,71,0.2);
  text-align: center;
}
.question-context { color: var(--gray); font-size: 11px; margin-bottom: 6px; }
.question-text { color: #FF6B35; font-size: 30px; font-weight: 900; line-height: 1.2; }

.answer-display {
  background: var(--white); border: 2px solid var(--c3);
  border-radius: var(--radius-sm); padding: 10px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.answer-display span:first-child { font-size: 22px; font-weight: 700; color: var(--dark); letter-spacing: 3px; }
.backspace-btn { font-size: 18px; color: #ccc; cursor: pointer; padding: 4px; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad-key {
  background: var(--white); border: 2px solid #eee; border-radius: var(--radius-sm);
  padding: 14px; text-align: center; color: var(--dark); font-size: 18px;
  font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 #ddd;
  transition: transform 0.1s, box-shadow 0.1s;
}
.numpad-key:active { transform: translateY(2px); box-shadow: 0 1px 0 #ddd; }
.numpad-hint { background: #FFF0F0; border-color: var(--c1); color: var(--c1); font-size: 11px; }
.numpad-check { background: #F0FFF4; border-color: var(--c3); color: var(--c3); font-size: 20px; }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice-btn {
  background: var(--white); border: 2px solid #eee; border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 14px; font-weight: 700; color: var(--dark);
  cursor: pointer; text-align: left; box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transition: all 0.15s;
}
.choice-btn:active, .choice-btn.selected { border-color: var(--c4); background: #EFF6FF; }

.feedback {
  background: var(--white); border-radius: var(--radius); padding: 16px;
  text-align: center; border: 2px solid #eee;
}
.feedback--correct { border-color: var(--c3); background: #F0FFF4; }
.feedback--wrong { border-color: var(--c1); background: #FFF0F0; }
.feedback-icon { font-size: 36px; margin-bottom: 8px; }
.feedback-msg { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.feedback-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.ai-bubble {
  background: var(--white); border: 2px solid var(--c4);
  border-radius: var(--radius); padding: 14px;
}
.ai-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ai-avatar { font-size: 18px; }
.ai-label { font-size: 11px; font-weight: 800; color: var(--c4); }
.ai-badge { background: #EFF6FF; color: var(--c4); font-size: 9px; padding: 2px 6px; border-radius: 8px; font-weight: 700; }
.ai-text { font-size: 12px; line-height: 1.7; color: var(--dark); }

.end-content { align-items: center; padding-top: 32px; }
.end-icon { font-size: 64px; margin-bottom: 8px; }
.end-title { font-size: 24px; font-weight: 900; color: #FF6B35; text-align: center; }
.score-card {
  background: var(--white); border-radius: var(--radius); padding: 16px 32px;
  text-align: center; border: 2px solid #FFD93D; margin: 8px 0;
  box-shadow: 0 3px 12px rgba(255,217,61,0.2); width: 100%;
}
.score-number { font-size: 48px; font-weight: 900; color: #FFD93D; }
.score-label { font-size: 12px; color: var(--gray); }
.stars { font-size: 28px; letter-spacing: 6px; }
.weak-title { font-size: 12px; font-weight: 800; color: var(--c1); margin-bottom: 6px; }
.weak-list { font-size: 12px; color: var(--dark); list-style: none; line-height: 2; }
.end-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 8px; }

.btn-primary {
  background: var(--c3); color: white; border: none; border-radius: var(--radius-sm);
  padding: 14px; font-size: 14px; font-weight: 900; cursor: pointer;
  box-shadow: 0 3px 0 #44aa55; width: 100%;
}
.btn-secondary {
  background: var(--white); color: var(--gray); border: 2px solid #eee;
  border-radius: var(--radius-sm); padding: 12px; font-size: 14px;
  font-weight: 800; cursor: pointer; width: 100%;
}
.btn-retry { background: var(--c1); color: white; box-shadow: 0 3px 0 #cc4444; border: none; border-radius: var(--radius-sm); padding: 10px 16px; font-weight: 800; font-size: 13px; cursor: pointer; }
.btn-hint-action { background: white; color: var(--c4); border: 2px solid var(--c4); border-radius: var(--radius-sm); padding: 10px 16px; font-weight: 800; font-size: 13px; cursor: pointer; }

@keyframes pop { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.pop { animation: pop 0.3s ease; }
