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

/* ===== DEFAULT THEME VARIABLES ===== */
:root {
  --body-bg: linear-gradient(135deg, #dbeafe 0%, #ede9fe 35%, #d1fae5 70%, #fef9c3 100%);
  --bg: #eff8ff;
  --surface: #ffffff;
  --border: #93c5fd;
  --text: #1e1b4b;
  --text-muted: #6d28d9;
  --text-light: #a5b4fc;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --primary-light: #e0f2fe;
  --success: #34d399;
  --success-dark: #059669;
  --success-light: #d1fae5;
  --success-fg: #065f46;
  --danger: #fb923c;
  --danger-dark: #ea580c;
  --danger-light: #ffedd5;
  --danger-fg: #7c2d12;
  --synonym-bg: #d1fae5;
  --synonym-text: #065f46;
  --antonym-bg: #ffedd5;
  --antonym-text: #7c2d12;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-lg: 28px;
  --radius-xl: 40px;
  --shadow: 0 2px 12px rgba(56,189,248,0.14);
  --shadow-md: 0 6px 24px rgba(56,189,248,0.20);
  --shadow-lg: 0 12px 40px rgba(56,189,248,0.26);
  --shadow-3d: 0 5px 0;
  --header-height: 68px;
}

/* ===== SPACE THEME ===== */
html[data-theme="space"] {
  --body-bg: linear-gradient(160deg, #050518 0%, #0d0a2e 50%, #1a0540 100%);
  --bg: #12123a;
  --surface: #1a1a50;
  --border: rgba(167,139,250,0.25);
  --text: #e4dcff;
  --text-muted: #9d8ec4;
  --text-light: #5a508a;
  --primary: #a78bfa;
  --primary-dark: #7c3aed;
  --primary-light: #2d1b69;
  --success-light: #052e16;
  --success-fg: #a7f3d0;
  --danger-light: #450a0a;
  --danger-fg: #fca5a5;
  --synonym-bg: #052e16;
  --synonym-text: #86efac;
  --antonym-bg: #450a0a;
  --antonym-text: #fca5a5;
}

/* ===== OCEAN THEME ===== */
html[data-theme="ocean"] {
  --body-bg: linear-gradient(180deg, #011d33 0%, #023d6b 60%, #025a8a 100%);
  --bg: #02305a;
  --surface: #03436e;
  --border: rgba(56,189,248,0.25);
  --text: #cef0ff;
  --text-muted: #7bc8e8;
  --text-light: #3d88b5;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --primary-light: #082f49;
  --success-light: #052e16;
  --success-fg: #a7f3d0;
  --danger-light: #450a0a;
  --danger-fg: #fca5a5;
  --synonym-bg: #052e16;
  --synonym-text: #86efac;
  --antonym-bg: #450a0a;
  --antonym-text: #fca5a5;
}

/* ===== WOODLAND THEME ===== */
html[data-theme="woodland"] {
  --body-bg: linear-gradient(160deg, #0d2010 0%, #1a3a15 50%, #253d1e 100%);
  --bg: #1e3a18;
  --surface: #284d20;
  --border: rgba(134,239,172,0.2);
  --text: #e0f5d8;
  --text-muted: #90c078;
  --text-light: #557040;
  --primary: #86efac;
  --primary-dark: #22c55e;
  --primary-light: #14532d;
  --success-light: #052e16;
  --success-fg: #bbf7d0;
  --danger-light: #450a0a;
  --danger-fg: #fca5a5;
  --synonym-bg: #052e16;
  --synonym-text: #86efac;
  --antonym-bg: #450a0a;
  --antonym-text: #fca5a5;
}

/* ===== CANDY THEME ===== */
html[data-theme="candy"] {
  --body-bg: linear-gradient(135deg, #fff0fb 0%, #fce8ff 50%, #ffe0f8 100%);
  --bg: #fce8ff;
  --surface: #fff5fe;
  --border: #f0a8e0;
  --text: #3d0a38;
  --text-muted: #9b3590;
  --text-light: #cf90c8;
  --primary: #ec4899;
  --primary-dark: #be185d;
  --primary-light: #fce7f3;
  --success-light: #dcfce7;
  --success-fg: #065f46;
  --danger-light: #fee2e2;
  --danger-fg: #991b1b;
  --synonym-bg: #dcfce7;
  --synonym-text: #166534;
  --antonym-bg: #fee2e2;
  --antonym-text: #991b1b;
}

/* ===== DESERT THEME ===== */
html[data-theme="desert"] {
  --body-bg: linear-gradient(180deg, #1a0800 0%, #3d1e00 50%, #2c1400 100%);
  --bg: #3a1a00;
  --surface: #4d2800;
  --border: rgba(251,146,60,0.25);
  --text: #ffecd0;
  --text-muted: #d4945c;
  --text-light: #8a5030;
  --primary: #fb923c;
  --primary-dark: #ea580c;
  --primary-light: #431407;
  --success-light: #052e16;
  --success-fg: #a7f3d0;
  --danger-light: #450a0a;
  --danger-fg: #fca5a5;
  --synonym-bg: #052e16;
  --synonym-text: #86efac;
  --antonym-bg: #450a0a;
  --antonym-text: #fca5a5;
}

/* ===== BASE ===== */
body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--body-bg);
  background-attachment: fixed;
  background-size: 200% 200%;
  animation: bgDrift 18s ease infinite;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.5s ease, color 0.3s ease;
}

@keyframes bgDrift {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

/* ===== THEME LAYER (floating particles) ===== */
#themeLayer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.theme-particle {
  position: absolute;
  bottom: -60px;
  animation: floatUp linear infinite;
  user-select: none;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg) scale(1);   opacity: 0; }
  5%   { opacity: 0.85; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-110vh) rotate(360deg) scale(0.6); opacity: 0; }
}

/* ===== HEADER ===== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, #e0f2fe 0%, #ede9fe 50%, #d1fae5 100%);
  border-bottom: 3px solid var(--border);
  border-radius: 0 0 24px 24px;
  z-index: 100;
  box-shadow: var(--shadow-md);
  transition: background 0.4s, border-color 0.4s;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  font-weight: 400;
  color: var(--primary);
  white-space: nowrap;
  letter-spacing: 0.5px;
}
#logoEmoji { font-size: 22px; transition: transform 0.3s; }
#logoEmoji:hover { transform: rotate(-10deg) scale(1.2); }

.main-nav {
  flex: 1;
  display: flex;
  gap: 2px;
  justify-content: center;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-xl);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  font-family: 'Nunito', inherit;
  transition: all 0.18s;
}
.nav-btn:hover { background: rgba(255,255,255,0.5); color: var(--text); transform: translateY(-1px); }
.nav-btn.active {
  background: var(--primary);
  color: white;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(56,189,248,0.45);
  transform: translateY(-1px);
}

.header-actions { display: flex; gap: 6px; align-items: center; }

.icon-btn {
  width: 38px; height: 38px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  box-shadow: 0 3px 0 var(--border);
}
.icon-btn:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 5px 0 var(--primary-light); }

/* ===== THEME PICKER ===== */
.theme-wrapper { position: relative; }

.theme-picker {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 260px;
  animation: popIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(-6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.theme-picker-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-option-btn {
  padding: 12px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  font-family: inherit;
  box-shadow: 0 3px 0 var(--border);
}
.theme-option-btn:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 6px 0 var(--primary-light); }
.theme-option-btn.active { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 3px 0 var(--primary); }
.theme-emoji { font-size: 26px; display: block; margin-bottom: 4px; }
.theme-name { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.theme-option-btn.active .theme-name { color: var(--primary); }

/* ===== GLASSMORPHISM (dark themes) ===== */
html[data-theme="space"] .card,
html[data-theme="space"] .flip-face,
html[data-theme="ocean"] .card,
html[data-theme="ocean"] .flip-face,
html[data-theme="woodland"] .card,
html[data-theme="woodland"] .flip-face,
html[data-theme="desert"] .card,
html[data-theme="desert"] .flip-face {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-color: rgba(255,255,255,0.14);
}

/* ===== MAIN ===== */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 24px) 20px 48px;
  position: relative;
  z-index: 1;
}

/* ===== TABS ===== */
.tab-content { display: none; animation: fadeIn 0.25s ease; }
.tab-content.active { display: block; }

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

.tab-header { margin-bottom: 24px; }
.tab-header h1 { font-family: 'Fredoka One', cursive; font-size: 34px; font-weight: 400; color: var(--text); letter-spacing: 0.3px; }
.tab-subtitle { color: var(--primary-dark); font-size: 15px; font-weight: 600; margin-top: 5px; }

/* ===== EXPLORER CONTROLS ===== */
.explorer-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 9px 16px;
  flex: 1;
  min-width: 160px;
  max-width: 300px;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}
