
/* -------------------------
   Theme Variables
------------------------- */
:root{
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --blue: #0b2a5b;
  --blue2:#123a7a;
  --danger:#b91c1c;
}

/* -------------------------
   Base Layout
------------------------- */
body{
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;

  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

.app-container{
  width: 100%;
  max-width: 920px;
  margin: 28px auto;
  padding: 0 16px;
}

/* Headings */
h1, h2{ margin-top: 0; }
h1{ margin-bottom: 4px; }

/* Utility */
.hidden{ display: none; }

/* -------------------------
   Header
------------------------- */
.app-header{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
  margin-bottom: 14px;
}

.header-left h1{
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.2px;
  color: var(--blue);
}

.subtitle{
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: 14px;
}

.app-logo{
  height: 96px;
  width: auto;
  border-radius: 14px;
  flex-shrink: 0;
}

/* -------------------------
   Cards + Sections
------------------------- */
.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
}

.card-lite{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.card-head h2{
  margin: 0;
  font-size: 18px;
}

.muted{
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: 13px;
}

.divider{
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

/* -------------------------
   Setup UI
------------------------- */
.setup-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.setup-block h3{
  margin: 0 0 10px 0;
  font-size: 14px;
  color: var(--text);
}

.pill-row{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.option-grid{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Radio pills */
.radio-pill{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
}
.radio-pill input{ transform: scale(1.05); }
.radio-pill span{ font-size: 14px; }

/* Checkbox pills */
.check-pill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
}
.check-pill input{ transform: scale(1.05); }

/* Rows + inputs */
.row{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

#numQuestions{
  width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  font-size: 14px;
}

/* -------------------------
   Buttons
------------------------- */
button{
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 14px;
  background: white;
  cursor: pointer;
  margin-top: 0; /* remove global margin-top from your old version */
}

button.primary{
  background: var(--blue);
  border-color: var(--blue);
  color: white;
  font-weight: 700;
}

button.primary:hover{
  background: var(--blue2);
  border-color: var(--blue2);
}

button.ghost{
  background: #f8fafc;
}

button:disabled{
  opacity: 0.55;
  cursor: not-allowed;
}

/* -------------------------
   Progress (Original bar)
------------------------- */
.progress-wrap{
  margin: 12px 0 14px;
}

.progress-label{
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.progress-bar{
  height: 10px;
  background: #e9eef6;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-fill{
  height: 100%;
  width: 0%;
  background: var(--blue);
  border-radius: 999px;
  transition: width 180ms ease;
}

/* -------------------------
   Quiz Prompt + Choices
------------------------- */
.prompt{
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

/* IMPORTANT:
   Your JS should add class="choice" to the clickable labels/buttons.
*/
.choice{
  display: block;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: #ffffff;
}

.choice:hover{
  background-color: #f0f3ff;
  border-color: #4f6cff;
}

/* -------------------------
   Feedback + Errors
------------------------- */
.feedback{
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.error{
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
}

/* -------------------------
   Sentence Builder
------------------------- */
#sentenceUI{
  margin-top: 16px;
}

.sb-label{
  margin: 8px 0 6px 0;
  font-size: 13px;
  color: var(--muted);
}

#wordBank{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 26px;
}

#wordBank .token{
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 16px;
  background: #ffffff;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

#wordBank .token:hover{
  transform: translateY(-1px);
}

#sentenceBar{
  min-height: 64px;
  padding: 14px 16px;
  border: 2px dashed #d6d6d6;
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #fafafa;
}

#sentenceBar .token.placed{
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}

#sentenceBar .token.placed.punct{
  margin-left: -6px;
}

#resetSentenceBtn{
  margin-top: 14px;
}

/* =========================================
   FUN PROGRESS: Runner Road
   ========================================= */
.progress-world{
  display: grid;
  gap: 10px;
  margin: 10px 0 18px;
}

.track{
  position: relative;
  height: 56px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f3f6ff, #e8eeff);
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.06);
}

