/* ---------------- RESET / BASE ---------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ---------------- BODY ---------------- */
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;

  /* appearance */
  background: linear-gradient(to right, #ffecd2, #fcb69f);
  min-height: 100vh;

  /* behavior */
  overflow-x: hidden;
  overscroll-behavior: none;

  /* mobile safe area */
  padding-bottom: env(safe-area-inset-bottom);
}

.app-shell {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.main-content {
flex: 1;
overflow-y: auto;
padding-top: 10px;
margin-top: 10px;
}
.container {
width: 100%;
max-width: 100%;
padding: 15px;
}
.app-screen {
  display: flex;
  justify-content: center;
  align-items: center;   /* 🔥 centers vertically */
  min-height: 100%;
  margin-top: 0;
}
.screen {
width: 100%;
max-width: 700px;
background: white;
border-radius: 16px;
padding: 25px;
box-shadow: 0 10px 25px rgba(0,0,0,0.08);
animation: fadeIn 0.3s ease;
}

header {
display: flex;
flex-direction: column;
gap: 10px;
position: sticky;
top: 0;
background: rgba(255,255,255,0.9);
backdrop-filter: blur(10px);
z-index: 1000;
padding: 10px;
}
header h1 {
color: #ff5f6d;
margin-bottom: 20px;
font-size: 1.8rem;
}
.profile-hint {
font-size: 13px;
color: white;
display: inline-block;
text-align: center;
margin: 6px auto;
padding: 6px 12px;
border-radius: 999px;
background: linear-gradient(270deg, #ff9a9e, #fad0c4, #a18cd1, #84fab0);
background-size: 400% 400%;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
animation: gradientMove 6s ease infinite, hintPulse 2.5s ease-in-out infinite;
}

@media (max-width: 600px) {
header {
max-height: 180px;
overflow-y: auto;
padding: 6px 8px;
gap: 4px;
}
header h1 {
font-size: 1rem;
margin: 0;
line-height: 1.2;
}
header h1, header .profile-hint {
/ smaller spacing for small screens */
}
}
/* ---------------- SCREENS (general) ---------------- */
/* default layout used by many screens (initial rules) */
#intro-screen,
#grade-selection,
#operation-selection,
#quiz,
#parent-dashboard {
min-height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
/* 🔥 CHANGE THIS (kept as originally placed) */
justify-content: flex-start;
padding: 15px;
}
/* specific presentation for intro screen (overrides general above) */
#intro-screen {
display: flex;
justify-content: center;
align-items: center;
min-height: 100dvh;
/* animated gradient background */
background: linear-gradient(270deg, #ff9a9e, #a18cd1, #fbc2eb, #84fab0);
background-size: 800% 800%;
animation: gradientMove 12s ease infinite;
position: relative;
overflow: hidden;
}
/* floating bubbles on intro */
#intro-screen::before,
#intro-screen::after {
content: '';
position: absolute;
width: 200px;
height: 200px;
background: rgba(255,255,255,0.2);
border-radius: 50%;
animation: floatBubble 10s infinite ease-in-out;
}
#intro-screen::before { top: 10%; left: 10%; }
#intro-screen::after  { bottom: 10%; right: 10%; animation-delay: 3s; }
/* center visible screens (applies later to preserve cascade) */
#intro-screen:not(.hide),
#grade-selection:not(.hide),
#operation-selection:not(.hide),
#quiz:not(.hide),
#parent-dashboard:not(.hide) {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
/* hide screens by default (so only toggled ones show) */
#grade-selection,
#operation-selection,
#quiz,
#parent-dashboard {
display: none;
}
/* ---------------- INTRO CARD ---------------- */
.intro-card {
background: linear-gradient(135deg, #ffffff, #f0f9ff);
padding: 35px;
border-radius: 25px;
text-align: center;
max-width: 520px;
box-shadow: 0 15px 40px rgba(0,0,0,0.15);
animation: floatIn 0.6s ease;
position: relative;
}
.intro-card::before {
content: '';
position: absolute;
inset: -3px;
border-radius: 25px;
background: linear-gradient(45deg, #ff6ec4, #7873f5, #42e695);
z-index: -1;
filter: blur(8px);
opacity: 0.6;
}
.intro-card h2 {
font-size: 2rem;
color: #ff6b6b;
margin-bottom: 15px;
animation: bounceTitle 2s infinite;
}
.intro-card p {
font-size: 1.1rem;
margin: 10px 0;
color: #333;
}
.intro-actions { margin-top: 20px; }
/* ---------------- UI GRIDS ---------------- */
.grade-grid,
.operation-grid { grid-template-columns: repeat(2, 1fr); }
.answer-grid { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 400px) {
.grade-grid, .operation-grid, .answer-grid { grid-template-columns: 1fr; }
}
/* button grid on larger screens */
@media (min-width: 600px) {
.btn-grid { grid-template-columns: 1fr 1fr; }
}
/* ---------------- BUTTONS ---------------- */
.btn {
background: linear-gradient(135deg, #ff9a9e, #fad0c4);
border: none;
width: 100%;
padding: 16px;
font-size: 1.1rem;
border-radius: 16px;
cursor: pointer;
margin: 5px;
transition: all 0.15s ease;
box-shadow: 0 4px 10px rgba(0,0,0,0.12);
-webkit-tap-highlight-color: transparent;
}
@media (min-width: 600px) {
.btn { width: auto; min-width: 140px; }
}
.btn:active { transform: scale(0.96); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.btn:hover { transform: scale(1.05); transition: 0.2s; }

.secondary {
background: linear-gradient(135deg, #d4fc79, #96e6a1);
}
/ later override (intentionally same order as original file) */
.secondary { background: #ddd; margin-left: 10px; }
/* danger button */
.btn.danger {
background: linear-gradient(135deg, #ff6b6b, #ff3b3b);
color: white;
}
/* back button */
.back-btn {
background-color: #ff5f6d;
color: #fff;
margin-bottom: 15px;
font-size: 1rem;
}
.back-btn:hover { background-color: #ff7f8f; }
/* control bar */
.control-bar { display: flex; gap: 10px; justify-content: space-between; }
.control-bar .btn { flex: 1; }
/* ---------------- PROGRESS / STARS / TIMER ---------------- */
#progress-container {
width: 100%;
height: 20px;
background-color: #e0e0e0;
border-radius: 10px;
margin-bottom: 15px;
overflow: hidden;
}
#progress-bar {
height: 100%;
width: 0%;
background: linear-gradient(to right, #ffb347, #ffcc70);
border-radius: 10px;
transition: width 0.3s ease;
}
#star-box { margin-top: 15px; }
#stars { font-size: 2rem; color: gold; margin-top: 5px; }
#timer-box { font-size: 1.2rem; margin-bottom: 10px; color: #333; font-weight: bold; }
/* question & counting */
#question {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  text-align: center;
  font-weight: bold;
  color: #333;
  margin-bottom: 20px;
  white-space: pre-line;
}
.counting-objects { font-size: 2rem; line-height: 2.5rem; }
.counting-objects span { cursor: pointer; display: inline-block; margin: 5px; font-size: 2.2rem; transition: transform 0.2s; }
.counting-objects span:hover { transform: scale(1.2); }
.counted { opacity: 0.5; transform: scale(0.9); }
/* responsive adjustments */
@media (max-width: 400px) {
#question { font-size: 1.2rem; }
.btn { font-size: 1rem; padding: 10px; }
}
/* ---------------- DRAG & DROP ---------------- */
.draggable {
  padding: 10px 16px;
  margin: 5px;
  background: #1e293b;
  color: #fff;
  border-radius: 8px;
  cursor: grab;
  display: inline-block;
}

.drop-zone {
  display: inline-block;
  min-width: 60px;
  padding: 10px;
  margin: 5px;
  border: 2px dashed #888;
  border-radius: 8px;
  text-align: center;
}
.drop-zone.over { border-color: #4CAF50; background: rgba(76, 175, 80, 0.2); }
.snap { animation: snapIn 0.3s ease; }
.correct-highlight { background: #4CAF50 !important; color: #fff; box-shadow: 0 0 10px #4CAF50; }
.drop-wrong { animation: shake 0.3s; background: rgba(244, 67, 54, 0.2); }
.used { opacity: 0.4; }
/* ---------------- ANIMATIONS ---------------- /
/ fade / float / pop */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes floatIn {
from { transform: translateY(30px) scale(0.95); opacity: 0; }
to   { transform: translateY(0) scale(1);      opacity: 1; }
}
@keyframes popIn {
from { transform: scale(0.95); opacity: 0; }
to   { transform: scale(1); opacity: 1; }
}
@keyframes floatBubble {
0% { transform: translateY(0px); }
50% { transform: translateY(-30px); }
100% { transform: translateY(0px); }
}
@keyframes gradientMove {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
@keyframes hintPulse {
0%, 100% { transform: scale(1); opacity: 0.85; }
50%     { transform: scale(1.05); opacity: 1; }
}
@keyframes snapIn { 0% { transform: scale(1.2); } 100% { transform: scale(1); } }
/* animations referenced by classes (kept single definitions to match final cascade) */
.correct-anim { animation: bounce 0.4s ease, glow 0.6s ease; }
@keyframes glow {
0% { box-shadow: 0 0 0px #4CAF50; }
50%{ box-shadow: 0 0 20px #4CAF50; }
100%{ box-shadow: 0 0 0px #4CAF50; }
}
/* final bounce + shake definitions (keeps the last behavior defined in original file) */
@keyframes bounce {
0% { transform: scale(1); }
50% { transform: scale(1.3); }
100% { transform: scale(1); }
}
@keyframes shake {
0%  { transform: translateX(0); }
25% { transform: translateX(-5px); }
50% { transform: translateX(5px); }
75% { transform: translateX(-5px); }
100%{ transform: translateX(0); }
}
.wrong-anim { animation: shake 0.4s; }
/* screen transitions */
.screen-transition { animation: screenFadeSlide 0.35s ease; }
@keyframes screenFadeSlide {
from { opacity: 0; transform: translateY(20px) scale(0.98); }
to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* ---------------- MASCOT ---------------- */
#mascot {
position: fixed;
bottom: 15px;
right: 10px;
z-index: 999;
display: flex;
flex-direction: column;
align-items: center;
transition: bottom 0.8s ease-out;
}
#mascot-character {
font-size: 60px;
animation: mascotFloat 2s infinite ease-in-out;
cursor: pointer;
transition: transform 0.2s;
}
#mascot-character:active { transform: scale(1.2); }
#mascot-bubble {
background: white;
padding: 10px 15px;
border-radius: 15px;
margin-bottom: 10px;
font-size: 14px;
max-width: 200px;
text-align: center;
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
@keyframes mascotFloat { 0%{transform:translateY(0)}50%{transform:translateY(-8px)}100%{transform:translateY(0)} }
/* reactions reuse bounce/shake */
.mascot-happy { animation: bounce 0.4s; }
.mascot-sad   { animation: shake 0.4s; }
/* hand wave */
#mascot-hand {
position: absolute;
top: 10px;
right: -10px;
font-size: 20px;
animation: wave 2s infinite;
}
@keyframes wave {
0% { transform: rotate(0deg); }
25% { transform: rotate(20deg); }
50% { transform: rotate(-10deg); }
75% { transform: rotate(20deg); }
100% { transform: rotate(0deg); }
}
/* ---------------- MODALS / PROGRESS ---------------- */
.modal, #progress-modal, .dashboard-overlay {
position: fixed;
inset: 0;
display: flex;
justify-content: center;
align-items: center;
z-index: 5000;
background: rgba(0,0,0,0.5);
}
#progress-modal { background: rgba(0,0,0,0.6); z-index: 2000; }
.modal-content, .progress-card {
background: white;
padding: 20px;
border-radius: 16px;
width: 90%;
max-width: 500px;
text-align: center;
animation: popIn 0.25s ease;
max-height: 85vh;
overflow-y: auto;
overflow-x: hidden;
word-wrap: break-word;
scroll-behavior: smooth;
}
@media (max-width: 500px) {
.modal-content { width: 95%; max-height: 90vh; padding: 16px; }
}
.modal-content input {
width: 100%;
padding: 12px;
margin: 10px 0;
border-radius: 10px;
border: 1px solid #ddd;
font-size: 1rem;
}
/* avatar picker */
#avatar-picker, #edit-avatar-picker {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 6px;
margin: 10px 0;
}
#avatar-picker span, #edit-avatar-picker span {
font-size: 26px;
cursor: pointer;
padding: 6px;
border-radius: 8px;
transition: 0.2s;
}
#avatar-picker span:hover, #edit-avatar-picker span:hover { background: #f3f4f6; }
#avatar-picker .selected, #edit-avatar-picker .selected { background: #ff9a9e; }
/* modal actions */
.modal-actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 10px;
}
.modal-actions .btn { flex: 1 1 45%; }
.modal-text { font-size: 0.95rem; margin: 10px 0; color: #555; }
/* ---------------- DASHBOARD ---------------- */
.progress-card { padding: 20px; border-radius: 15px; max-height: 80vh; overflow-y: auto; width: 90%; max-width: 500px; }
.progress-entry {
border-left: 4px solid #4CAF50;
padding-left: 10px;
margin-bottom: 10px;
background: #fafafa;
border-radius: 6px;
}
.dashboard-section {
margin-bottom: 20px;
padding: 10px;
border-radius: 10px;
background: #f9f9f9;
}
.dashboard-section h3 { margin-bottom: 8px; }
/* alerts & trends */
.alert {
background: #ffe0e0;
color: #b00020;
padding: 8px;
border-radius: 8px;
margin-bottom: 8px;
font-size: 14px;
font-weight: bold;
}
.weak-skill, .weak-item { background: #fff3cd; padding: 6px; border-radius: 6px; margin-bottom: 5px; font-size: 14px; }
.trend-up { color: green; }
.trend-down { color: red; }
.trend-item { padding: 6px; margin-bottom: 5px; border-radius: 6px; background: #eef6ff; }
/* dashboard modal */
.dashboard-overlay {
background: rgba(0,0,0,0.6);
z-index: 3000;
}
.dashboard-modal {
width: 92%;
max-width: 700px;
height: 85vh;
background: white;
border-radius: 18px;
display: flex;
flex-direction: column;
overflow: hidden;
animation: popIn 0.25s ease;
}
.dashboard-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px 20px;
background: #4CAF50;
color: white;
}
.close-btn {
background: transparent;
border: none;
font-size: 20px;
color: white;
cursor: pointer;
}
.dashboard-content {
padding: 15px;
overflow-y: auto;
flex: 1;
}
.history-item {
background: white;
border-left: 4px solid #4CAF50;
padding: 8px;
margin-bottom: 8px;
border-radius: 8px;
}
.dashboard-table {
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
.dashboard-table th {
text-align: left;
background: #4CAF50;
color: white;
padding: 8px;
}
.dashboard-table td {
padding: 8px;
border-bottom: 1px solid #eee;
transition: background 0.2s;
}
.dashboard-table tr:nth-child(even) { background: #f9f9f9; }
.dashboard-table tr:hover { background: #f1f7ff; }
@media (max-width: 500px) {
.dashboard-table th, .dashboard-table td { padding: 5px; }
}
/* trend chart and controls */
#trendChart { background: white; border-radius: 10px; padding: 10px; }
.chart-controls { display: flex; gap: 10px; margin-bottom: 10px; }
.chart-controls select { padding: 6px; border-radius: 6px; border: 1px solid #ccc; }
/* child selector */
#child-selector {
display: flex;
gap: 10px;
margin-bottom: 15px;
justify-content: center;
align-items: center;
background: rgba(255,255,255,0.9);
backdrop-filter: blur(10px);
padding: 10px 12px;
border-radius: 14px;
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
#child-select {
padding: 10px 12px;
border-radius: 10px;
border: none;
font-size: 0.95rem;
background: #f3f4f6;
box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
outline: none;
cursor: pointer;
}
#child-select:focus { box-shadow: 0 0 0 2px #ff9a9e; }
@media (max-width: 500px) {
#child-selector { flex-direction: column; align-items: stretch; }
#child-select, #child-selector .btn { width: 100%; }
}
#child-selector .btn { padding: 10px 14px; font-size: 0.9rem; }
/* ---------------- CHILD PROFILES ---------------- */
#child-profiles {
display: flex;
gap: 10px;
overflow-x: auto;
padding: 5px;
scroll-snap-type: x mandatory;
}
.child-card {
scroll-snap-align: start;
min-width: 70px;
padding: 10px;
border-radius: 12px;
background: #ffffff;
text-align: center;
cursor: pointer;
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
transition: 0.2s;
}
.child-card:hover { transform: translateY(-3px); }
.child-avatar { font-size: 28px; margin-bottom: 5px; }
.child-name { font-size: 12px; font-weight: bold; }
.child-card.active { border: 2px solid #ff9a9e; box-shadow: 0 0 10px rgba(255,154,158,0.6); }
/* mobile child profile sizing */
@media (max-width: 600px) {
#child-selector { padding: 6px; gap: 6px; }
.child-card { min-width: 55px; padding: 6px; }
.child-avatar { font-size: 20px; }
.child-name { font-size: 10px; }
}
/* hide scrollbar for profiles on webkit */
#child-profiles::-webkit-scrollbar { display: none; }
/* ---------------- SMALL CARDS ---------------- */
.resume-card {
background: white;
padding: 15px;
border-radius: 15px;
margin: 15px auto;
max-width: 300px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
text-align: center;
}
.resume-card h3 { margin-bottom: 10px; }
.add-card { background: #f3f4f6; opacity: 0.8; }
.add-card:hover { opacity: 1; }
/* ---------------- UTILITIES ---------------- */
.hide { display: none !important; }
.top-actions { width: 100%; max-width: 500px; margin: 10px auto 15px; }
.screen-content { width: 100%; max-width: 500px; }
.good { color: green; }
.bad  { color: red; }
/* header compact state */
header.compact { max-height: 60px; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 2000;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
}

/* top bar */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
}

/* hamburger */
.menu-btn {
  font-size: 22px;
  background: none;
  border: none;
  cursor: pointer;
}

/* title */
.app-title {
  font-size: 1.2rem;
  color: #ff5f6d;
  margin: 0;
}

.nav-section {
  padding: 15px;
  border-bottom: 1px solid #f1f1f1;
}

.nav-section h3 {
  margin-bottom: 10px;
  font-size: 1rem;
  color: #555;
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 600px) {
  .app-title {
    font-size: 1rem;
  }
}


.nav-drawer {
  position: relative;
  z-index: 9999;

  width: 100%;
  background: white;
  border-top: 1px solid #eee;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);

  max-height: 110vh;
  overflow-y: auto;

  animation: slideDown 0.3s ease;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}



/* Modals (always highest) */
.modal,
.dashboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
}

@media (max-width: 600px) {

  /* shrink nav buttons ONLY on phones */
  .nav-drawer .btn {
    padding: 8px 10px;
    font-size: 0.85rem;
    width: auto;
    min-width: unset;
  }

  /* make buttons sit inline */
  .nav-section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  /* force title row separation */
  .nav-section h3 {
    flex: 0 0 100%;
    margin-bottom: 6px;
  }

}

@media (max-width: 600px) {
  .nav-drawer .btn {
    border-radius: 10px;
  }
}

@media (max-width: 600px) {

  /* make profile row horizontal */
  #child-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
  }

  /* ensure profiles stay in a row */
  #child-profiles {
    display: flex;
    gap: 10px;
  }

  /* make each card larger */
  .child-card {
    min-width: 80px;
    padding: 10px;
    border-radius: 14px;
  }

  /* bigger avatar (THIS is your main target) */
  .child-avatar {
    font-size: 32px;
  }

  /* slightly bigger name */
  .child-name {
    font-size: 12px;
  }

}

@media (max-width: 600px) {
  .child-card:active {
    transform: scale(0.95);
  }
}



.drop-zone {
  background: rgba(0,0,0,0.03);
  transition: all 0.2s ease;
}
@media (max-width: 600px) {
  #answer-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
}
@media (max-width: 600px) {
  .draggable {
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
  }
}

#question-container,
#answer-buttons,
.controls,
#score-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

@media (max-width: 600px) {

  .screen {
    padding: 18px;
  }

  #question {
    font-size: 1.4rem;
  }

  #answer-buttons {
    flex-direction: column; /* or keep wrap if you prefer grid feel */
  }

}

#answer-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.draggable {
  position: relative;
  user-select: none;
  touch-action: none;
}

@media (max-width: 600px) {

  /* ANSWER CONTAINER */
  #answer-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;

    justify-items: center;
    align-items: center;

    width: 100%;
    max-width: 260px;
    margin: 0 auto;
  }

  /* DRAGGABLE BUTTONS */
  .draggable {
    width: 100%;
    max-width: 90px;
    aspect-ratio: 1 / 1;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    margin: 0;
    border-radius: 12px;

    font-size: 1.2rem;

    touch-action: none;
    user-select: none;
  }

  .draggable:active {
    transform: scale(1.05);
    z-index: 2000;
  }

  /* DROP ZONE */
  .drop-zone {
    width: clamp(90px, 25vw, 120px);
    aspect-ratio: 1 / 1;

    display: flex;
    align-items: center;
    justify-content: center;

    margin: 8px auto;
    padding: 0;
    border-radius: 12px;

    font-size: 1.2rem;
  }

  .drop-zone.over {
    border: 3px dashed #4CAF50;
    background: rgba(76, 175, 80, 0.15);
  }
}