.search-bar input {
  border: none; outline: none;
  flex: 1; font-size: 14px;
  color: var(--text); background: transparent;
}
.search-bar input::placeholder { color: var(--text-light); }

.sort-select {
  padding: 9px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  font-size: 13px; font-weight: 600;
  color: var(--text);
  background: var(--surface);
  cursor: pointer; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}
.sort-select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }

.word-count-badge {
  padding: 7px 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--primary-dark);
}

/* ===== WORD EXPLORER ===== */
.word-explorer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

/* ===== FLIP CARD ===== */
.flip-card {
  perspective: 1200px;
  width: 100%;
  max-width: 520px;
  height: 360px;
  cursor: pointer;
}

@media (max-width: 560px) {
  .flip-card { height: 320px; }
}

.flip-card-inner {
  position: relative;
  width: 100%; height: 100%;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg), 0 6px 0 var(--border);
  transition: background 0.4s, border-color 0.4s;
  overflow: hidden;
}

/* Subtle sheen on the card */
.flip-face::before {
  content: '';
  position: absolute;
  top: -60%;
  left: -60%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 60% 40%, rgba(255,255,255,0.06) 0%, transparent 60%);
  pointer-events: none;
}

/* Top accent stripe */
.flip-face::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, #38bdf8, #a78bfa, #fb923c, #34d399, #fcd34d);
  pointer-events: none;
}

