*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* ===========================
     Backgrounds
     =========================== */

  --cover: #eef4ff;
  --cover-edge: #eef4ff;

  --paper: #ffffff;
  --paper-alt: #f4f8ff;

  /* ===========================
     Text
     =========================== */

  --ink: #14203a;
  --ink-soft: #6d7a92;
  --ink-faint: #a5b0c4;
  --on-ink: #ffffff;

  /* ===========================
     Primary (Deep Modern Blue)
     =========================== */

  --red: #3762e0;
  --red-dark: #2547ba;
  --red-soft: #e7edfd;

  /* ===========================
     Secondary (Teal — learning/progress)
     =========================== */

  --blue: #14b8ab;
  --blue-dark: #0e9186;
  --blue-soft: #e0f7f4;

  /* ===========================
     Success (Fresh Green — success only)
     =========================== */

  --green: #4cc26b;
  --green-dark: #369c52;
  --green-mid: #6fd489;
  --green-soft: #e6f8ea;

  /* ===========================
     Accent (Warm Orange/Coral)
     =========================== */

  --gold: #ff9d42;
  --gold-dark: #e57e1f;
  --gold-soft: #fff0dc;

  /* ===========================
     Borders
     =========================== */

  --border: #e6ebf5;
  --border-strong: #d3dcee;

  /* ===========================
     Shadows
     =========================== */

  --shadow-sm: 0 2px 0 rgba(20, 32, 58, 0.05);
  --shadow-md: 0 10px 24px rgba(20, 32, 58, 0.08);
  --shadow-lg: 0 18px 40px rgba(20, 32, 58, 0.1);

  /* ===========================
     Radius
     =========================== */

  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 26px;
  --radius-pill: 999px;

  /* ===========================
     Motion
     =========================== */

  --lip: 4px;
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);

  /* ===========================
     Fonts
     =========================== */

  --font-display: "Baloo 2", "Fredoka", cursive;
  --font-body: "Nunito", "Inter", sans-serif;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--cover);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;
  color: var(--ink);
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  background-repeat: no-repeat;
}

body::before {
  top: -60px;
  left: -60px;
  width: 260px;
  height: 260px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cpath fill='%23dbe6ff' d='M45,-58C59,-49,71,-35,75,-19C79,-3,75,15,66,30C57,45,43,57,26,64C9,71,-11,73,-29,67C-47,61,-63,47,-71,29C-79,11,-79,-11,-71,-29C-63,-47,-47,-61,-29,-68C-11,-75,9,-75,26,-70C43,-65,31,-67,45,-58Z' transform='translate(100 100)'/%3E%3C/svg%3E");
  background-size: contain;
}

