@import url('https://fonts.googleapis.com/css2?family=Luckiest+Guy&family=Quicksand:wght@400;600;700&family=Roboto+Mono:wght@500&display=swap');

:root {
  --blox-blue: #00A2FF;
  --blox-green: #10b981;
  --blox-red: #EF4444;
  --blox-magenta: #FF00FF;
  --ink: #1e293b;
  --bg: #f3f4f6;
}

body {
  font-family: 'Quicksand', sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

.font-blox { font-family: 'Luckiest Guy', cursive; letter-spacing: 1px; }
.font-report { font-family: 'Roboto Mono', monospace; }

/* Casita */
.casita-container{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 0;
  font-size: clamp(1.8rem, 8vw, 2.8rem);
  line-height: 1.1;
  font-weight: 800;
  margin: 2.5rem auto;
  text-align: left;
}
.divisor-ui{
  padding-right: .8rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--blox-blue);
}
.dividendo-ui-box{
  border-left: 6px solid var(--blox-blue);
  border-top: 6px solid var(--blox-blue);
  padding-left: .8rem;
  padding-top: .5rem;
  position: relative;
  min-width: 150px;
  color: var(--blox-green);
}
.cociente-ui{
  position: absolute;
  top: -1.3em;
  left: .8rem;
  color: var(--blox-magenta);
  white-space: pre;
  letter-spacing: .05em;
}
.residuo-line{ color: var(--blox-green); font-size: .9em; white-space: pre; }
.subtraction-line{
  color: var(--blox-red);
  font-size: .8em;
  border-bottom: 2px solid var(--blox-red);
  display: inline-block;
  white-space: pre;
}

