/* ===================================================================
   ENGLISH FUN — STYLESHEET
   Design: Playful & Bright for 2nd grade children
=================================================================== */

/* ─── RESET & ROOT VARIABLES ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  overflow-x: hidden;          /* prevent horizontal scroll at root level */
  -webkit-text-size-adjust: 100%; /* prevent iOS font-size boost */
}

:root {
  --font-h: 'Fredoka One', cursive;
  --font-b: 'Nunito', sans-serif;
  --bg: #FFFDF5;
  --text: #2B2B2B;
  --muted: #888;
  --shadow: 0 6px 24px rgba(0,0,0,.10);
  --shadow-hover: 0 12px 36px rgba(0,0,0,.16);
  --radius: 22px;
  --radius-sm: 14px;
  --radius-pill: 99px;
}

/* ─── BODY ─── */
body {
  font-family: var(--font-b);
  background: var(--bg);
  min-height: 100vh;
  /* NOTE: no position:relative + overflow-x:hidden here — that combo
     kills momentum scroll on iOS Safari. overflow-x is on html instead. */
}

/* Polka-dot background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 15%, rgba(255,210,50,.18) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(100,195,255,.18) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(255,140,200,.10) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ─── APP CONTAINER ─── */
#app {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 16px 60px;   /* extra bottom padding so last card isn't cut off */
}

/* ================================================================
   HOME SCREEN
================================================================ */
.home-head {
  text-align: center;
  padding: 24px 0 32px;
}

.mascot {
  font-size: 4.5rem;
  display: block;
  animation: float 3.5s ease-in-out infinite;
  margin-bottom: 6px;
}

.app-title {
  font-family: var(--font-h);
  font-size: clamp(2rem, 8vw, 3.6rem);
  color: #FF5722;
  text-shadow: 3px 4px 0 rgba(255,87,34,.18);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.app-tagline {
  font-size: clamp(.95rem, 3.5vw, 1.25rem);
  color: var(--muted);
  font-weight: 800;
}

/* Progress summary badge */
.home-progress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  border-radius: var(--radius-pill);
  padding: 6px 18px;
  font-size: .95rem;
  font-weight: 800;
  color: var(--text);
  box-shadow: var(--shadow);
  margin-top: 12px;
}

/* ─── CATEGORY GRID ─── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 560px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
}

.cat-card {
  border-radius: var(--radius);
  padding: 22px 14px 18px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cat-card:hover   { transform: translateY(-5px) scale(1.02); box-shadow: var(--shadow-hover); }
.cat-card:active  { transform: scale(.96); }

.cat-card.completed { border-width: 3px; }

.cat-ico   { font-size: 3rem; display: block; margin-bottom: 8px; }
.cat-name  { font-family: var(--font-h); font-size: 1.1rem; color: var(--text); margin-bottom: 3px; }
.cat-sub   { font-size: .78rem; color: var(--muted); font-weight: 700; }
.cat-stars { margin-top: 10px; font-size: 1.3rem; letter-spacing: 2px; }

/* Bottom progress stripe */
.cat-bar {
  position: absolute;
  bottom: 0; left: 0;
  height: 5px;
  border-radius: 0;
  transition: width .6s cubic-bezier(.34,1.56,.64,1);
}

/* "Jogar" pill */
.cat-play {
  display: inline-block;
  margin-top: 12px;
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  color: white;
  font-family: var(--font-h);
  font-size: .95rem;
  letter-spacing: .5px;
  border: none;
  cursor: pointer;
  transition: transform .15s;
}
.cat-play:hover  { transform: scale(1.07); }
.cat-play:active { transform: scale(.96); }

/* ================================================================
   EXERCISE PAGE — HEADER
================================================================ */
.ex-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 2.5px dashed #e9e4d4;
}

.btn-back {
  flex-shrink: 0;
  background: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.1);
  transition: transform .15s;
  line-height: 1;
}
.btn-back:hover  { transform: scale(1.07); }
.btn-back:active { transform: scale(.93); }

.ex-hinfo { flex: 1; min-width: 0; }

.ex-htitle {
  font-family: var(--font-h);
  font-size: clamp(.9rem, 3.5vw, 1.1rem);
  color: var(--text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prog-wrap {
  background: #EEE;
  border-radius: var(--radius-pill);
  height: 11px;
  overflow: hidden;
}

.prog-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width .4s ease;
}

.ex-hcount {
  flex-shrink: 0;
  font-family: var(--font-h);
  font-size: 1.15rem;
}

/* ─── EXERCISE CARD ─── */
.ex-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  box-shadow: var(--shadow);
}