body::after {
  bottom: -80px;
  right: -80px;
  width: 320px;
  height: 320px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cpath fill='%23dcf5ef' d='M39,-51C50,-44,58,-31,63,-16C68,-1,70,17,63,32C56,47,41,59,24,66C7,73,-12,75,-29,69C-46,63,-61,49,-69,32C-77,15,-78,-5,-72,-22C-66,-39,-53,-53,-38,-60C-23,-67,-6,-67,10,-64C26,-61,28,-58,39,-51Z' transform='translate(100 100)'/%3E%3C/svg%3E");
  background-size: contain;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   Shared motion vocabulary
   ========================================================================== */

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pop-scale {
  0% {
    transform: scale(0);
  }
  70% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes slide-in-left {
  0% {
    opacity: 0;
    transform: translateX(-14px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slide-in-right {
  0% {
    opacity: 0;
    transform: translateX(14px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  15%,
  55% {
    transform: translateX(-6px);
  }
  35%,
  75% {
    transform: translateX(6px);
  }
  90% {
    transform: translateX(-2px);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Screens fade+rise on every entrance, so navigation always feels directional. */
.screen {
  animation: pop-in 0.4s var(--ease-smooth) both;
  position: relative;
  z-index: 1;
}

/* Children carrying `--i` cascade in one after another. */
[style*="--i"] {
  animation: pop-in 0.5s var(--ease-smooth) both;
  animation-delay: calc(var(--i) * 70ms);
}

/* ==========================================================================
   Shell / container
   ========================================================================== */

.container {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 1040px;
  padding: 40px 44px 44px;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

@media (max-width: 600px) {
  /* Top-left decoration */
  .container::before {
    content: "";
    position: absolute;
    top: -40px;
    left: -40px;
    width: 130px;
    height: 130px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cpath fill='%23eef3ff' d='M45,-58C59,-49,71,-35,75,-19C79,-3,75,15,66,30C57,45,43,57,26,64C9,71,-11,73,-29,67C-47,61,-63,47,-71,29C-79,11,-79,-11,-71,-29C-63,-47,-47,-61,-29,-68C-11,-75,9,-75,26,-70C43,-65,31,-67,45,-58Z' transform='translate(100 100)'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
  }

  /* Bottom-right decoration */
  .container::after {
    content: "";
    position: absolute;
    bottom: -40px;
    right: -40px;
    width: 130px;
    height: 130px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cpath fill='%23edf9f6' d='M39,-51C50,-44,58,-31,63,-16C68,-1,70,17,63,32C56,47,41,59,24,66C7,73,-12,75,-29,69C-46,63,-61,49,-69,32C-77,15,-78,-5,-72,-22C-66,-39,-53,-53,-38,-60C-23,-67,-6,-67,10,-64C26,-61,28,-58,39,-51Z' transform='translate(100 100)'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
  }
}
.active-session {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
}

.active-session-main {
  flex: 1;
  min-width: 0;
}

/* ==========================================================================
   Header
   ========================================================================== */

header {
  text-align: center;
  margin-bottom: 32px;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--border);
  position: relative;
}

header h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
  animation: pop-in 0.6s var(--ease-smooth) both;
}

.subtitle {
  color: var(--ink-soft);
  font-size: 1.02rem;
  font-weight: 700;
}

/* ==========================================================================
   Timer
   ========================================================================== */

.timer-container {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.timer {
  display: inline-block;
  background: var(--ink);
  color: var(--on-ink);
  border-radius: var(--radius-pill);
  font-size: 1.02rem;
  padding: 9px 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Screen titles / shared
   ========================================================================== */

.screen-title {
  font-family: var(--font-display);
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 22px;
  text-align: center;
}

.back-button {
  background: none;
  border: none;
  color: var(--blue-dark);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 12px;
  font-family: inherit;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s var(--ease-smooth);
}

.back-button:hover,
.back-button:focus-visible {
  color: var(--red);
}

.back-arrow {
  display: inline-block;
  font-size: 1.1rem;
  transition: transform 0.2s var(--ease-pop);
}

.back-button:hover .back-arrow {
  transform: translateX(-4px);
}

/* ==========================================================================
   Sections screen (Starters / Movers)
   ========================================================================== */

.sections-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

/* Flat, chunky, pressable learning card — thick bottom edge, no gradients. */
.section-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  background: var(--paper-alt);
  border: 2px solid var(--border-strong);
  border-bottom: 5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 24px 22px 20px;
  cursor: pointer;
  transition:
    transform 0.1s ease,
    border-color 0.15s var(--ease-smooth),
    box-shadow 0.15s var(--ease-smooth);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.section-card:hover,
.section-card:focus-visible {
  box-shadow: var(--shadow-sm);
}

.section-card:active {
  transform: translateY(3px);
  border-bottom-width: 2px;
  margin-bottom: 3px;
}

#starters-section-btn {
  border-color: var(--green-mid);
  background: var(--green-soft);
}

#starters-section-btn:hover,
#starters-section-btn:focus-visible {
  border-color: var(--green-dark);
}

#movers-section-btn {
  border-color: #9db8f2;
  background: var(--red-soft);
}

#movers-section-btn:hover,
#movers-section-btn:focus-visible {
  border-color: var(--red);
}

/* Decorative flat SVG blob tucked in the corner of each section card. */
.section-card::after {
  content: "";
  position: absolute;
  bottom: -22px;
  right: -22px;
  width: 90px;
  height: 90px;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.6;
  pointer-events: none;
}

#starters-section-btn::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cpath fill='%23bfe9cd' d='M45,-58C59,-49,71,-35,75,-19C79,-3,75,15,66,30C57,45,43,57,26,64C9,71,-11,73,-29,67C-47,61,-63,47,-71,29C-79,11,-79,-11,-71,-29C-63,-47,-47,-61,-29,-68C-11,-75,9,-75,26,-70C43,-65,31,-67,45,-58Z' transform='translate(100 100)'/%3E%3C/svg%3E");
}

#movers-section-btn::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cpath fill='%23c6d6fb' d='M39,-51C50,-44,58,-31,63,-16C68,-1,70,17,63,32C56,47,41,59,24,66C7,73,-12,75,-29,69C-46,63,-61,49,-69,32C-77,15,-78,-5,-72,-22C-66,-39,-53,-53,-38,-60C-23,-67,-6,-67,10,-64C26,-61,28,-58,39,-51Z' transform='translate(100 100)'/%3E%3C/svg%3E");
}

.section-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  position: relative;
  z-index: 1;
}

.section-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.section-card-icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}

/* The one bit of playful idle motion — icons bob while a card is hovered. */
.section-card:hover .section-card-icon,
.section-card:focus-visible .section-card-icon {
  animation: bob 0.9s ease-in-out infinite;
}

.section-card-badge {
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--paper);
  border: 2px solid var(--border);
  color: var(--ink-faint);
}

#starters-section-btn .section-card-badge {
  background: var(--paper);
  border-color: var(--green-mid);
  color: var(--green-dark);
}

