/* ===========================================================
   wordses.com  — learner-facing flash card experience
   Mobile-first, large touch targets, lots of colour & symbols
   so that low-English-literacy users can navigate by sight.
   =========================================================== */

:root {
  --bg:        #f3f6ff;
  --card:      #ffffff;
  --ink:       #1f2540;
  --muted:     #6b7280;
  --brand:     #5b6cff;
  --brand-dk:  #3f4fd6;
  --good:      #18b663;
  --good-dk:   #0f9a52;
  --warn:      #f59e0b;
  --bad:       #ef4444;
  --listen:    #ff3b5c;
  --shadow:    0 10px 30px rgba(31,37,64,.12);
  --shadow-sm: 0 4px 14px rgba(31,37,64,.10);
  --radius:    22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;   /* fit mobile viewport, allowing for browser chrome */
}

.wrap {
  width: 100%;
  max-width: 720px;
  padding: 16px;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar shared on every page after setup ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: 26px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform .12s ease;
}
.home-btn:active { transform: scale(.92); }

.badge-row { display: flex; gap: 10px; align-items: center; }

.pill {
  background: var(--card);
  box-shadow: var(--shadow-sm);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill .star { color: var(--warn); }

/* ---------- generic hero / headings ---------- */
.hero {
  text-align: center;
  margin: 8px 0 22px;
}
.hero .logo {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--brand);
}
.hero .logo span { color: var(--ink); }
.hero p { color: var(--muted); font-size: 16px; margin: 6px 0 0; }

h1, h2 { text-align: center; }

/* ---------- big primary button ---------- */
.big-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border: none;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform .12s ease, background .12s ease;
}
.big-btn:active { transform: scale(.97); }
.big-btn:disabled { background: #c7ccea; cursor: not-allowed; box-shadow: none; }
.big-btn.go { background: var(--good); }

/* ===========================================================
   ENVIRONMENT CHECK PAGE
   =========================================================== */
.center-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}
.spinner {
  width: 56px; height: 56px;
  border: 6px solid #d8def7;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.env-bad .symbol-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 56px;
  flex-wrap: wrap;
}
.env-bad .arrow { font-size: 40px; color: var(--muted); }
.env-bad .x { color: var(--bad); }
.env-bad .ok { color: var(--good); }
.browser-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 160px;
}
.browser-card .b-icon { font-size: 60px; }
.browser-card .b-name { font-size: 26px; font-weight: 800; }
.env-bad .simple-text { font-size: 20px; color: var(--ink); max-width: 420px; }
.env-bad .device { font-size: 46px; }

/* ===========================================================
   SETUP PAGE
   =========================================================== */