.flip-back {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
  align-items: flex-start;
}

/* Front face */
.card-top-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-big-word {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(38px, 9vw, 62px);
  font-weight: 400;
  color: var(--primary);
  text-align: center;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s;
  padding: 8px 0;
  letter-spacing: 1px;
}

.card-phonetic {
  font-size: 15px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  margin-bottom: 12px;
  min-height: 20px;
}

.flip-hint-btn {
  margin-top: auto;
  padding: 10px 22px;
  border: 2px dashed var(--border);
  border-radius: 24px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: hintPulse 2.5s ease-in-out infinite;
}
.flip-hint-btn:hover { border-color: var(--primary); color: var(--primary); border-style: solid; animation: none; }
.flip-card.flipped .flip-hint-btn { animation: none; }

@keyframes hintPulse {
  0%, 100% { transform: scale(1);    border-color: var(--border); }
  50%       { transform: scale(1.04); border-color: var(--primary); color: var(--primary); }
}

.card-delete-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 28px; height: 28px;
  border: none; background: transparent;
  cursor: pointer; font-size: 15px;
  border-radius: 6px;
  opacity: 0.35;
  transition: opacity 0.2s, background 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.card-delete-btn:hover { opacity: 1; background: var(--danger-light); }

/* Back face */
.card-word-small {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  font-weight: 400;
  color: var(--primary);
  width: 100%;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.back-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  width: 100%;
  margin-bottom: 8px;
}

.card-meaning {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  width: 100%;
  flex: 1;
  overflow-y: auto;
}