#movers-section-btn .section-card-badge {
  background: var(--paper);
  border-color: #9db8f2;
  color: var(--red);
}

.section-card-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  position: relative;
  z-index: 1;
}

.section-card-description {
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.55;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Translate widget (main page)
   ========================================================================== */

.translate-widget {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 2px solid var(--border);
  text-align: center;
}

.translate-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--blue);
  color: var(--on-ink);
  border: none;
  border-bottom: var(--lip) solid var(--blue-dark);
  padding: 13px 28px;
  font-size: 0.95rem;
  font-weight: 800;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  min-height: 50px;
  transition:
    transform 0.1s ease,
    filter 0.15s;
}

.translate-btn:hover,
.translate-btn:focus-visible {
  filter: brightness(1.05);
}

.translate-btn:active {
  transform: translateY(var(--lip));
  border-bottom-width: 0;
  margin-bottom: var(--lip);
}

.translate-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.translate-btn-icon img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

/* Recording: turn coral and pulse. */
.translate-btn.active {
  background: var(--gold);
  border-bottom-color: var(--gold-dark);
  animation: rec-glow 1.6s ease-in-out infinite;
}

.translate-btn.active .translate-btn-icon {
  animation: bob 0.8s ease-in-out infinite;
}

@keyframes rec-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(229, 126, 31, 0.35);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(229, 126, 31, 0);
  }
}

.translate-btn:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
  animation: none;
}

.translate-entry-actions {
  margin-top: 10px;
}

.translate-hear-btn {
  padding: 6px 14px;
  font-size: 0.78rem;
  min-height: 34px;
}

.translate-hear-btn-pulse {
  border-color: var(--blue) !important;
  color: var(--blue-dark) !important;
  animation: hear-pulse 1.2s ease-in-out 3;
}

@keyframes hear-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(20, 184, 171, 0.32);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(20, 184, 171, 0);
  }
}

.translate-hint {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.4;
  font-weight: 600;
}

.translate-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 16px;
  background: var(--blue-soft);
  border: 2px solid #bfe9e3;
  border-radius: var(--radius-pill);
  margin: 14px auto 0;
  max-width: 480px;
  min-height: 32px;
  color: var(--blue-dark);
  font-weight: 800;
  font-size: 0.78rem;
  animation: pop-in 0.28s var(--ease-pop) both;
}

.translate-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 14px;
  text-align: left;
}

