:root {
  --pink: #ff5fa2;
  --purple: #8a5cf6;
  --blue: #38bdf8;
  --green: #34d399;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --ink: #2b2150;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(120, 80, 200, 0.25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Baloo 2", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  min-height: 100%;
}

body {
  background: linear-gradient(135deg, #ffd6ec 0%, #c5e3ff 50%, #d6ffe9 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* floating background blobs */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.35;
  z-index: 0;
  animation: float 9s ease-in-out infinite;
}
.blob.b1 { width: 160px; height: 160px; background: var(--pink); top: 8%; left: 6%; }
.blob.b2 { width: 120px; height: 120px; background: var(--blue); top: 60%; left: 80%; animation-delay: 1.5s; }
.blob.b3 { width: 100px; height: 100px; background: var(--yellow); top: 78%; left: 12%; animation-delay: 3s; }
.blob.b4 { width: 140px; height: 140px; background: var(--green); top: 12%; left: 78%; animation-delay: 2s; }
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-26px) scale(1.06); }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 18px 60px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand h1 {
  font-size: clamp(26px, 6vw, 44px);
  margin: 0;
  background: linear-gradient(90deg, var(--pink), var(--purple), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 0 rgba(255,255,255,0.4);
}
.brand .logo {
  font-size: 40px;
  animation: wobble 3s ease-in-out infinite;
}
@keyframes wobble { 0%,100%{transform:rotate(-8deg)} 50%{transform:rotate(8deg)} }

.star-counter {
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Mascot banner */
.mascot-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 18px;
}
.mascot {
  font-size: 56px;
  animation: bob 2.4s ease-in-out infinite;
  flex: 0 0 auto;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-10px) rotate(4deg); }
}
.mascot-bubble {
  background: #fff;
  border-radius: 20px 20px 20px 4px;
  padding: 14px 18px;
  font-size: 20px;
  font-weight: 800;
  box-shadow: var(--shadow);
  position: relative;
  animation: popIn 0.5s ease;
}
.mascot-bubble span { font-size: 15px; font-weight: 600; color: #8a82a8; }
@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

/* Tile entrance animation */
.tile-in { animation: tilePop 0.5s cubic-bezier(.2,1.3,.5,1) backwards; }
@keyframes tilePop {
  0% { transform: scale(0.3) translateY(30px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Hello card with sparkles */
.hello-card { margin-top: 20px; text-align: center; position: relative; overflow: hidden; }
.sparkles { display: flex; justify-content: space-around; font-size: 24px; margin-bottom: 6px; }
.sparkles span { animation: twinkle 1.8s ease-in-out infinite; }
.sparkles span:nth-child(2) { animation-delay: 0.3s; }
.sparkles span:nth-child(3) { animation-delay: 0.6s; }
.sparkles span:nth-child(4) { animation-delay: 0.9s; }
.sparkles span:nth-child(5) { animation-delay: 1.2s; }
@keyframes twinkle {
  0%, 100% { transform: scale(0.7); opacity: 0.4; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* Floating emojis drifting up */
.floater {
  position: fixed;
  bottom: -40px;
  z-index: 2;
  pointer-events: none;
  animation: drift linear forwards;
  opacity: 0.85;
}
@keyframes drift {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.85; }
  100% { transform: translateY(-108vh) rotate(40deg); opacity: 0; }
}

/* Home tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 10px;
}
.tile {
  border: none;
  border-radius: 28px;
  padding: 26px 18px;
  color: #fff;
  font-size: clamp(20px, 4.5vw, 30px);
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 150px;
  justify-content: center;
}
.tile:active { transform: scale(0.95); }
.tile:hover { transform: translateY(-6px); }
.tile .emoji { font-size: 56px; animation: pop 2.5s ease-in-out infinite; }
@keyframes pop { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }
.tile.toetse { background: linear-gradient(135deg, var(--pink), #ff8fc0); }
.tile.studeer { background: linear-gradient(135deg, var(--blue), #6ad0ff); }
.tile.flits { background: linear-gradient(135deg, var(--green), #7be6b5); }
.tile.sterre { background: linear-gradient(135deg, var(--orange), var(--yellow)); }

/* Generic card */
.card {
  background: var(--card);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.section-title {
  font-size: clamp(22px, 5vw, 32px);
  margin: 6px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-btn {
  border: none;
  background: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  color: var(--purple);
}
.back-btn:active { transform: scale(0.95); }

/* List items */
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 10px solid var(--purple);
  transition: transform 0.12s ease;
}
.list-item:active { transform: scale(0.98); }
.list-item .li-emoji { font-size: 34px; }
.list-item .li-text { flex: 1; }
.list-item .li-title { font-weight: 800; font-size: 20px; }
.list-item .li-sub { color: #8a82a8; font-size: 14px; }
.subject-pill {
  background: var(--purple);
  color: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
}

/* Subject filter tabs */
.subject-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.subject-tabs::-webkit-scrollbar { display: none; }
.subject-tab {
  flex: 0 0 auto;
  white-space: nowrap;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-family: inherit;
  font-weight: 800;
  font-size: 16px;
  background: #fff;
  color: var(--purple);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.subject-tab:active { transform: scale(0.94); }
.subject-tab.active {
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: #8a82a8;
  font-size: 18px;
}
.empty .big { font-size: 60px; display: block; margin-bottom: 10px; }

/* Quiz */
.quiz-progress {
  height: 16px;
  background: #ece7ff;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.quiz-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.question {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  margin-bottom: 18px;
  text-align: center;
}
.answers { display: grid; gap: 12px; }
.answer {
  border: 3px solid #ece7ff;
  background: #fff;
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s ease, border-color 0.1s ease;
  color: var(--ink);
}
.answer:active { transform: scale(0.98); }
.answer.correct { border-color: var(--green); background: #e7fff4; animation: goodshake 0.5s; }
.answer.wrong { border-color: #ff6b6b; background: #ffeaea; animation: badshake 0.4s; }
.answer.disabled { pointer-events: none; opacity: 0.85; }
@keyframes goodshake { 0%,100%{transform:scale(1)} 40%{transform:scale(1.06)} }
@keyframes badshake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

.text-answer {
  width: 100%;
  border: 3px solid #ece7ff;
  border-radius: 18px;
  padding: 16px;
  font-size: 22px;
  text-align: center;
  font-family: inherit;
}

.big-btn {
  border: none;
  border-radius: 18px;
  padding: 16px 22px;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  cursor: pointer;
  box-shadow: var(--shadow);
  width: 100%;
  margin-top: 14px;
}
.big-btn:active { transform: scale(0.97); }
.big-btn.green { background: linear-gradient(135deg, var(--green), #2bb985); }

.feedback {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  margin-top: 16px;
  min-height: 34px;
}
.feedback.good { color: #18a06a; }
.feedback.bad { color: #e0556b; }

/* Result screen */
.result {
  text-align: center;
  padding: 20px;
}
.result .score-ring {
  font-size: 70px;
  margin: 10px 0;
  animation: pop 1.4s ease-in-out infinite;
}
.result h2 { font-size: 34px; margin: 6px 0; }
.result .stars-earned {
  font-size: 26px;
  font-weight: 800;
  color: var(--orange);
  margin: 12px 0;
}

/* Flashcards */
.flashcard {
  perspective: 1200px;
  margin: 10px auto 18px;
  max-width: 460px;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 240px;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  text-align: center;
  box-shadow: var(--shadow);
}
.flash-front { background: linear-gradient(135deg, var(--blue), #8ad8ff); color: #fff; }
.flash-back { background: linear-gradient(135deg, var(--green), #7be6b5); color: #fff; transform: rotateY(180deg); }
.flash-hint { text-align: center; color: #8a82a8; margin-bottom: 10px; }
.flash-nav { display: flex; gap: 12px; }
.flash-nav .big-btn { margin-top: 0; }

/* Library viewer */
.viewer img, .viewer video { width: 100%; border-radius: 18px; }
.viewer iframe { width: 100%; height: 70vh; border: none; border-radius: 18px; }

/* Text notes */
.note-body { font-size: 18px; line-height: 1.6; color: var(--ink); }
.note-body h3 {
  font-size: 22px;
  margin: 4px 0 12px;
  color: var(--purple);
}
.note-body p { margin: 0 0 12px; }
.note-body ul { margin: 0 0 12px; padding-left: 6px; list-style: none; }
.note-body li { margin: 8px 0; padding-left: 30px; position: relative; }
.note-body li::before { content: "👉"; position: absolute; left: 0; }
.note-body b { color: var(--pink); }
.note-body .hint {
  display: block;
  color: #8a82a8;
  font-size: 15px;
  font-style: italic;
}
.note-body .example {
  background: #f3f0ff;
  border-radius: 14px;
  padding: 10px 14px;
  margin: 8px 0;
}

/* "Ek het dit klaar geleer" checkbox */
.learned-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 3px solid #ece7ff;
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
  cursor: pointer;
  font-size: 20px;
  font-weight: 800;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease;
}
.learned-box:active { transform: scale(0.97); }
.learned-box .learned-check { font-size: 30px; }
.learned-box.on {
  border-color: var(--green);
  background: linear-gradient(135deg, #e7fff4, #d6ffe9);
  color: #18a06a;
  animation: goodshake 0.5s;
}
.learned-tick { font-size: 16px; }
.list-item.is-learned { border-left-color: var(--green); background: #f3fff9; }

/* badges */
.badges { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.badge {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #fff;
  border-radius: 18px;
  padding: 14px;
  font-weight: 800;
  text-align: center;
  min-width: 110px;
  box-shadow: var(--shadow);
  animation: pop 3s ease-in-out infinite;
}
.badge .b-emoji { font-size: 38px; display: block; }
.badge.locked { background: #d9d4e8; color: #fff; opacity: 0.7; animation: none; }

/* confetti */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.confetti-piece {
  position: absolute;
  width: 12px; height: 12px;
  top: -20px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 1; }
}

.footer-link {
  text-align: center;
  margin-top: 30px;
}
.footer-link a {
  color: var(--purple);
  font-weight: 700;
  text-decoration: none;
  opacity: 0.7;
}

.hidden { display: none !important; }

/* ===== AUTH (login / register) ===== */
.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.auth-tab {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 14px;
  font-family: inherit;
  font-weight: 800;
  font-size: 18px;
  background: #fff;
  color: var(--purple);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.auth-tab:active { transform: scale(0.96); }
.auth-tab.active {
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
}

.auth-card {
  max-width: 480px;
  margin: 0 auto 16px;
}

.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
  font-size: 16px;
}
.field input {
  width: 100%;
  border: 3px solid #ece7ff;
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 18px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}
.field input:focus { border-color: var(--purple); }

/* Brand / auth logo images */
.auth-logo {
  width: 200px;
  max-width: 70%;
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 8px 18px rgba(120, 80, 200, 0.25));
}
.brand-logo {
  height: 52px;
  width: auto;
  display: block;
}
.brand { gap: 8px; }

/* Logout button in topbar */
.logout-btn {
  border: none;
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  color: var(--purple);
  box-shadow: var(--shadow);
  cursor: pointer;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn:active { transform: scale(0.95); }

/* ---------- Subject picker (Vakke) ---------- */
.subj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 10px 0;
}
.subj-tile {
  position: relative;
  border: 3px solid #ece7ff;
  background: #fff;
  border-radius: 16px;
  padding: 12px 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.subj-tile:hover { transform: translateY(-2px); }
.subj-tile.sel {
  border-color: var(--purple);
  background: linear-gradient(135deg, #f4efff, #ece4ff);
  box-shadow: 0 6px 16px rgba(138, 92, 246, 0.25);
}
.subj-emoji { font-size: 28px; }
.subj-name { line-height: 1.2; }
.subj-check {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-size: 13px;
  line-height: 22px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.subj-tile.sel .subj-check { opacity: 1; transform: scale(1); }
.subj-custom-tag {
  font-size: 11px;
  font-weight: 800;
  color: #8a5cf6;
  background: #efe8ff;
  border-radius: 999px;
  padding: 1px 8px;
}
.subj-custom-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}
.subj-custom-row input {
  flex: 1;
  min-width: 160px;
  border: 3px solid #ece7ff;
  border-radius: 14px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  outline: none;
}
.subj-custom-row input:focus { border-color: var(--purple); }

/* ---------- Language switch (🇿🇦 / 🇬🇧) ---------- */
.lang-switch {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 4px 0 14px;
}
.lang-btn {
  border: 3px solid #ece7ff;
  background: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.lang-btn:active { transform: scale(0.95); }
.lang-btn.active {
  border-color: var(--purple);
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
}

/* Vakke edit modal */
.vakke-modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 60, 0.55);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.vakke-modal-card {
  background: #fff;
  border-radius: 22px;
  padding: 20px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(30, 20, 60, 0.35);
}

/* ---------- Opsommings (AI summaries) ---------- */
.ops-previews { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.ops-thumb { position: relative; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; border: 2px solid #e3e1ff; }
.ops-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ops-thumb button { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.55); color: #fff; border: none; border-radius: 8px; width: 22px; height: 22px; font-size: 11px; cursor: pointer; line-height: 1; }
.ops-summary { line-height: 1.55; }
.ops-summary h3 { color: var(--purple, #8a5cf6); margin: 14px 0 6px; }
.ops-summary h4 { color: #5b4ad6; margin: 12px 0 4px; }
.ops-summary ul { margin: 4px 0 10px; padding-left: 22px; }
.ops-summary li { margin: 3px 0; }
.ops-summary p { margin: 6px 0; }