.card-tags-back {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ===== WORD NAVIGATION ===== */
.word-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.arrow-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
  box-shadow: 0 4px 0 var(--border);
  font-family: inherit;
}
.arrow-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--primary-light);
}
.arrow-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--border); }
.arrow-btn:disabled { opacity: 0.25; cursor: not-allowed; transform: none; }

.word-nav-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 120px;
  justify-content: center;
}

.nav-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}
.nav-dot:hover { background: var(--text-muted); transform: scale(1.2); }
.nav-dot.active { background: var(--primary); transform: scale(1.3); }

.nav-counter {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ===== CARD (shared) ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  padding: 28px;
  box-shadow: var(--shadow-md);
  transition: background 0.4s, border-color 0.4s, transform 0.2s, box-shadow 0.2s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ===== CARD HEADINGS ===== */
.card h3 {
  font-family: 'Fredoka One', cursive;
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.3px;
}

/* ===== STAT CARDS ===== */
.progress-stats-grid .stat-card:nth-child(1) { border-color: #38bdf8; box-shadow: 0 6px 0 #0284c7; }
.progress-stats-grid .stat-card:nth-child(1) .stat-value { color: #0284c7; }
.progress-stats-grid .stat-card:nth-child(1) .stat-icon { filter: drop-shadow(0 0 6px rgba(56,189,248,0.6)); }

.progress-stats-grid .stat-card:nth-child(2) { border-color: #a78bfa; box-shadow: 0 6px 0 #7c3aed; }
.progress-stats-grid .stat-card:nth-child(2) .stat-value { color: #7c3aed; }
.progress-stats-grid .stat-card:nth-child(2) .stat-icon { filter: drop-shadow(0 0 6px rgba(167,139,250,0.6)); }

.progress-stats-grid .stat-card:nth-child(3) { border-color: #fbbf24; box-shadow: 0 6px 0 #d97706; }
.progress-stats-grid .stat-card:nth-child(3) .stat-value { color: #d97706; }
.progress-stats-grid .stat-card:nth-child(3) .stat-icon { filter: drop-shadow(0 0 6px rgba(252,211,77,0.7)); }

.progress-stats-grid .stat-card:nth-child(4) { border-color: #34d399; box-shadow: 0 6px 0 #059669; }
.progress-stats-grid .stat-card:nth-child(4) .stat-value { color: #059669; }
.progress-stats-grid .stat-card:nth-child(4) .stat-icon { filter: drop-shadow(0 0 6px rgba(52,211,153,0.6)); }

/* ===== BADGES & TAGS ===== */
.pos-badge {
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mastery-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-xl);
}
.mastery-0 { background: #f1f5f9; color: #64748b; }
.mastery-1 { background: #fef9c3; color: #b45309; }
.mastery-2 { background: #ffedd5; color: #c2410c; }
.mastery-3 { background: #a7f3d0; color: #047857; }
.mastery-4 { background: #bfdbfe; color: #1d4ed8; }

.tag-row { display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; }
.tag-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 3px;
  min-width: 26px;
}
.tag { padding: 4px 12px; border-radius: var(--radius-xl); font-size: 12px; font-weight: 600; }
.synonym-tag { background: var(--synonym-bg); color: var(--synonym-text); }
.antonym-tag { background: var(--antonym-bg); color: var(--antonym-text); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}
.empty-state-icon { font-size: 72px; margin-bottom: 16px; animation: floatBob 3s ease-in-out infinite; display: inline-block; }
@keyframes floatBob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}
.empty-state h3 { font-family: 'Fredoka One', cursive; font-size: 24px; font-weight: 400; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 15px; color: var(--primary-dark); font-weight: 600; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-xl);
  border: none; cursor: pointer;
  font-size: 14px; font-weight: 700; font-family: inherit;
  transition: all 0.1s;
  white-space: nowrap;
  position: relative;
}
.btn-primary {
  background: var(--primary); color: white;
  box-shadow: var(--shadow-3d) var(--primary-dark);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--primary-dark);
}
.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--primary-dark);
}
.btn-success {
  background: var(--success); color: white;
  box-shadow: var(--shadow-3d) var(--success-dark);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--success-dark);
}
.btn-success:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--success-dark); }
.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-3d) var(--border);
}
.btn-secondary:hover {
  background: var(--bg); transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--border);
}
.btn-secondary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--border); }
.btn-large { padding: 14px 32px; font-size: 15px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.link-btn {
  background: none; border: none;
  color: var(--primary); cursor: pointer;
  font-size: inherit; font-weight: 600;
  padding: 0; text-decoration: underline; font-family: inherit;
}

/* ===== ADD WORD ===== */
.add-word-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block;
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 7px;
}
.label-hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-light); }