.translate-entry {
  background: var(--paper-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  animation: pop-in 0.35s var(--ease-smooth) both;
}

.translate-entry-user {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 6px;
}

.translate-entry-english {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 6px;
}

.translate-entry-result {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--ink);
}

.translate-entry-result .bilingual-line {
  margin-bottom: 0.25em;
}

.translate-entry-result .spanish-text {
  font-weight: 700;
  line-height: 1.3;
  color: var(--red);
}

.translate-entry-result .gloss {
  font-family: var(--font-body);
  font-size: 0.82em;
  font-style: italic;
  color: var(--ink-soft);
}

.translate-entry-notes {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ==========================================================================
   Scenarios screen
   ========================================================================== */

.scenarios-status {
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 20px;
  font-weight: 700;
}

.scenarios-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.scenario-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  background: var(--paper-alt);
  border: 2px solid var(--border-strong);
  border-bottom: 5px solid var(--border-strong);
  border-left: 5px solid var(--blue);
  border-radius: var(--radius-sm);
  padding: 17px 19px 13px;
  cursor: pointer;
  transition:
    transform 0.1s ease,
    border-color 0.15s var(--ease-smooth);
  font-family: inherit;
  /* Cards are appended by JS, so stagger them as they arrive. */
  animation: pop-in 0.4s var(--ease-smooth) both;
}

.scenario-card:hover,
.scenario-card:focus-visible {
  border-left-color: var(--red);
}

.scenario-card:active {
  transform: translateY(3px);
  border-bottom-width: 2px;
  margin-bottom: 3px;
}

.scenario-card-title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--ink);
}

.scenario-card-setting {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.45;
  font-weight: 600;
}
.scenario-card-meta {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink);
  opacity: 0.72;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.start-button {
  background: var(--red);
  color: var(--on-ink);
  border: none;
  border-bottom: var(--lip) solid var(--red-dark);
  padding: 16px 38px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    transform 0.1s ease,
    filter 0.15s;
  font-weight: 800;
  min-height: 52px;
  font-family: inherit;
}

.start-button:hover {
  filter: brightness(1.05);
}

.start-button:active {
  transform: translateY(var(--lip));
  border-bottom-width: 0;
  margin-bottom: var(--lip);
}

.start-button:disabled {
  background: var(--border-strong);
  border-bottom-color: var(--border);
  color: var(--ink-faint);
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.secondary-button {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--border-strong);
  border-bottom-width: var(--lip);
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  min-height: 42px;
  transition:
    transform 0.1s ease,
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}

.secondary-button:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
}

.secondary-button:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
  margin-bottom: 2px;
}

.secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#vocab-continue-btn {
  display: block;
  margin: 24px auto 0;
}

/* ==========================================================================
   Vocabulary practice screen
   ========================================================================== */

.vocab-scenario-label {
  color: var(--blue-dark);
  font-weight: 800;
  margin-bottom: 8px;
  text-align: center;
}

.vocab-instructions {
  color: var(--ink-soft);
  margin-bottom: 18px;
  line-height: 1.45;
  text-align: center;
  font-weight: 600;
}

/* -- progress bar -- */

.vocab-progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.progress-track {
  flex: 1;
  height: 16px;
  background: var(--paper-alt);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--green);
  border-radius: var(--radius-pill);
  position: relative;
  transition: width 0.6s var(--ease-smooth);
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 2px 6px auto 6px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.4);
}

.vocab-progress {
  color: var(--ink);
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* -- current word card, flashcard style -- */

.vocab-current-card {
  background: var(--paper-alt);
  border: 2px solid var(--border-strong);
  border-bottom: 6px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 24px 30px;
  margin-bottom: 22px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition:
    border-color 0.25s var(--ease-smooth),
    background 0.25s var(--ease-smooth);
}

/* Flat SVG star scatter behind the flashcard word. */
.vocab-current-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e2ebfa' d='M12 0l2.6 8.1H23l-6.9 5 2.6 8.1L12 16.2 5.3 21.2l2.6-8.1L1 8.1h8.4z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23dff2ee' d='M12 0l2.6 8.1H23l-6.9 5 2.6 8.1L12 16.2 5.3 21.2l2.6-8.1L1 8.1h8.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position:
    6% 18%,
    92% 78%;
  background-size: 26px, 20px;
  opacity: 0.8;
  pointer-events: none;
}