/* road center line */
.track::after{
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  height: 2px;
  background: repeating-linear-gradient(
    to right,
    rgba(0,0,0,0.18) 0 12px,
    rgba(0,0,0,0.00) 12px 22px
  );
  transform: translateY(-50%);
}

.track-fill{
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(255,215,0,0.35), rgba(0,200,255,0.20));
  transition: width 280ms ease;
}

.checkpoints{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
}

.checkpoint{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.18);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.9);
}

.checkpoint.done{
  background: rgba(0,0,0,0.55);
}

.runner{
  position: absolute;
  top: 50%;
  left: 18px;
  transform: translate(-50%, -50%);
  font-size: 26px;
  transition: left 320ms cubic-bezier(.2,.9,.2,1), transform 320ms cubic-bezier(.2,.9,.2,1);
  will-change: left, transform;
}

.runner.jump{
  transform: translate(-50%, -65%) scale(1.06);
}

.progress-meta{
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mute-btn{
  border: 1px solid rgba(0,0,0,0.12);
  background: white;
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
}

/* =========================================
   Micro-animations: Correct / Wrong / Next / Final
   ========================================= */
.choice.correct{
  animation: pop 260ms ease-out;
  outline: 3px solid rgba(46, 204, 113, 0.45);
}

.choice.wrong{
  animation: shake 360ms ease-in-out;
  outline: 3px solid rgba(231, 76, 60, 0.40);
}

@keyframes pop{
  0%   { transform: scale(1); }
  55%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes shake{
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* Question transitions */
.question-card.enter{
  animation: fadeInUp 240ms ease-out;
}

.question-card.exit{
  animation: fadeOutDown 200ms ease-in forwards;
}

@keyframes fadeInUp{
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOutDown{
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

/* Final score celebration */
.score-card.celebrate{
  animation: glow 900ms ease-in-out;
}

@keyframes glow{
  0%,100% { box-shadow: 0 0 0 rgba(255,215,0,0); }
  40% { box-shadow: 0 0 26px rgba(255,215,0,0.35); }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce){
  .runner, .track-fill, .choice, .question-card, .score-card{
    transition: none !important;
    animation: none !important;
  }
}

.mode-tabs { display:flex; gap:10px; margin: 12px 0 14px; }
.tab { padding:10px 12px; border:1px solid #ccc; border-radius:12px; cursor:pointer; background:#fff; }
.tab.active { font-weight:700; border-width:2px; }

.select { width: 100%; padding: 10px; border-radius: 12px; border: 1px solid #ccc; }

.unit-grid { display:grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap:10px; margin-top:10px; }
.unit-btn { padding: 10px; border-radius: 12px; border: 1px solid #ccc; background: #fff; cursor:pointer; }
.unit-btn.selected { border-width:2px; }

/* =========================================
   Sadlier / Tabs polish (theme-aligned)
   ========================================= */

.mode-tabs{
  display:flex;
  gap:10px;
  margin: 12px 0 14px;
}

.tab{
  padding:10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor:pointer;
  background: #ffffff;
  color: var(--text);
}

.tab:hover{
  border-color: rgba(11, 42, 91, 0.35);
  background: #f8fafc;
}

.tab.active{
  font-weight: 800;
  border-width: 2px;
  border-color: rgba(11, 42, 91, 0.35);
}

.tab-link{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.runner-link{
  color: #b28704;
  border-color: #f5c518;
}

.farmer-link{
  color: #2f7d32;
  border-color: #81c784;
}

/* Select matches your input style */
.select{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  font-size: 14px;
  color: var(--text);
}

/* Units grid */
.unit-grid{
  display:grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap:10px;
  margin-top:10px;
}

.unit-btn{
  padding: 10px 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  cursor:pointer;
  font-weight: 700;
  color: var(--text);
}

.unit-btn:hover{
  background: #f8fafc;
  border-color: rgba(11, 42, 91, 0.35);
}

.unit-btn.selected{
  border-width: 2px;
  border-color: rgba(11, 42, 91, 0.45);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.unit-btn:disabled{
  opacity: 0.45;
  cursor: not-allowed;
  background: #f3f4f6;
}

/* Mobile: fewer columns so buttons are not cramped */
@media (max-width: 540px){
  .unit-grid{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

#sadlierNumQuestions{
  width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  font-size: 14px;

}

/* ================================
   FIX: Tabs not clickable (overlay)
   Put this at the very bottom
================================= */

/* Make sure the tab bar is on top */
.mode-tabs{
  position: relative;
  z-index: 1000;
}

/* Ensure progress world is below */
.progress-world{
  position: relative;
  z-index: 1;
}

/* Extra safety: progress visuals shouldn't intercept clicks */
.track,
.track-fill,
.checkpoints,
.runner,
.track::after{
  pointer-events: none;
}

/* But keep the mute button clickable */
.mute-btn,
#muteBtn{
  pointer-events: auto;
}

#spellAnswer{
  min-height: 54px;
  border: 2px dashed #d6d6d6;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  background: #fafafa;
  display:flex;
  align-items:center;
}

#spellTiles{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top: 8px;
}

.spell-tile{
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 18px;
  background: #fff;
  cursor:pointer;
}

.spell-tile:disabled{
  opacity: 0.45;
  cursor:not-allowed;
}

.spell-actions{
  display:flex;
  gap:10px;
  margin-top: 12px;
}

/* -------------------------
   Login Overlay
------------------------- */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.login-logo {
  height: 112px;
  width: auto;
  border-radius: 14px;
  margin-bottom: 16px;
}

.login-card h2 {
  color: var(--blue);
  margin-bottom: 4px;
}

.login-field {
  width: 100%;
  text-align: left;
  margin-top: 16px;
}

.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--blue);
}

.login-submit {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  font-size: 15px;
}

/* -------------------------
   Student Badge (header)
------------------------- */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.student-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
}

.logout-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.logout-btn:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}


/* ================================
   TICKER BAR
   ================================ */
.ticker-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1a56a0;
  border-top: 2px solid #f5c518;
  color: #f5c518;
  padding: 7px 16px;
  overflow: hidden;
  font-size: 0.88rem;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.25);
}

.ticker-label {
  white-space: nowrap;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  color: #f5c518;
  flex-shrink: 0;
  border-right: 2px solid #f5c51860;
  padding-right: 12px;
}

.ticker-track {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 1.4em;
}

.ticker-inner {
  display: inline-flex;
  gap: 0;
  white-space: nowrap;
  animation: ticker-scroll 30s linear infinite;
  will-change: transform;
}

.ticker-inner:hover {
  animation-play-state: paused;
}

.ticker-item {
  padding: 0 36px;
  font-weight: 700;
  color: #f5c518;
}

.ticker-item::after {
  content: "\2605";
  margin-left: 6px;
}

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}


/* ================================
   100% PERFECT SPLASH
   ================================ */
.perfect-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
}

.perfect-splash.hidden {
  display: none;
}

#fireworksCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.perfect-message {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: perfect-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.perfect-emoji {
  font-size: 5rem;
  animation: perfect-spin 0.6s ease-out 0.1s both;
  display: block;
}

.perfect-title {
  font-size: clamp(3.5rem, 12vw, 7rem);
  font-weight: 900;
  background: linear-gradient(135deg, #ffd700, #ff8c00, #ffd700);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: perfect-shine 1.5s linear infinite;
  margin: 0;
  line-height: 1;
}

.perfect-sub {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  color: #fff;
  font-weight: 700;
  margin: 12px 0 32px 0;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(255,200,0,0.5);
}

.perfect-btn {
  font-size: 1.1rem;
  padding: 12px 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #000;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 180, 0, 0.5);
  transition: transform 0.15s, box-shadow 0.15s;
}

.perfect-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px rgba(255, 180, 0, 0.7);
}

@keyframes perfect-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@keyframes perfect-spin {
  from { transform: rotate(-20deg) scale(0); }
  to   { transform: rotate(0deg)   scale(1); }
}

@keyframes perfect-shine {
  0%   { background-position: 0% center; }
  100% { background-position: 200% center; }
}