.word-input-row { display: flex; gap: 10px; }

.word-input, .form-input, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit;
  color: var(--text); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.word-input { font-size: 18px; font-family: 'Fredoka One', cursive; letter-spacing: 0.5px; }
.word-input:focus, .form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-textarea { resize: vertical; min-height: 80px; }

.lookup-result { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.lookup-word-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.lookup-word-header h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 28px; font-weight: 400; color: var(--primary);
  letter-spacing: 0.5px;
}

.lookup-error {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--danger-fg);
}

.phonetic { font-size: 13px; color: var(--text-muted); font-style: italic; }

.section-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }

.bulk-progress {
  margin-top: 14px; padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  max-height: 220px; overflow-y: auto;
}
.bulk-progress-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.bulk-progress-item:last-child { border-bottom: none; }

/* ===== QUIZ CONFIG ===== */
.quiz-config { max-width: 560px; }
.quiz-option-group { margin-bottom: 20px; }
.option-label {
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}
.option-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.option-btn {
  padding: 8px 16px;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; font-weight: 500; font-family: inherit;
  color: var(--text-muted);
  transition: all 0.15s;
}
.option-btn:hover { border-color: var(--primary); color: var(--primary); }
.option-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* ===== QUIZ ACTIVE ===== */
.quiz-header { margin-bottom: 20px; }
.quiz-meta {
  display: flex; justify-content: space-between;
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 10px;
}
.quiz-progress-bar { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; border: 2px solid var(--border); }
.quiz-progress-fill { height: 100%; background: linear-gradient(90deg, #38bdf8, #a78bfa, #fb923c, #34d399); border-radius: 4px; transition: width 0.5s cubic-bezier(0.34,1.2,0.64,1); }

.quiz-card { max-width: 720px; width: 100%; }
.question-label {
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 12px;
}
.quiz-prompt {
  font-family: 'Fredoka One', cursive;
  font-size: 30px; font-weight: 400; color: var(--primary);
  margin-bottom: 28px; line-height: 1.4; min-height: 60px;
  letter-spacing: 0.5px;
}
.quiz-prompt.definition-mode {
  font-size: 17px;
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 600;
  font-style: italic;
  color: var(--text);
  line-height: 1.65;
}

.quiz-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }

.quiz-option-card {
  padding: 18px 20px;
  min-height: 80px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer; font-size: 15px; line-height: 1.55;
  color: var(--text); background: var(--surface);
  font-family: inherit;
  transition: all 0.1s;
  text-align: left;
  display: flex; align-items: center; gap: 12px;
  word-break: break-word;
  box-shadow: 0 4px 0 var(--border);
}
.quiz-option-card:hover:not(:disabled) {
  border-color: var(--primary); background: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: 0 7px 0 var(--primary-light), var(--shadow-md);
}
.quiz-option-card:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border);
}
.quiz-option-card.correct {
  border-color: var(--success); background: var(--success-light); color: var(--success-fg);
  box-shadow: 0 4px 0 var(--success-dark);
}
.quiz-option-card.incorrect {
  border-color: var(--danger); background: var(--danger-light); color: var(--danger-fg);
  box-shadow: 0 4px 0 var(--danger-dark);
}
.quiz-option-card:disabled { cursor: default; transform: none; }