.vocab-current-card.correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.vocab-current-card.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  animation: shake 0.45s ease-in-out;
}

/* Tick that pops in when a pronunciation is accepted. */
.vocab-check {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: var(--on-ink);
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0);
  z-index: 1;
}

.vocab-check.show {
  animation: pop-scale 0.45s var(--ease-pop) forwards;
}

.vocab-word {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 800;
  font-optical-sizing: auto;
  color: var(--ink);
  margin-bottom: 10px;
  line-height: 1.25;
  letter-spacing: 0.005em;
  unicode-bidi: isolate;
  animation: pop-in 0.4s var(--ease-smooth) both;
  position: relative;
  z-index: 1;
}

.vocab-meaning {
  font-family: var(--font-body);
  color: var(--ink-soft);
  font-size: 1.15rem;
  margin-bottom: 18px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.vocab-status {
  min-height: 1.4em;
  margin-bottom: 10px;
  color: var(--blue-dark);
  font-weight: 800;
  font-size: 0.95rem;
  position: relative;
  z-index: 1;
}

.vocab-feedback {
  min-height: 1.4em;
  margin-bottom: 16px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  position: relative;
  z-index: 1;
}

.vocab-feedback.success {
  color: var(--green-dark);
  font-weight: 800;
  animation: pop-in 0.3s var(--ease-pop) both;
}

.vocab-feedback.retry {
  color: var(--red);
  animation: pop-in 0.3s var(--ease-pop) both;
}

.vocab-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

#vocab-hear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
#vocab-hear-btn .hear-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  transform: translateY(-3px);
}
/* -- word chips -- */

.vocab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 26px;
}

.vocab-chip {
  border: 2px solid var(--border-strong);
  border-bottom-width: 4px;
  background: var(--paper);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 1rem;
  font-family: var(--font-display);
  cursor: pointer;
  color: var(--ink);
  line-height: 1.3;
  min-height: 40px;
  transition:
    border-color 0.15s var(--ease-smooth),
    color 0.15s,
    background 0.15s,
    transform 0.1s ease;
}

.vocab-chip:hover {
  border-color: var(--blue);
}

.vocab-chip:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.vocab-chip.active {
  border-color: var(--blue-dark);
  color: var(--on-ink);
  font-weight: 800;
  background: var(--blue);
}

.vocab-chip.done {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
}

/* Chips pop as they flip to done. */
.vocab-chip.just-done {
  animation: pop-scale 0.4s var(--ease-pop);
}

/* ==========================================================================
   Confetti (vocab success + session complete)
   ========================================================================== */

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall 1.5s ease-in forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(var(--fall, 280px)) rotate(var(--spin, 540deg));
  }
}

/* ==========================================================================
   Conversation screen
   ========================================================================== */
/* Conversation */
.conversation-screen {
  position: relative;
  width: 100%;
}
.active-session {
  display: block;
  width: 100%;
  margin-bottom: 0;
}
.active-session-main {
  position: relative;
  width: 100%;
  min-width: 0;
}
.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  margin-bottom: 3px;
}
.active-session-main > .back-button {
  display: inline-flex;
  align-items: center;
  margin: 0 0 4px;
  padding: 5px 0;
  min-height: 28px;
  font-size: 0.82rem;
} /* Image */
.pair-animation-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 16 / 10;
  height: auto;
  margin: 4px auto 16px;
  padding: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--paper-alt) 0%, var(--paper) 100%);
  border: 2px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
}

.pair-animation {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 10px 20px rgba(20, 32, 58, 0.1));
}