.ex-instr {
  font-size: clamp(.95rem, 3.2vw, 1.05rem);
  font-weight: 800;
  color: #666;
  margin-bottom: 18px;
  text-align: center;
}

/* ================================================================
   QUIZ EXERCISE
================================================================ */
.quiz-q-wrap {
  text-align: center;
  margin-bottom: 22px;
}

.quiz-q-text {
  font-family: var(--font-h);
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  color: var(--text);
  margin-bottom: 4px;
}

.quiz-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.q-opt {
  flex: 1;
  background: #F7F5EE;
  border: 3px solid #E5DFD0;
  border-radius: var(--radius-sm);
  padding: 15px 10px;
  font-family: var(--font-b);
  font-size: clamp(.9rem, 3.5vw, 1.15rem);
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
  min-height: 56px;
  touch-action: manipulation;   /* prevents 300ms tap delay on mobile */
  -webkit-tap-highlight-color: transparent;
}

.q-opt:hover:not(.disabled) {
  transform: scale(1.03);
  border-color: #BDBDBD;
  background: white;
}
.q-opt:active:not(.disabled) { transform: scale(.96); }

.q-opt.opt-ok {
  background: #D4EDDA;
  border-color: #28A745;
  color: #155724;
  animation: bounce-in .35s;
}
.q-opt.opt-bad {
  background: #F8D7DA;
  border-color: #DC3545;
  color: #721C24;
  animation: shake .4s;
}
.q-opt.opt-reveal {
  background: #D4EDDA;
  border-color: #28A745;
  color: #155724;
}
.q-opt.disabled { cursor: not-allowed; }