.option-letter {
  font-size: 12px; font-weight: 700;
  width: 28px; height: 28px;
  border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--text-muted);
}
.quiz-option-card.correct .option-letter { background: var(--success); color: white; }
.quiz-option-card.incorrect .option-letter { background: var(--danger); color: white; }

.quiz-feedback {
  margin-top: 14px; padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600; line-height: 1.5;
  border: 2px solid transparent;
  animation: feedbackPop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes feedbackPop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.quiz-feedback.correct { background: var(--success-light); color: var(--success-fg); border-color: var(--success); }
.quiz-feedback.incorrect { background: var(--danger-light); color: var(--danger-fg); border-color: var(--danger); }

/* ===== QUIZ COMPLETE ===== */
.quiz-complete { display: flex; justify-content: center; }
.quiz-results { max-width: 480px; width: 100%; text-align: center; padding: 40px; border-radius: var(--radius-lg); }
.results-icon { font-size: 64px; margin-bottom: 14px; display: inline-block; animation: floatBob 2s ease-in-out infinite; }
.quiz-results h2 { font-family: 'Fredoka One', cursive; font-size: 30px; font-weight: 400; color: var(--text); margin-bottom: 20px; letter-spacing: 0.5px; }
.results-score { display: flex; align-items: baseline; justify-content: center; gap: 12px; margin-bottom: 24px; }
.score-big {
  font-size: 56px; font-weight: 400; font-family: 'Fredoka One', cursive;
  background: linear-gradient(135deg, #38bdf8, #a78bfa, #fb923c);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.score-percent { font-size: 26px; color: var(--primary); font-weight: 800; }
.results-breakdown {
  text-align: left; margin-bottom: 28px;
  max-height: 200px; overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; font-size: 14px;
  border-bottom: 1px solid var(--border); color: var(--text);
}
.result-item:last-child { border-bottom: none; }
.result-word { font-weight: 700; font-family: 'Fredoka One', cursive; font-size: 16px; letter-spacing: 0.3px; }
.results-actions { display: flex; gap: 12px; justify-content: center; }

/* ===== PROGRESS ===== */
.progress-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  text-align: center; padding: 32px 16px;
  border-radius: var(--radius-lg);
  transition: transform 0.2s, box-shadow 0.2s, background 0.4s, border-color 0.4s;
}
.stat-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.stat-icon { font-size: 36px; margin-bottom: 14px; display: inline-block; transition: transform 0.3s; }
.stat-card:hover .stat-icon { transform: scale(1.2) rotate(-5deg); }
.stat-value { font-size: 40px; font-weight: 800; color: var(--primary); margin-bottom: 4px; font-family: 'Fredoka One', cursive; letter-spacing: 1px; }
.stat-label { font-size: 13px; color: var(--text); font-weight: 700; }

.mastery-section { margin-bottom: 24px; }
.mastery-section h3, .word-progress-section h3 { font-family: 'Fredoka One', cursive; font-size: 20px; font-weight: 400; margin-bottom: 18px; color: var(--text); }
.mastery-chart { display: flex; flex-direction: column; gap: 14px; }
.mastery-row { display: flex; align-items: center; gap: 12px; }
.mastery-row-label { font-size: 13px; font-weight: 500; color: var(--text-muted); width: 96px; text-align: right; flex-shrink: 0; }
.mastery-bar-bg { flex: 1; height: 16px; background: var(--bg); border-radius: 8px; overflow: hidden; border: 2px solid var(--border); }
.mastery-bar-fill { height: 100%; border-radius: 6px; transition: width 0.7s cubic-bezier(0.34,1.2,0.64,1); }
.mastery-count { font-size: 13px; font-weight: 600; color: var(--text); width: 28px; text-align: right; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.word-progress-list { display: flex; flex-direction: column; gap: 10px; }
.word-progress-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; background: var(--bg);
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: all 0.15s;
}
.word-progress-item:hover { background: var(--surface); border-color: var(--border); transform: translateX(4px); box-shadow: var(--shadow); }
.wpi-word { font-family: 'Fredoka One', cursive; font-size: 17px; font-weight: 400; width: 140px; flex-shrink: 0; color: var(--primary); letter-spacing: 0.3px; }
.wpi-bar-area { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.wpi-bar-bg { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.wpi-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.wpi-stats { font-size: 12px; color: var(--text-muted); }
.wpi-mastery { flex-shrink: 0; }

/* ===== MULTI-SELECT QUIZ OPTIONS ===== */
.quiz-option-card.multi-select {
  position: relative;
  padding-right: 44px; /* room for checkbox */
}
.quiz-option-card.multi-select::before {
  content: '';
  position: absolute;
  top: 50%; right: 14px;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.quiz-option-card.multi-select.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.quiz-option-card.multi-select.selected::before {
  background: var(--primary); border-color: var(--primary);
  content: '✓'; font-size: 12px; font-weight: 700; color: white;
  display: flex; align-items: center; justify-content: center;
}
.quiz-option-card.multi-select.selected .option-letter { background: var(--primary); color: white; }
.multi-select-hint {
  grid-column: 1 / -1; /* span both columns */
  font-size: 12px; color: var(--text-muted);
  margin: 0 0 4px; font-style: italic;
  padding: 6px 10px;
  background: var(--bg); border-radius: var(--radius-sm);
}

/* ===== CANDY BURST ===== */
.candy-particle {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  font-size: 22px;
  line-height: 1;
  animation: candyBurst 0.9s ease-out forwards;
}
@keyframes candyBurst {
  0%   { transform: translate(0,0) scale(0) rotate(0deg); opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translate(var(--cx),var(--cy)) scale(1.3) rotate(var(--cr)); opacity: 0; }
}

/* ===== SPINNER ===== */
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TOAST ===== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000;
}
.toast {
  padding: 14px 22px; border-radius: var(--radius-xl);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 320px; color: white;
}
.toast.success { background: #064e3b; }
.toast.error   { background: #7f1d1d; }
.toast.info    { background: #312e81; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== MASCOT PICKER ===== */
.mascot-wrapper { position: relative; }
.mascot-picker {
  position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  box-shadow: var(--shadow-lg); z-index: 200; min-width: 200px;
  animation: pickerFadeIn 0.18s ease;
}
.mascot-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px;
}
.mascot-option-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 8px; border-radius: var(--radius-sm);
  border: 2px solid transparent; background: var(--bg);
  cursor: pointer; transition: all 0.15s ease; font-family: inherit;
}
.mascot-option-btn:hover { border-color: var(--primary); background: var(--primary-soft, rgba(99,102,241,0.1)); transform: translateY(-2px); }
.mascot-option-btn.active { border-color: var(--primary); background: var(--primary-soft, rgba(99,102,241,0.1)); }
.mascot-emoji { font-size: 28px; line-height: 1; }
.mascot-name { font-size: 12px; font-weight: 600; color: var(--text); }

/* ===== DAILY CHALLENGE CARD ===== */
.daily-challenge-card {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, var(--primary-soft, rgba(88,204,2,0.12)), rgba(255,200,0,0.12));
  border: 2px solid var(--primary); border-radius: var(--radius-lg);
  padding: 18px 20px; margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}
.dc-mascot {
  font-size: 42px; line-height: 1; flex-shrink: 0;
  animation: mascotIdleBounce 2.4s ease-in-out infinite;
}
.dc-content { flex: 1; min-width: 0; }
.dc-title { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.3; margin-bottom: 4px; }
.dc-subtitle { font-size: 13px; color: var(--text-muted); }
.dc-streak {
  display: inline-block; margin-top: 5px;
  font-size: 12px; font-weight: 700; color: #f97316;
  background: rgba(249,115,22,0.12); padding: 2px 8px;
  border-radius: 100px;
}

/* ===== MASCOT FEEDBACK (QUIZ) ===== */
.mascot-feedback {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius-lg);
  margin-top: 12px; animation: mascotPop 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.mascot-feedback.mf-correct  { background: rgba(34,197,94,0.12);  border: 1.5px solid rgba(34,197,94,0.35); }
.mascot-feedback.mf-incorrect { background: rgba(239,68,68,0.10);  border: 1.5px solid rgba(239,68,68,0.28); }
.mf-avatar {
  font-size: 30px; line-height: 1; flex-shrink: 0;
  animation: mascotAnswer 0.5s ease;
}
.mf-message {
  font-size: 14px; font-weight: 600; color: var(--text);
  line-height: 1.45; margin: 0; padding-top: 4px;
}

/* ===== MASCOT ENCOURAGEMENT (PROGRESS) ===== */
.mascot-encourage-card { margin-bottom: 20px; }
.mascot-encourage-inner {
  display: flex; align-items: center; gap: 14px;
}
.mascot-encourage-avatar {
  font-size: 44px; line-height: 1; flex-shrink: 0;
  animation: mascotIdleBounce 2.8s ease-in-out infinite;
}
.mascot-encourage-name {
  font-size: 12px; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px;
}
.mascot-encourage-message {
  font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.45;
}

/* ===== MASCOT ANIMATIONS ===== */
@keyframes mascotIdleBounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%       { transform: translateY(-6px) rotate(3deg); }
}
@keyframes mascotAnswer {
  0%   { transform: scale(0.6) rotate(-20deg); }
  60%  { transform: scale(1.2) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes mascotPop {
  0%   { opacity: 0; transform: scale(0.85) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */

/* --- Tablet / iPad (≤1024px) --- */
@media (max-width: 1024px) {
  .quiz-card { max-width: 100%; }
  .quiz-config { max-width: 100%; }
}

/* --- Small tablet / large phone (≤900px) --- */
@media (max-width: 900px) {
  .add-word-container { grid-template-columns: 1fr; }
  .progress-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .flip-card { max-width: 100%; }
  .word-explorer { gap: 20px; }
  .quiz-option-card { font-size: 14px; padding: 16px 18px; min-height: 72px; }
  .quiz-option-card.multi-select { padding-right: 40px; }
}

/* --- iPad portrait / mid-size (601px–768px) --- */
@media (max-width: 768px) {
  .quiz-options-grid { gap: 12px; }
  .quiz-prompt { font-size: 26px; margin-bottom: 22px; }
  .stat-card { padding: 22px 12px; }
  .stat-value { font-size: 32px; }
  .score-big { font-size: 44px; }
  .quiz-results { padding: 32px 24px; }
  .tab-header h1 { font-size: 28px; }
}

/* --- Mobile (≤600px) --- */
@media (max-width: 600px) {
  .nav-label { display: none; }
  .header-content { padding: 0 12px; gap: 8px; }
  .app-main { padding: calc(var(--header-height) + 16px) 14px 40px; }

  /* Quiz */
  .quiz-options-grid { grid-template-columns: 1fr; gap: 10px; }
  .quiz-option-card { padding: 14px 16px; min-height: 60px; font-size: 14px; }
  .quiz-option-card.multi-select { padding-right: 40px; }
  .quiz-prompt { font-size: 20px; margin-bottom: 18px; min-height: 48px; }
  .quiz-card { padding: 18px 16px; }
  .question-label { font-size: 11px; }

  /* Library card */
  .flip-card { height: 300px; }
  .card-big-word { font-size: clamp(28px, 10vw, 48px); }
  .arrow-btn { width: 46px; height: 46px; font-size: 26px; }

  /* Progress */
  .progress-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 18px 10px; }
  .stat-value { font-size: 28px; }
  .stat-icon { font-size: 26px; margin-bottom: 8px; }

  /* Results */
  .quiz-results { padding: 24px 16px; }
  .score-big { font-size: 38px; }
  .score-percent { font-size: 20px; }

  /* General */
  .tab-header h1 { font-size: 26px; }
  .tab-subtitle { font-size: 13px; }
  .option-btn { padding: 7px 12px; font-size: 13px; }
  .card { padding: 18px 16px; }
}