/* Suggested phrase — sits below the conversation section */
.hint-panel {
  width: 100%;
  min-width: 0;
  margin: 10px 0 8px;
  padding: 7px 10px;
  background: var(--blue-soft);
  border: 1px solid #bfe9e3;
  border-left: 3px solid var(--blue);
  border-radius: 11px;
  box-shadow: none;
}
.hint-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}
.hint-header {
  margin: 0;
  font-size: 0.58rem;
  line-height: 1.2;
  letter-spacing: 0.06em;
  color: var(--blue-dark);
}
.hint-toggle-btn {
  flex-shrink: 0;
  min-height: 0;
  padding: 1px 6px;
  background: var(--paper);
  border: 1px solid var(--blue);
  border-radius: 7px;
  color: var(--blue);
  font-family: inherit;
  font-size: 0.56rem;
  font-weight: 800;
  line-height: 1.4;
  cursor: pointer;
}
.hint-toggle-btn:hover,
.hint-toggle-btn:focus-visible {
  background: var(--blue);
  color: var(--on-ink);
}
#hint-text {
  margin: 0;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: pre-wrap;
}
#hint-text .bilingual-line {
  margin-bottom: 0.15em;
}
#hint-text .bilingual-line:last-child {
  margin-bottom: 0;
}
#hint-text .spanish-text {
  display: block;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
}
#hint-text .gloss {
  display: block;
  margin-top: 1px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-style: italic;
  line-height: 1.1;
} /* Conversation */
.conversation-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 175px;
  margin: 0 0 8px;
  padding: 10px 11px;
  background: var(--paper);
  border: 2px solid var(--border-strong);
  border-radius: 14px;
}
.conversation-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  margin: 0 0 5px;
}
.conversation-container .panel-label {
  margin: 0;
  font-size: 0.58rem;
  line-height: 1.2;
  letter-spacing: 0.07em;
}
.session-progress {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  opacity: 0.75;
  white-space: nowrap;
}
.conversation-history {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
  padding-right: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.message {
  max-width: 75%;
  padding: 7px 10px;
  border-radius: 13px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.22;
  word-break: normal;
  overflow-wrap: anywhere;
  border: 2px solid transparent;
}
.message .bilingual-line {
  margin-bottom: 0.25em;
}
.message .bilingual-line:last-child {
  margin-bottom: 0;
}
.message .spanish-text {
  display: block;
  font-size: 1em;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  unicode-bidi: isolate;
}
.message .gloss {
  display: block;
  margin-top: 1px;
  font-family: var(--font-body);
  font-size: 0.76em;
  font-style: italic;
  font-weight: 400;
  line-height: 1.15;
  opacity: 0.8;
}
.message-ai {
  align-self: flex-start;
  background: var(--ink);
  color: var(--on-ink);
  border-color: transparent;
  border-bottom-left-radius: 6px;
  animation: slide-in-left 0.32s var(--ease-smooth) both;
}
.practice-word-card {
  max-width: 92%;
  padding: 12px 14px;
}
.practice-word {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
}
.practice-meaning {
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  opacity: 0.9;
}
.practice-meaning-label {
  font-weight: 800;
  text-transform: lowercase;
  opacity: 0.85;
}
.message-user {
  align-self: flex-end;
  background: var(--red);
  color: var(--on-ink);
  border-color: transparent;
  border-bottom-right-radius: 6px;
  animation: slide-in-right 0.32s var(--ease-smooth) both;
}
.message-correction {
  align-self: center;
  max-width: 90%;
  padding: 7px 10px;
  background: var(--gold-soft);
  color: var(--gold-dark);
  border-left: 4px solid var(--gold);
  font-size: 0.72rem;
  animation: pop-in 0.3s var(--ease-pop) both;
} /* Bottom controls */
.conversation-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  gap: 8px;
  margin: 0;
  padding: 0;
}
.conversation-nav-controls,
.conversation-session-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.controls-separator {
  display: inline-block;
  width: 1px;
  height: 28px;
  margin: 0 4px;
  background: var(--border-strong);
  opacity: 0.7;
  flex-shrink: 0;
}
.conversation-controls .secondary-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 6px 14px;
  background: var(--paper);
  border: 2px solid var(--border-strong);
  border-bottom-width: 3px;
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.73rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.1s ease,
    border-color 0.15s var(--ease-smooth),
    background 0.15s var(--ease-smooth),
    color 0.15s var(--ease-smooth);
}
.conversation-controls .session-action-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
}
.conversation-controls .session-action-icon {
  font-size: 1rem;
  line-height: 1;
  font-weight: 700;
}
.conversation-controls .secondary-button:hover,
.conversation-controls .secondary-button:focus-visible {
  border-color: var(--blue);
  color: var(--blue-dark);
}
.conversation-controls .secondary-button:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}
.conversation-controls .secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.conversation-controls .nav-button:nth-child(2) {
  min-width: 76px;
}
.conversation-controls .secondary-button.paused {
  background: var(--blue);
  border-color: var(--blue-dark);
  color: var(--on-ink);
} /* Listening / processing */
.listening-indicator {
  position: fixed;

  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));

  z-index: 9999;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: 7px;

  width: max-content;
  min-width: 0;

  margin: 0;
  padding: 7px 12px;

  background: rgba(224, 247, 244, 0.97);

  border: 1px solid #bfe9e3;
  border-radius: 999px;

  box-shadow: 0 4px 14px rgba(20, 32, 58, 0.12);

  pointer-events: none;

  animation: listening-indicator-in 0.25s var(--ease-pop) both;

  max-width: calc(100vw - 24px);
}
.listening-indicator span,
#listening-label,
#translate-status-text {
  color: var(--blue-dark);
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.1;
}
.listening-indicator .wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: auto;
  height: 10px;
  flex-shrink: 0;
}
.listening-indicator .wave span {
  display: block;
  width: 2px;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--blue);
  transform-origin: center;
  animation: wave-bar 1s ease-in-out infinite;
}
.listening-indicator .wave span:nth-child(2) {
  animation-delay: 0.15s;
}
.listening-indicator .wave span:nth-child(3) {
  animation-delay: 0.3s;
}
.listening-indicator .wave span:nth-child(4) {
  animation-delay: 0.45s;
}
/* Four bars that dance while the mic is open. */
.wave {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 15px;
  flex-shrink: 0;
}