/* ─── Speak button (small) ─── */
.spk {
  flex-shrink: 0;
  background: none;
  border: 2px solid #E5DFD0;
  border-radius: var(--radius-pill);
  padding: 6px 9px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
  line-height: 1;
}
.spk:hover  { transform: scale(1.15); border-color: #bbb; }
.spk:active { transform: scale(.9); }

/* Big speak button (on question) */
.spk-big {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 4px;
  transition: transform .2s;
}
.spk-big:hover { transform: scale(1.2); }

/* ================================================================
   MATCH EXERCISE
================================================================ */
.match-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.match-col { display: flex; flex-direction: column; gap: 8px; }

.match-item {
  background: #F7F5EE;
  border: 3px solid #E5DFD0;
  border-radius: var(--radius-sm);
  padding: 13px 10px;
  font-family: var(--font-b);
  font-size: clamp(.85rem, 3vw, 1rem);
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
  color: var(--text);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 54px;
  line-height: 1.3;
  width: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.match-item:hover:not([disabled]):not(.match-done) {
  transform: scale(1.04);
  border-color: #BDBDBD;
  background: white;
}

.match-item.match-sel {
  border-color: #4D96FF;
  background: #EAF3FF;
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(77,150,255,.25);
}

.match-item.match-done {
  background: #D4EDDA;
  border-color: #28A745;
  color: #155724;
  cursor: default;
  opacity: .85;
}

.match-item.match-bad {
  background: #F8D7DA;
  border-color: #DC3545;
  animation: shake .4s;
}

.match-emoji { font-size: clamp(1.5rem, 5vw, 2rem); }

/* ================================================================
   FILL-IN-THE-BLANK EXERCISE
================================================================ */
.fill-sent-wrap {
  font-family: var(--font-h);
  font-size: clamp(1.1rem, 4.5vw, 1.55rem);
  color: var(--text);
  line-height: 2.2;
  text-align: center;
  margin-bottom: 22px;
}

.fill-blank {
  display: inline-block;
  min-width: 90px;
  border-bottom: 3.5px solid #4D96FF;
  background: #EAF3FF;
  color: #1A5FBF;
  padding: 3px 14px;
  border-radius: 10px;
  font-weight: 900;
  vertical-align: middle;
  transition: background .3s, border-color .3s, color .3s;
}
.fill-blank.empty   { color: transparent; }
.fill-blank.blank-ok  { background: #D4EDDA; border-color: #28A745; color: #155724; }
.fill-blank.blank-bad { background: #F8D7DA; border-color: #DC3545; color: #721C24; animation: shake .4s; }

.fill-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.fill-opt {
  background: white;
  border: 3px solid #DDD;
  border-radius: var(--radius-pill);
  padding: 11px 22px;
  font-family: var(--font-b);
  font-size: clamp(.95rem, 3.5vw, 1.15rem);
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
  color: var(--text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.fill-opt:hover:not(.disabled) {
  transform: scale(1.06);
  border-color: #4D96FF;
  background: #EAF3FF;
}
.fill-opt:active:not(.disabled) { transform: scale(.95); }
.fill-opt.disabled { cursor: not-allowed; opacity: .6; }
.fill-opt.opt-reveal {
  background: #D4EDDA;
  border-color: #28A745;
  color: #155724;
}

/* ================================================================
   FEEDBACK & NAVIGATION BUTTONS
================================================================ */
.feedback {
  margin-top: 16px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-h);
  font-size: clamp(1rem, 4vw, 1.3rem);
  text-align: center;
  animation: slide-up .3s;
}
.fb-ok  { background: #D4EDDA; color: #155724; }
.fb-bad { background: #F8D7DA; color: #721C24; }

.btn-next {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: linear-gradient(135deg, #4D96FF, #2979FF);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 17px;
  font-family: var(--font-h);
  font-size: clamp(1rem, 4vw, 1.25rem);
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(77,150,255,.4);
  transition: transform .15s, box-shadow .15s;
  animation: slide-up .3s;
  letter-spacing: .5px;
}
.btn-next:hover  { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(77,150,255,.5); }
.btn-next:active { transform: scale(.98); }

.match-fb {
  min-height: 24px;
  margin-top: 14px;
}

/* ================================================================
   COMPLETE / RESULTS SCREEN
================================================================ */
.complete-screen {
  text-align: center;
  padding: 40px 20px;
  animation: bounce-in .5s;
}

.complete-mascot { font-size: 6rem; display: block; margin-bottom: 12px; }

.complete-title {
  font-family: var(--font-h);
  font-size: clamp(2rem, 7vw, 3rem);
  color: var(--text);
  margin-bottom: 6px;
}

.complete-sub {
  font-size: clamp(1rem, 4vw, 1.3rem);
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 24px;
}

.stars-row {
  font-size: 3.5rem;
  letter-spacing: 10px;
  margin-bottom: 24px;
  display: block;
  min-height: 60px;
}

.star-pop {
  display: inline-block;
  opacity: 0;
  animation: star-pop .5s cubic-bezier(.34,1.56,.64,1) forwards;
}

.score-box {
  background: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 800;
  color: var(--text);
}

.score-num {
  font-family: var(--font-h);
  font-size: 2rem;
  color: #4D96FF;
}

.complete-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-retry {
  background: linear-gradient(135deg, #6BCB77, #43A855);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 28px;
  font-family: var(--font-h);
  font-size: clamp(1rem, 4vw, 1.2rem);
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(107,203,119,.4);
  transition: transform .15s;
}
.btn-retry:hover  { transform: translateY(-2px); }
.btn-retry:active { transform: scale(.97); }

.btn-home-big {
  background: linear-gradient(135deg, #FF6B35, #FF9A3C);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 28px;
  font-family: var(--font-h);
  font-size: clamp(1rem, 4vw, 1.2rem);
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(255,107,53,.4);
  transition: transform .15s;
}
.btn-home-big:hover  { transform: translateY(-2px); }
.btn-home-big:active { transform: scale(.97); }

/* ================================================================
   CONFETTI
================================================================ */
#confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
  touch-action: none;         /* belt-and-braces: don't consume any touch events */
}

.conf-piece {
  position: absolute;
  top: -20px;
  animation: conf-fall linear forwards;
  border-radius: 2px;
}

/* ================================================================
   UTILITY
================================================================ */
.hidden { display: none !important; }
.mt-1  { margin-top: 12px; }

/* ================================================================
   ANIMATIONS
================================================================ */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}

@keyframes bounce-in {
  0%   { transform: scale(.5); opacity: 0; }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

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

@keyframes slide-up {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes star-pop {
  0%   { transform: scale(0) rotate(-200deg); opacity: 0; }
  60%  { transform: scale(1.4) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg);    opacity: 1; }
}

@keyframes conf-fall {
  from { transform: translateY(-30px) rotate(0deg); opacity: 1; }
  to   { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ================================================================
   RESPONSIVE TWEAKS
================================================================ */
@media (max-width: 380px) {
  .quiz-opts { grid-template-columns: 1fr; }
  .match-area { grid-template-columns: 1fr; }
  .match-col:first-child::after {
    content: '↕';
    display: block;
    text-align: center;
    font-size: 1.5rem;
    margin: 4px 0;
    color: var(--muted);
  }
}