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

body {
  font-family: 'Fredoka', 'Comic Neue', 'Comic Sans MS', cursive, sans-serif;
  background: #fff8e7;
  background-image:
    radial-gradient(circle at 25px 25px, rgba(255,209,102,.25) 2px, transparent 2.5px),
    radial-gradient(circle at 75px 75px, rgba(255,209,102,.18) 2px, transparent 2.5px);
  background-size: 100px 100px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Background bees (hidden when .bg-bees-off) ---------- */
.bg-bees { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bg-bees-off { display: none; }
.bg-bee { position: absolute; opacity: .95; animation: floatbee 5s ease-in-out infinite; }
@keyframes floatbee {
  0%,100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-14px) rotate(3deg); }
}
.topbar, .stats, .controls-bar, .card-area, .empty { position: relative; z-index: 1; }

/* ---------- Header ---------- */
.topbar {
  background: linear-gradient(135deg, #e63946, #c1121f);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 12px 16px;
  border-bottom: 6px solid #ffd166;
  overflow: hidden;
}
.topbar h1 {
  font-size: 2.4rem;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 rgba(0,0,0,.25);
  white-space: nowrap;
}
.title-bee {
  height: 72px;
  width: auto;
  flex-shrink: 0;
  animation: floatbee 4s ease-in-out infinite;
}
@keyframes buzz {
  0%,100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-8px) rotate(5deg); }
}

/* ---------- Stats ---------- */
.stats {
  background: #fff3b0;
  text-align: center;
  padding: 10px;
  font-size: 1.15rem;
  color: #7f4f00;
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
}
.stats b { color: #d62828; }

/* ---------- Controls ---------- */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 14px;
  flex-wrap: wrap;
  background: #ffe5ec;
  border-bottom: 3px dashed #ffb3c1;
  z-index: 10;
}
.filter-wrap { position: relative; z-index: 100; }
.filter-btn {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 10px 22px;
  border: none;
  border-radius: 25px;
  background: #4361ee;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #2b3fa8;
  transition: transform .1s;
}
.filter-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #2b3fa8; }

.filter-panel {
  position: absolute;
  top: 110%;
  left: 0;
  z-index: 50;
  background: #fff;
  border: 3px solid #4361ee;
  border-radius: 16px;
  padding: 16px;
  width: min(560px, 92vw);
  max-height: 65vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  z-index: 200;
}
.hidden { display: none !important; }
.filter-group { margin-bottom: 14px; }
.filter-group h3 { color: #4361ee; margin-bottom: 6px; font-size: 1.05rem; }
.options { display: flex; flex-wrap: wrap; gap: 6px; max-height: 130px; overflow-y: auto; }
.option-chip {
  font-family: inherit;
  font-size: .85rem;
  padding: 5px 12px;
  border-radius: 15px;
  border: 2px solid #b8c1ec;
  background: #f1f3ff;
  cursor: pointer;
  transition: all .15s;
}
.option-chip.selected { background: #4361ee; color: #fff; border-color: #4361ee; }
.filter-actions { display: flex; gap: 10px; }
.apply-btn, .clear-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 9px 20px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
}
.apply-btn { background: #06d6a0; color: #fff; box-shadow: 0 3px 0 #049a74; }
.clear-btn { background: #ffd166; color: #7f4f00; box-shadow: 0 3px 0 #d4a017; }
.apply-btn:active, .clear-btn:active { transform: translateY(2px); box-shadow: none; }

/* ---------- Sort ---------- */
.sort-wrap { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #7f4f00; }
.sort-select {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 9px 14px;
  border: 3px solid #ff9f1c;
  border-radius: 20px;
  background: #fff;
  color: #7f4f00;
  cursor: pointer;
}

/* ---------- View toggle & next ---------- */
.view-toggle { display: flex; gap: 6px; }
.view-btn {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid #ff9f1c;
  background: #fff;
  color: #ff9f1c;
  cursor: pointer;
  transition: all .15s;
}
.view-btn.active { background: #ff9f1c; color: #fff; }
.next-btn {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 10px 24px;
  border: none;
  border-radius: 25px;
  background: #06d6a0;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #049a74;
  transition: transform .1s;
}
.next-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #049a74; }
.back-btn {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 10px 24px;
  border: none;
  border-radius: 25px;
  background: #ffb35c;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #d68a2e;
  transition: transform .1s;
}
.back-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d68a2e; }

/* ---------- Cards ---------- */
.card-area {
  display: grid;
  gap: 24px;
  padding: 30px 20px;
  justify-items: center;
  align-content: start;
}
.view-1 { grid-template-columns: minmax(0, 560px); justify-content: center; }
.view-2 { grid-template-columns: repeat(2, minmax(0, 560px)); justify-content: center; }
.view-4 { grid-template-columns: repeat(2, minmax(0, 520px)); justify-content: center; }

.flashcard {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 8 / 3.4;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  background: #ffffff;
  border: 10px solid #3a86ff;
  box-shadow: 0 8px 0 rgba(0,0,0,.15), 0 14px 28px rgba(0,0,0,.12);
  transition: transform .15s;
  user-select: none;
}
.flashcard.border-0 { border-color: #3a86ff; }  /* blue   */
.flashcard.border-1 { border-color: #e63946; }  /* red    */
.flashcard.border-2 { border-color: #2dc653; }  /* green  */
.flashcard.border-3 { border-color: #ffd60a; }  /* yellow */
.view-4 .flashcard { aspect-ratio: 8 / 3.2; border-width: 7px; }
.flashcard:hover { transform: scale(1.03) rotate(-1deg); }
.flashcard .word {
  font-family: 'Nunito', 'Andika', 'Baloo 2', 'Fredoka', cursive, sans-serif;
  font-weight: 800;
  color: #1d3557;
  letter-spacing: 2px;
  white-space: nowrap;
}
.flashcard .word .hint {
  color: #e63946;
}
.flashcard .info {
  position: absolute;
  bottom: 8px;
  left: 16px;
  font-size: .8rem;
  font-weight: 500;
  color: rgba(0,0,0,.45);
}
.flashcard .star {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 1.9rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #ffe066;            /* light yellowish */
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: all .2s;
}
.flashcard .star.mastered {
  color: #f5a300;            /* darker yellow */
  transform: scale(1.15);
}
.flashcard .speak-btn {
  position: absolute;
  bottom: 8px;
  right: 14px;
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform .15s;
}
.flashcard .speak-btn:hover { transform: scale(1.25); }
.flashcard .speak-btn:active { transform: scale(.95); }

/* global hint button in controls bar */
.hint-global-btn {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 10px 24px;
  border: none;
  border-radius: 25px;
  background: #ffd166;
  color: #7f4f00;
  cursor: pointer;
  box-shadow: 0 4px 0 #d4a017;
  transition: transform .1s;
}
.hint-global-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d4a017; }
.hint-global-btn.active { background: #e63946; color: #fff; box-shadow: 0 4px 0 #a62639; }

.empty {
  text-align: center;
  font-size: 1.3rem;
  color: #e63946;
  padding: 40px;
}

@media (max-width: 640px) {
  .view-4 { grid-template-columns: 1fr 1fr; }
  .view-2 { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 1.4rem; }
  .title-bee { height: 48px; }
}