.wave span {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--blue);
  transform-origin: center;
  animation: wave-bar 1s ease-in-out infinite;
}

.wave span:nth-child(2) {
  animation-delay: 0.15s;
}

.wave span:nth-child(3) {
  animation-delay: 0.3s;
}

.wave span:nth-child(4) {
  animation-delay: 0.45s;
}

@keyframes wave-bar {
  0%,
  100% {
    transform: scaleY(0.35);
  }
  50% {
    transform: scaleY(1);
  }
}

/* Terminal states ("Done", "Failed") keep the bars but stop the dance. */
.translate-status.idle .wave span {
  animation: none;
  transform: scaleY(0.35);
}

#conversation-screen {
  position: relative;
}

#conversation-screen > #listening-indicator {
  position: absolute;

  left: 50%;
  bottom: 12px;

  transform: translateX(-50%);

  z-index: 9999;
}
/* ==========================================================================
   Completion screen
   ========================================================================== */
.completion-container {
  position: relative;
  overflow: hidden;
  padding: 0;
}

/* Centers the completion block vertically + horizontally */
.completion-center {
  min-height: calc(100dvh - 48px - env(safe-area-inset-bottom, 0px));

  padding: 60px 20px;

  position: relative;
  z-index: 1;

  display: flex;
  align-items: center;
  justify-content: center;
}

/* Controls the contents inside the block */
.completion-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