.section-label {
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 22px 0 10px;
  text-align: center;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.choice {
  background: var(--card);
  border: 3px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 10px;
  text-align: center;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.choice:active { transform: scale(.97); }
.choice .flag { font-size: 52px; line-height: 1; }
.choice .name { font-weight: 800; font-size: 20px; margin-top: 8px; }
.choice .sub  { color: var(--muted); font-size: 14px; }
.choice.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(91,108,255,.15), var(--shadow-sm);
}

/* CEFR levels */
.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.level {
  background: var(--card);
  border: 3px solid transparent;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 14px 6px;
  text-align: center;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.level:active { transform: scale(.95); }
.level .code { font-size: 24px; font-weight: 800; }
.level .word { font-size: 12px; color: var(--muted); display: block; margin: 4px 0 8px; }
.level .bars { display: flex; gap: 3px; justify-content: center; height: 22px; align-items: flex-end; }
.level .bars i {
  display: block;
  width: 6px;
  border-radius: 3px;
  background: #dfe3f3;
}
.level.selected {
  border-color: var(--good);
  box-shadow: 0 0 0 4px rgba(24,182,99,.15), var(--shadow-sm);
}
.level.selected .bars i.on { background: var(--good); }
.level .bars i.on { background: var(--brand); }

.setup-footer { margin-top: auto; padding-top: 22px; }

/* ===========================================================
   TOPIC GRID
   =========================================================== */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 520px) {
  .topic-grid { grid-template-columns: repeat(3, 1fr); }
}
.topic {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--ink);
  padding: 22px 8px;
  text-align: center;
  transition: transform .12s ease, box-shadow .12s ease;
  border: 3px solid transparent;
}
.topic:active { transform: scale(.95); }
.topic:hover { box-shadow: var(--shadow); }
.topic .t-icon { font-size: 48px; line-height: 1; }
.topic .t-name { font-weight: 800; font-size: 17px; margin-top: 10px; }
.topic.random { background: linear-gradient(135deg,#fff,#eef1ff); border-color: var(--brand); }

/* ===========================================================
   PLAYER  (flash card)
   =========================================================== */
/* player fills the remaining viewport so the card needs no page scrolling */
#player {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.progress {
  height: 8px;
  background: #e2e6f7;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s ease;
}

.flashcard {
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;            /* grow to fill the player so the image can take the slack */
  min-height: 0;
}

.card-question {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 26px;
  font-weight: 800;
}
.icon-btn {
  border: none;
  background: #eef1ff;
  color: var(--brand-dk);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: transform .12s ease, background .12s;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn.playing { background: var(--brand); color:#fff; animation: pulseSoft 1s ease infinite; }

/* Eye icon states: show slash when hidden, show open eye when revealed */
.eye-icon .eye-open { display: none; }
.eye-icon .eye-slash { display: inline; }
.full-answer.revealed .eye-icon .eye-open { display: inline; }
.full-answer.revealed .eye-icon .eye-slash { display: none; }

.card-image-wrap {
  width: 100%;
  flex: 0 1 auto;
  min-height: 120px;
  border-radius: 18px;
  overflow: hidden;
  background: #eef1ff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -8px 0;
}
.card-image-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card-image-wrap .placeholder { font-size: 64px; opacity: .5; }

/* matched short / mid answers appear as green chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 4px; }
.chip {
  background: #e7f8ee;
  color: var(--good-dk);
  border: 2px solid var(--good);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  animation: popIn .35s cubic-bezier(.2,1.3,.5,1);
}
@keyframes popIn { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* the full answer (obfuscated then revealed) */
.full-answer {
  background: #f7f8ff;
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.full-words {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  font-size: 24px;
  font-weight: 800;
  min-width: 0;
}
.word { position: relative; display: inline-flex; }
.word .blocks {
  display: inline-block;
  height: 24px;
  border-radius: 7px;
  background: repeating-linear-gradient(45deg,#cfd5f2,#cfd5f2 7px,#c2c9ef 7px,#c2c9ef 14px);
}
.word .txt { display: none; color: var(--ink); }
.word.shown .blocks { display: none; }
.word.shown .txt { display: inline; }

/* encourage: dance + glow the still-hidden words */
.full-words.encourage .word:not(.shown) .blocks {
  animation: dance .7s ease-in-out infinite;
  background: repeating-linear-gradient(45deg,#ffd27a,#ffd27a 7px,#ffbe4d 7px,#ffbe4d 14px);
  box-shadow: 0 0 10px rgba(245,158,11,.7);
}
@keyframes dance {
  0%,100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-5px) rotate(-4deg); }
  75% { transform: translateY(-2px) rotate(4deg); }
}

.full-answer.revealed { background: #e7f8ee; }
.fa-controls { display: flex; gap: 8px; flex: 0 0 auto; }

/* microphone */
.mic-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}
.mic-hint { color: var(--muted); font-weight: 700; min-height: 22px; text-align:center; }

.mic-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.mic-btn {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

.mic-icon { width: 42px; height: 42px; }
.mic-icon .mic-head   { fill: currentColor; }
.mic-icon .mic-grille { fill: var(--brand-dk); opacity: .55; }
.mic-icon .mic-stand  { stroke: currentColor; }
.mic-btn.listening .mic-icon .mic-grille { fill: #b30021; }
.mic-btn.idle { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe {
  0%,100% { transform: scale(1);   box-shadow: 0 0 0 0 rgba(91,108,255,.45); }
  50%     { transform: scale(1.06); box-shadow: 0 0 0 16px rgba(91,108,255,0); }
}
.mic-btn.listening { background: var(--listen); animation: none; }
.mic-btn .rec-dot {
  position: absolute;
  top: 10px; right: 12px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  display: none;
}
.mic-btn.listening .rec-dot { display: block; animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

@keyframes pulseSoft { 0%,100%{transform:scale(1);} 50%{transform:scale(1.1);} }

.heard {
  font-size: 15px;
  color: var(--muted);
  min-height: 20px;
  text-align: center;
  font-style: italic;
}

.next-btn {
  position: absolute;
  right: 0;
  flex: 0 0 auto;
  width: auto;
  max-width: 110px;
  font-size: 24px;
  padding: 10px 22px;
}

/* ---- compact layout for small / short phone screens ---- */
@media (max-width: 480px) {
  .wrap { padding: 12px; }
  .topbar { margin-bottom: 10px; }
  .home-btn { width: 48px; height: 48px; font-size: 23px; }
  .pill { padding: 7px 13px; font-size: 14px; }
  .flashcard { padding: 13px; gap: 10px; border-radius: 22px; }
  .card-question { font-size: 22px; }
  .full-words { font-size: 21px; }
  .big-btn { font-size: 20px; padding: 15px; }
}
@media (max-height: 720px) {
  .mic-btn { width: 76px; height: 76px; }
  .mic-icon { width: 34px; height: 34px; }
  .card-question { font-size: 21px; }
  .card-image-wrap { min-height: 90px; }
}

/* ===========================================================
   END OF SET
   =========================================================== */
.end-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}
.end-screen .trophy { font-size: 96px; animation: popIn .5s cubic-bezier(.2,1.3,.5,1); }
.end-screen .score-big { font-size: 40px; font-weight: 800; }
.ad-slot {
  width: 100%;
  border: 2px dashed #c7ccea;
  border-radius: var(--radius);
  padding: 28px;
  color: var(--muted);
  font-weight: 700;
}

.hidden { display: none !important; }

/* Share button styles */
.share-btn {
  background: #3b82f6 !important;
  border: none !important;
  color: white !important;
  font-weight: 700 !important;
  padding: 12px 30px !important;
  border-radius: 30px !important;
  cursor: pointer !important;
  font-size: 16px !important;
  transition: transform 0.2s, box-shadow 0.2s !important;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4) !important;
}

.share-btn:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 6px 25px rgba(59, 130, 246, 0.6) !important;
}

.share-btn:active {
  transform: scale(0.95) !important;
}

/* Achievement card preview (optional) */
.achievement-preview {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  margin: 10px 0;
}