:root {
  --bg: #fff8f0;
  --card: #fff;
  --primary: #ff8a5b;
  --primary-d: #ff6b3d;
  --pink: #ffb3ba;
  --mint: #b5ead7;
  --yellow: #ffe39d;
  --blue: #b8e0f6;
  --purple: #d7b9ff;
  --text: #3d2c2c;
  --muted: #7a6a6a;
  --shadow: 0 6px 18px rgba(255, 138, 91, 0.18);
  --radius: 22px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Comic Sans MS', 'Be Vietnam Pro', 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(circle at 10% 20%, var(--yellow) 0, transparent 30%),
    radial-gradient(circle at 90% 10%, var(--mint) 0, transparent 32%),
    radial-gradient(circle at 80% 90%, var(--pink) 0, transparent 30%),
    var(--bg);
  background-attachment: fixed;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

header.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 12px;
}
.brand {
  font-size: 28px;
  font-weight: bold;
  color: var(--primary-d);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand .mascot { font-size: 36px; }
.topbar .nav-links { display: flex; gap: 10px; }

h1 { font-size: 36px; margin: 12px 0 6px; }
h2 { font-size: 24px; margin: 18px 0 10px; }
p { line-height: 1.55; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, background 0.15s;
  font-family: inherit;
}
.btn:hover { background: var(--primary-d); }
.btn:active { transform: scale(0.97); }
.btn.big { font-size: 22px; padding: 16px 32px; }
.btn.ghost {
  background: transparent;
  color: var(--primary-d);
  border: 2px solid var(--primary);
}
.btn.ghost:hover { background: var(--primary); color: #fff; }
.btn.danger { background: #ff5b6b; }
.btn.danger:hover { background: #e44a59; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: var(--radius-sm);
  border: 2px solid #f3d8c8;
  background: #fffdfb;
  font-family: inherit;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
}
label { display: block; margin: 8px 0 6px; font-weight: bold; color: var(--muted); }

.grid {
  display: grid; gap: 16px;
}
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* Home */
.hero {
  text-align: center;
  padding: 40px 20px 20px;
}
.hero .mascot { font-size: 88px; display: block; margin-bottom: 12px; }
.hero h1 { font-size: 48px; color: var(--primary-d); margin: 0 0 8px; }
.hero .sub { font-size: 20px; color: var(--muted); }

.profile-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  border: 3px solid transparent;
}
.profile-card:hover { transform: translateY(-4px); border-color: var(--primary); }
.profile-card .avatar { font-size: 72px; line-height: 1; }
.profile-card .name { font-size: 22px; font-weight: bold; margin-top: 8px; }
.profile-card .level { font-size: 14px; color: var(--muted); }

/* Letters grid (mầm non) */
.letter-tile {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 18px 10px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s;
  user-select: none;
}
.letter-tile:hover { transform: scale(1.05); }
.letter-tile .char {
  font-size: 56px; font-weight: bold; color: var(--primary-d);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
}
.letter-tile .ex { font-size: 14px; color: var(--muted); }
.letter-tile .emoji { font-size: 28px; }

/* Topic chips */
.topic-chip {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.12s;
}
.topic-chip:hover { transform: translateY(-3px); }
.topic-chip .emoji { font-size: 54px; }
.topic-chip .title { font-size: 20px; font-weight: bold; }

/* Word card (lớp 1) */
.word-card {
  text-align: center;
  padding: 28px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.word-card .emoji { font-size: 100px; display: block; }
.word-card .word {
  font-size: 64px; font-weight: bold;
  color: var(--primary-d);
  margin: 10px 0;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
}
.steps {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  font-size: 28px; margin: 16px 0;
}
.step {
  background: #fff3e6;
  border-radius: 14px;
  padding: 8px 18px;
  opacity: 0.35;
  transition: opacity 0.25s, transform 0.25s, background 0.25s;
}
.step.active {
  opacity: 1;
  background: var(--yellow);
  transform: scale(1.18);
}
.step.final {
  background: var(--mint);
  color: var(--primary-d);
  font-weight: bold;
}

.toolbar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
  margin-top: 18px;
}
.toolbar .btn { min-width: 130px; }

.stars { font-size: 32px; letter-spacing: 4px; }
.star-on { color: #ffc83a; }
.star-off { color: #e5d5c5; }

.banner {
  background: #fff3cd;
  border-left: 6px solid #ffc107;
  padding: 12px 16px;
  border-radius: 10px;
  margin: 12px 0;
  color: #5b4a00;
}
.banner.err {
  background: #ffe1e3;
  border-left-color: #ff5b6b;
  color: #6b1d23;
}
.banner.ok {
  background: #d6f5e3;
  border-left-color: #2ecc71;
  color: #1d5b3a;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

table {
  width: 100%; border-collapse: collapse; margin-top: 10px;
}
th, td {
  padding: 10px 12px; border-bottom: 1px solid #f3d8c8; text-align: left;
}
th { background: #fff3e6; color: var(--primary-d); }

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  max-width: 90vw;
}
dialog::backdrop { background: rgba(0,0,0,0.4); }

/* Animations */
@keyframes pop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.pop { animation: pop 0.35s ease-out; }

@keyframes wiggle {
  0%,100% { transform: rotate(0deg); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
.wiggle { animation: wiggle 0.5s ease-in-out; }

.reward-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px; z-index: 999;
}
.reward-overlay .big-emoji { font-size: 160px; animation: pop 0.5s ease-out; }
.reward-overlay .msg { font-size: 28px; color: var(--primary-d); font-weight: bold; text-align: center; max-width: 90vw; }

/* Mascot */
.mascot { vertical-align: middle; line-height: 0; }
.mascot-svg { width: 100%; height: 100%; }
.mascot-state-idle .mascot-svg { animation: mascot-breathe 3s ease-in-out infinite; }
.mascot-state-happy .mascot-svg { animation: mascot-bounce 0.5s ease-out 2; }
.mascot-state-wiggle .mascot-svg { animation: mascot-wiggle 0.5s ease-in-out; }
.mascot-state-sad .mascot-svg { transform: rotate(-5deg); filter: saturate(0.5); }

@keyframes mascot-breathe {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes mascot-bounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes mascot-wiggle {
  0%,100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

/* Subject chip */
.subject-chip {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  border: 3px solid transparent;
}
.subject-chip:hover { transform: translateY(-4px); border-color: var(--primary); }
.subject-chip .subject-name { font-size: 24px; font-weight: bold; margin-top: 8px; color: var(--primary-d); }
.subject-chip .subject-meta { font-size: 14px; color: var(--muted); }

/* Skill tree path */
.skill-path { position: relative; padding: 30px 0; }
.skill-node {
  position: relative;
  width: 90px; height: 90px;
  margin: 16px auto;
  border-radius: 50%;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s;
  border: 4px solid var(--primary);
}
.skill-node.locked { background: #f0e8e0; border-color: #d4c4b4; cursor: not-allowed; opacity: 0.55; }
.skill-node.done { border-color: #2ecc71; }
.skill-node:not(.locked):hover { transform: scale(1.07); }
.skill-node .stars { font-size: 16px; }
.skill-node .icon { font-size: 36px; }
.skill-node-title { text-align: center; font-size: 14px; color: var(--text); max-width: 140px; margin: 0 auto; }

/* Math tile / shape tile */
.count-emoji { font-size: 64px; }
.compare-num { font-size: 80px; font-weight: bold; color: var(--primary-d); }