/* Flat SVG confetti dots framing the medal — no gradients. */
.completion-container::before {
  content: "";
  position: absolute;
  inset: 0;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'%3E%3Ccircle cx='50' cy='80' r='8' fill='%23ffce8a'/%3E%3Ccircle cx='180' cy='35' r='6' fill='%2398e0c9'/%3E%3Ccircle cx='350' cy='100' r='5' fill='%23a9c3fb'/%3E%3Ccircle cx='1050' cy='60' r='8' fill='%23ffb199'/%3E%3Ccircle cx='1150' cy='180' r='6' fill='%23c6d6fb'/%3E%3Ccircle cx='1080' cy='400' r='5' fill='%23ffce8a'/%3E%3Ccircle cx='1160' cy='650' r='8' fill='%2398e0c9'/%3E%3Ccircle cx='950' cy='740' r='6' fill='%23a9c3fb'/%3E%3Ccircle cx='700' cy='770' r='5' fill='%23ffb199'/%3E%3Ccircle cx='300' cy='750' r='8' fill='%23ffce8a'/%3E%3Ccircle cx='100' cy='650' r='6' fill='%23c6d6fb'/%3E%3Ccircle cx='40' cy='450' r='5' fill='%23ffb199'/%3E%3Ccircle cx='250' cy='300' r='6' fill='%2398e0c9'/%3E%3C/svg%3E");

  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;

  pointer-events: none;
  z-index: 0;
}
.completion-medal {
  margin-bottom: 14px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  animation:
    pop-scale 0.6s var(--ease-pop) both,
    bob 2.2s ease-in-out 0.6s infinite;
}

.completion-medal img {
  width: 70px;
  height: 70px;
  object-fit: contain;
  display: block;
}
.completion-message h2 {
  font-family: var(--font-display);
  color: var(--red);
  font-size: 1.8rem;
  margin-bottom: 12px;
  animation: pop-in 0.4s var(--ease-smooth) 0.15s both;
}

.completion-message p {
  color: var(--ink-soft);
  margin-bottom: 30px;
  font-size: 1.05rem;
  font-weight: 600;
  animation: pop-in 0.4s var(--ease-smooth) 0.25s both;
}

.completion-message .start-button {
  animation: pop-in 0.4s var(--ease-smooth) 0.35s both;
}

.info-text {
  margin-top: 15px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

.restart-btn {
  margin-top: 10px;
}
/* ==========================================================================
   Accessibility
   ========================================================================== */

a:focus-visible,
button:focus-visible,
.section-card:focus-visible,
.scenario-card:focus-visible,
.vocab-chip:focus-visible {
  outline: 2px solid var(--blue-dark);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Scrollbars
   ========================================================================== */

.conversation-history::-webkit-scrollbar,
.translate-results::-webkit-scrollbar,
.hint-panel::-webkit-scrollbar {
  width: 8px;
}

.conversation-history::-webkit-scrollbar-track,
.translate-results::-webkit-scrollbar-track,
.hint-panel::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-history::-webkit-scrollbar-thumb,
.translate-results::-webkit-scrollbar-thumb,
.hint-panel::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
}

.conversation-history::-webkit-scrollbar-thumb:hover,
.translate-results::-webkit-scrollbar-thumb:hover,
.hint-panel::-webkit-scrollbar-thumb:hover {
  background: var(--ink-soft);
}

/* ==========================================================================
   Responsive — designed mobile-first for an Android/iOS WebView wrapper
   ========================================================================== */

@media (max-width: 768px) {
  .active-session {
    flex-direction: column;
  }

  .conversation-container {
    height: 150px;
  }
}

@media (max-width: 640px) {
  body {
    padding: 0;
    align-items: stretch;
  }

  body::before,
  body::after {
    display: none;
  }

  .container {
    max-width: none;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  header h1 {
    font-size: 1.95rem;
  }

  .message {
    max-width: 88%;
  }

  .completion-medal {
    font-size: 3.5rem;
  }
  .pair-animation-wrap {
    height: 300px;
    margin: 0 0 10px;
    padding: 0;
    border-radius: 16px; /* rounded container */
    background: var(--paper-alt);
    box-sizing: border-box;
    overflow: hidden; /* clips image to rounded corners */
  }

  .pair-animation {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    margin: 0;
    padding: 0;
    border-radius: 0;
  }

  #pair-animation-object {
    width: 100%;
    height: 100%;
  }

  #pair-animation-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}