/* Buttons */
.btn-blox{
  width: 100%;
  padding: 1.25rem;
  border-radius: 1.2rem;
  font-family: 'Luckiest Guy', cursive;
  text-transform: uppercase;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  color: #fff !important;
  transition: transform .1s, filter .2s;
  box-shadow: 0 6px 0 rgba(0,0,0,.2);
  border: none;
  cursor: pointer;
}
.btn-blox:active{ transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.btn-blue{ background-color: #3b82f6; }
.btn-green{ background-color: #10b981; }
.btn-black{ background-color: #1e293b; }
.btn-yellow{ background-color: #eab308; }
.btn-orange{ background-color: #f97316; }

.active-level{
  background-color: #10b981 !important;
  color: white !important;
  border: 3px solid #059669 !important;
  transform: scale(1.05);
}

/* Robux icon */
.robux-icon{
  display:inline-block;
  width:22px;
  height:22px;
  background:#fff;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  border:2px solid #232527;
  vertical-align: middle;
}
.robux-icon-dark{ background:#232527; border:2px solid #fff; }

/* Goals */
.goals-card{ background:#fff; border-radius:1.5rem; border:2px solid #e5e7eb; overflow:hidden; }
.goal-row{ display:grid; grid-template-columns: 1fr 1fr 1fr; align-items:center; padding:1rem; border-bottom:1px solid #f3f4f6; text-align:center; }
.goal-row:last-child{ border-bottom:none; }
.missing-text{ color:#EF4444; font-size:.85rem; font-weight:800; }
.achieved-text{ color:#10B981; font-size:.85rem; font-weight:800; }

/* Pet */
.pet-bounce{ animation: bounce 1.5s infinite; }
@keyframes bounce { 0%,100%{transform: translateY(0);} 50%{transform: translateY(-10px);} }

/* Flash bar */
.flash-timer-bar{
  height: 12px;
  background:#e2e8f0;
  border-radius:6px;
  overflow:hidden;
  margin-bottom:1.5rem;
  border:2px solid #cbd5e1;
}
.flash-timer-fill{
  height:100%;
  background:#f97316;
  transition: width 1s linear;
}

/* Screens */
.screen{ display:none; }
.screen.active{ display:block; animation: fadeIn .4s ease-out; }
@keyframes fadeIn{ from{opacity:0; transform: translateY(10px);} to{opacity:1; transform: translateY(0);} }

@media print{
  .no-print{ display:none !important; }
  #report-view{ display:block !important; position: static; width:100%; border:none; background:white; padding:0; }
}


/* -------- Ajustes móviles (responsive) -------- */
@media (max-width: 420px) {
  .btn-blox{
    font-size: 1.05rem;
    padding: 1rem;
    border-radius: 1rem;
  }
  .font-blox{
    letter-spacing: 0.5px;
  }
  .op-sign{
    font-size: 2.1rem;
  }
  .op-card{
    padding: .9rem;
    border-radius: 1.25rem;
  }
}


/* ====== EDU FRACTIONS (mobile-first) ====== */
.edu-frac-row{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:14px;
  flex-wrap:nowrap;
}
.edu-op{
  font-family:'Luckiest Guy', cursive;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  color:#4f46e5; /* indigo */
  line-height:1;
}
.edu-frac-box{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width: 90px;
}
.edu-frac{
  display:inline-grid;
  grid-template-rows:auto 6px auto;
  align-items:center;
  justify-items:center;
  padding: 10px 16px;
  border-radius: 18px;
  background:#ffffff;
  border:2px solid rgba(99,102,241,.25);
  box-shadow: 0 8px 20px rgba(2,6,23,.06);
}
.edu-num,.edu-den{
  font-family:'Luckiest Guy', cursive;
  font-size: clamp(1.6rem, 8vw, 2.4rem);
  color:#0f172a;
  line-height:1;
}
.edu-bar{
  width:100%;
  height:4px;
  border-radius: 999px;
  background:#0f172a;
  opacity:.9;
}
.edu-mixed{
  display:inline-flex;
  align-items:center;
  gap:10px;
}
.edu-mixed-int{
  font-family:'Luckiest Guy', cursive;
  font-size: clamp(1.6rem, 8vw, 2.4rem);
  color:#0f172a;
}
.edu-int{
  font-family:'Luckiest Guy', cursive;
  font-size: clamp(1.6rem, 8vw, 2.4rem);
  color:#0f172a;
}

/* Make big buttons fit better on phones */
@media (max-width: 420px){
  .btn-blox{
    padding: 1rem !important;
    border-radius: 1.1rem !important;
    font-size: 1.05rem !important;
  }
  .btn-blox.btn-green.text-xl{
    font-size: 1.05rem !important;
  }
}


/* Fracciones apiladas (móvil friendly) */
.frac-stack{display:inline-grid;grid-template-rows:auto auto auto;align-items:center;justify-items:center;line-height:1;}
.frac-stack .num{font-weight:800;font-size:1.05em;}
.frac-stack .bar{width:100%;height:2px;background:currentColor;border-radius:2px;}
.frac-stack .den{font-weight:800;font-size:1.05em;}
@media (max-width:480px){
  .btn-blox{padding:1rem;font-size:1.05rem;border-radius:1.1rem;}
  .casita-container{font-size:clamp(1.4rem,7vw,2.2rem);}
}


/* ---------- Bitácora Fracciones ---------- */
.edu-notebook details {
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 6px 0 rgba(0,0,0,0.06);
}
.edu-notebook-sum {
  list-style: none;
  cursor: pointer;
  padding: 0.9rem 1rem;
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #334155;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.edu-notebook-sum::-webkit-details-marker { display:none; }
.edu-notebook-body { padding: 0.9rem 1rem; }
.edu-note-block { margin-bottom: 0.9rem; }
.edu-note-title { font-weight: 900; font-size: 0.85rem; color: #0f172a; margin-bottom: 0.25rem; }
.edu-note-text { font-size: 0.85rem; color: #475569; line-height: 1.35; white-space: pre-line; }


/* Manual Pro: cards e iconos llamativos */
.rule-card{
  border-radius: 1.25rem;
  border: 2px solid rgba(226,232,240,.9);
  padding: 1rem;
  background: linear-gradient(180deg, rgba(248,250,252,1) 0%, rgba(255,255,255,1) 100%);
  box-shadow: 0 10px 18px rgba(15,23,42,.06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.rule-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 16px 26px rgba(15,23,42,.10);
  border-color: rgba(203,213,225,1);
}
.rule-head{
  display:flex;
  align-items:center;
  gap:.75rem;
  margin-bottom:.35rem;
}
.rule-title{
  font-family: 'Luckiest Guy', cursive;
  letter-spacing: .5px;
  text-transform: uppercase;
  font-size: 1.05rem;
  line-height: 1.1;
}
.rule-icon{
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  box-shadow: 0 10px 18px rgba(2,6,23,.18);
  transition: transform .22s cubic-bezier(.175,.885,.32,1.275), filter .18s ease;
}
.rule-card:hover .rule-icon{
  transform: rotate(-6deg) scale(1.12);
  filter: brightness(1.05);
}
.rule-icon svg{
  width: 22px;
  height: 22px;
}
.rule-blue{ border-color: rgba(191,219,254,.9); }
.rule-orange{ border-color: rgba(254,215,170,.9); }
.rule-emerald{ border-color: rgba(167,243,208,.9); }
.rule-purple{ border-color: rgba(216,180,254,.9); }
.rule-yellow{ border-color: rgba(253,230,138,.9); }
.rule-red{ border-color: rgba(254,202,202,.9); }


/* =========================
   THEME + SETTINGS (B)
   - Dark refined (colors of buttons stay vivid)
   - Colored cards (amber/indigo/blue...) keep their original Tailwind colors (per user choice)
   ========================= */
:root{
  --app-bg: #f3f4f6;
  --app-surface: #ffffff;
  --app-surface-2: #f8fafc;
  --app-text: #0f172a;
  --app-muted: #64748b;
  --app-border: #e5e7eb;
  --app-shadow: rgba(0,0,0,.10);
  --modal-backdrop: rgba(2,6,23,.45);
}
body{
  background: var(--app-bg);
  color: var(--app-text);
}

/* Dark theme */
.theme-dark{
  --app-bg: #0b1220;
  --app-surface: #0f172a;
  --app-surface-2: #111c33;
  --app-text: #e2e8f0;
  --app-muted: #94a3b8;
  --app-border: #334155;
  --app-shadow: rgba(0,0,0,.45);
  --modal-backdrop: rgba(2,6,23,.72);
}


/* Dark theme readability fixes */
.theme-dark #settings-modal h2,
.theme-dark #settings-modal .settings-row,
.theme-dark #settings-modal .settings-row .text-gray-800,
.theme-dark #settings-modal .settings-row .text-gray-700{
  color: #f8fafc !important;
}
.theme-dark #settings-modal .settings-row .text-gray-500,
.theme-dark #settings-modal .settings-row .text-gray-400{
  color: #cbd5e1 !important;
}
.theme-dark #settings-modal .settings-row i{
  color: #e2e8f0 !important;
}
.theme-dark #settings-modal button[data-action="close-settings"]{
  background: rgba(148,163,184,.12) !important;
}
.theme-dark #settings-modal button[data-action="close-settings"]:hover{
  background: rgba(239,68,68,.15) !important;
}

/* End cards: make math/result text readable in dark mode */
.theme-dark #practice-area .text-gray-900{ color: #f8fafc !important; }
.theme-dark #practice-area .text-gray-800{ color: #f1f5f9 !important; }
.theme-dark #practice-area .text-gray-700{ color: #e2e8f0 !important; }
.theme-dark #practice-area .text-gray-400{ color: #cbd5e1 !important; }

/* Fractions history */
.theme-dark details summary.text-gray-700{ color: #f8fafc !important; }
.theme-dark details .text-gray-400{ color: #cbd5e1 !important; }
.theme-dark details .border-gray-200{ border-color: var(--app-border) !important; }
.theme-dark details .bg-white{ background: var(--app-surface) !important; }

/* Minimal Tailwind overrides (only neutrals) */
.theme-dark .bg-white{ background-color: var(--app-surface) !important; }
.theme-dark .bg-gray-50{ background-color: var(--app-surface-2) !important; }
.theme-dark .bg-gray-100{ background-color: #0b1220 !important; }
.theme-dark .text-gray-800,
.theme-dark .text-gray-900{ color: var(--app-text) !important; }
.theme-dark .text-gray-600,
.theme-dark .text-gray-500,
.theme-dark .text-gray-400{ color: var(--app-muted) !important; }
.theme-dark .border-gray-100,
.theme-dark .border-gray-200{ border-color: var(--app-border) !important; }
.theme-dark .shadow-xl,
.theme-dark .shadow-lg,
.theme-dark .shadow-2xl,
.theme-dark .shadow-md,
.theme-dark .shadow-sm{ box-shadow: 0 12px 30px var(--app-shadow) !important; }

/* Modal */
.modal-backdrop{ background: var(--modal-backdrop); }
.modal-card{
  background: var(--app-surface);
  border: 2px solid var(--app-border);
  box-shadow: 0 18px 40px var(--app-shadow);
}
.settings-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--app-border);
  background: var(--app-surface-2);
}
.switch{
  width: 56px;
  height: 32px;
  border-radius: 999px;
  position: relative;
  border: 2px solid rgba(148,163,184,.6);
  background: #e2e8f0;
  flex: 0 0 auto;
  transition: transform .15s ease, filter .15s ease;
}
.switch::after{
  content:'';
  position:absolute;
  top:50%;
  left:4px;
  width:24px;
  height:24px;
  border-radius:999px;
  transform: translateY(-50%);
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(0,0,0,.2);
  transition: left .18s ease;
}
.switch[data-on="1"]{
  background: #10b981;
  border-color: rgba(16,185,129,.8);
}
.switch[data-on="1"]::after{ left: 26px; }

/* Daily HUD bar */
.hud-bar{
  height: 12px;
  background: rgba(148,163,184,.25);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(148,163,184,.35);
}
.hud-fill{
  height:100%;
  width:0%;
  background: #f97316;
  transition: width .25s ease;
}

/* Motion toggle */
.no-anim *, .no-anim *::before, .no-anim *::after{
  animation: none !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation:none !important; transition:none !important; }
}


/* FIX: readable text in correct-answer card on dark mode */
.theme-dark .correct-answer,
.theme-dark .correct-answer *,
.theme-dark .answer-card.success,
.theme-dark .answer-card.success * {
  color: #0f172a !important; /* almost black */
}


/* FIX: ensure correct-answer text is dark on light success-card even in dark theme */
.theme-dark .correct-answer-card .correct-answer-text {
  color: #0f172a !important;
}


/* --- ANSWER CARD: bigger, equation-like, mobile friendly --- */
.correct-answer-card {
  box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}
.correct-answer-card .correct-answer-text{
  display: block;
  text-align: center;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.15;
  font-size: clamp(1.25rem, 5.4vw, 2.15rem);
  padding: 0.35rem 0.25rem;
  white-space: normal;
  word-break: break-word;
}
/* Make operators pop a bit when present in plain text */
.correct-answer-card .correct-answer-text{
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}
/* Dark theme: the card is light, so force dark text for legibility */
.theme-dark .correct-answer-card .correct-answer-text{
  color: #0f172a !important;
}

/* --- TOP BAR COMPACT --- */
.top-bar, header, .header-bar {
  min-height: 56px !important;
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}
.top-bar .label,
.header-bar .label,
.settings-label {
  display: none !important;
}

/* --- Dark mode result card color --- */
.theme-dark .correct-answer-card{
  background: linear-gradient(135deg,#064e3b,#065f46) !important;
  border-color:#10b981 !important;
}
.theme-dark .correct-answer-card .correct-answer-text{
  color:#ecfeff !important;
}


/* Mini selector buttons */
.btn-mini{
  display:flex; align-items:center; gap:.5rem;
  padding:.65rem 1rem; border-radius:999px;
  font-weight:800; font-size:.8rem;
  border:2px solid rgba(148,163,184,.5);
  background:rgba(255,255,255,.9);
  box-shadow:0 6px 0 rgba(0,0,0,.12);
  transition:transform .12s, filter .2s, background .2s, border-color .2s;
}
.btn-mini:active{ transform:translateY(3px); box-shadow:0 3px 0 rgba(0,0,0,.12); }
.btn-mini.active{ background: #10b981; color:#fff; border-color:#059669; }
.theme-dark .btn-mini{ background:rgba(15,23,42,.7); border-color:rgba(148,163,184,.25); color:#fff; }
.theme-dark .btn-mini.active{ background:#10b981; border-color:#059669; color:#0b1220; }

/* Slide-up animation */
@keyframes slideUp{
  from { opacity:0; transform: translateY(18px) scale(.98); }
  to { opacity:1; transform: translateY(0) scale(1); }
}
.slide-up{ animation: slideUp .28s ease-out both; }

/* Robux pulse */
@keyframes robuxPulse{
  0%{ transform: scale(1); }
  40%{ transform: scale(1.12); }
  100%{ transform: scale(1); }
}
.robux-pulse{ animation: robuxPulse .35s ease-out; }

/* Top bar auto-hide on scroll */
.topbar-hidden{ transform: translateY(-110%); }

/* Dark mode readability improvements */
.theme-dark .muted-on-dark{ color: rgba(255,255,255,.9) !important; }


/* Focus mode */
.focus-mode #top-bar{ display:none !important; }
.focus-mode .floating-actions{ display:none !important; }
.focus-mode .fab-report{ display:none !important; }

/* Debug UI */
.debug-ui .debug-bar{ display:block !important; }

.num-choice{font-size:18px;font-weight:900;letter-spacing:0.5px;}
.frac-choice{display:inline-block;}


/* ===== Ajustes: permitir scroll y cierre en pantallas chicas ===== */
#settings-modal .modal-card{
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== Respuestas en horizontal (móvil: 2 columnas, escritorio: 4) ===== */
.answers-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}
@media (min-width: 900px){
  .answers-grid{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}

/* ===== Operaciones de fracciones centradas y en fila ===== */
.edu-frac-row{
  flex-wrap: nowrap;
  justify-content: center;
}

@media (max-width: 520px){
  .edu-frac-row{ gap: 12px; }
  /* Reduce ligeramente fracciones y operador para que no se apilen */
  .edu-frac-row .frac-frac{ transform: scale(.92); transform-origin: center; }
  .edu-frac-row .edu-frac-op{ font-size: 26px; }
}


/* Tutorial (Fracciones) */
.tut-card{width:100%;display:flex;flex-direction:column;align-items:center;gap:14px}
.tut-msg{font-weight:800;font-size:1.05rem;text-align:center;color:#1f2937}
.tut-choices{width:100%;max-width:520px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:6px}
@media (min-width:640px){.tut-choices{grid-template-columns:repeat(4,minmax(0,1fr))}}
.tut-choice{width:100%!important;min-width:0;font-size:1.35rem!important;padding:0.9rem!important}
.history-list{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:8px;font-size:.8rem;font-weight:700;line-height:1.2}
.hist-icon{display:inline-block;width:1.6rem;text-align:center;opacity:.95}


/* === Tutorial fracciones: tarjeta de respuesta correcta (contraste y fracción en modo oscuro) === */
.correct-answer-card .answer-label { display:block; }

.theme-dark .correct-answer-card,
.theme-dark .correct-answer-card *{
  color: #ecfeff !important;
}

.theme-dark .correct-answer-card .edu-frac{
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(236,254,255,0.22) !important;
}

.theme-dark .correct-answer-card .edu-bar{
  background: rgba(236,254,255,0.9) !important;
  opacity: 0.95;
}
