/* =========================================================
   QuizPlay — main stylesheet
   Mobile-first, game-like, uses admin-controlled CSS vars
   ========================================================= */

* { box-sizing: border-box; }

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--background);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}

h1, h2, h3, h4, .brand-name, .fun-heading {
  font-family: 'Baloo 2', 'Poppins', sans-serif;
}

a { color: var(--primary); }

.container { max-width: 1100px; }

/* ---------------- Header ---------------- */
.site-header {
  background: var(--header-bg, #fff);
  color: var(--header-text, var(--text));
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  position: sticky;
  top: 0;
  z-index: 60;
}
.brand-name { font-weight: 800; font-size: 1.3rem; color: var(--header-text, var(--primary)); }
.brand-emoji { font-size: 1.6rem; }
.brand-logo { height: 36px; width: auto; }
.site-nav a {
  text-decoration: none;
  font-weight: 600;
  color: var(--header-text, var(--text));
  font-size: .95rem;
  opacity: .9;
}
.site-nav a:hover { color: var(--accent); opacity: 1; }
.visitor-badge {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
}

/* ---------------- Mobile menu toggle (hamburger) ---------------- */
.mobile-menu-toggle {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: rgba(127,127,127,.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-menu-toggle span {
  width: 20px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--header-text, var(--text));
  display: block;
  transition: transform .2s ease, opacity .2s ease;
}
.mobile-menu-toggle:hover { background: rgba(127,127,127,.2); }

/* ---------------- Mobile menu popup (blurred backdrop) ---------------- */
.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(20, 18, 35, .45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  display: flex;
  justify-content: flex-end;
}
.mobile-menu-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.mobile-menu-panel {
  width: min(320px, 84vw);
  height: 100%;
  background: var(--background, #fff);
  color: var(--text);
  box-shadow: -10px 0 40px rgba(0,0,0,.25);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.2,.9,.3,1.2);
}
.mobile-menu-overlay.open .mobile-menu-panel { transform: translateX(0); }
.mobile-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 10px;
  border-bottom: 2px solid rgba(127,127,127,.15);
}
.mobile-menu-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: rgba(127,127,127,.12);
  font-size: 1rem;
  cursor: pointer;
}
.mobile-menu-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.mobile-menu-nav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 13px 14px;
  border-radius: 14px;
  background: rgba(127,127,127,.06);
  transition: background .15s ease, transform .15s ease;
}
.mobile-menu-nav a:hover {
  background: var(--primary);
  color: #fff;
  transform: translateX(-2px);
}
.mobile-menu-visitor {
  margin-top: auto;
  padding-top: 16px;
  font-weight: 700;
  text-align: center;
  border-top: 2px solid rgba(127,127,127,.15);
}

/* ---------------- Live search ---------------- */
.live-search-wrap {
  position: relative;
  padding: 10px 0 14px;
}
.live-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(127,127,127,.08);
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  transition: border-color .15s ease, background .15s ease;
}
.live-search-box:focus-within {
  border-color: var(--primary);
  background: #fff;
}
.live-search-icon { font-size: .95rem; opacity: .7; }
.live-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  min-width: 0;
}
.live-search-clear {
  border: none;
  background: rgba(127,127,127,.15);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: .7rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.live-search-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,.16);
  padding: 8px;
  max-height: 420px;
  overflow-y: auto;
  z-index: 70;
  display: none;
  color: var(--text);
}
.live-search-results.open { display: block; }
.live-search-group-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 800;
  color: #999;
  padding: 8px 10px 4px;
}
.live-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
}
.live-search-item:hover { background: var(--background); color: var(--text); }
.live-search-item-icon { font-size: 1.1rem; }
.live-search-item-thumb {
  width: 38px; height: 38px; border-radius: 9px; object-fit: cover; flex-shrink: 0; background: #eee;
}
.live-search-item-title { display: block; font-weight: 700; font-size: .9rem; }
.live-search-item-cat { display: block; font-size: .75rem; color: #999; }
.live-search-empty { padding: 16px; text-align: center; color: #999; font-size: .9rem; }

/* ---------------- Hero / Featured ---------------- */
.hero-featured {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 24px;
  padding: 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin: 24px 0;
}
.hero-featured::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,.12);
  border-radius: 50%;
}
.hero-featured .badge-featured {
  background: var(--accent);
  color: #2D2D2D;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: .8rem;
  display: inline-block;
  margin-bottom: 10px;
}
.hero-featured h2 { font-weight: 800; font-size: 1.6rem; margin-bottom: 6px; }
.hero-featured p { opacity: .95; margin-bottom: 16px; }
.hero-featured img {
  border-radius: 16px;
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1/1;
  object-fit: cover;
  box-shadow: 0 10px 25px rgba(0,0,0,.2);
}

/* ---------------- Section headings ---------------- */
.category-heading {
  font-weight: 800;
  font-size: 1.35rem;
  margin: 30px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.category-heading a.see-all {
  margin-left: auto;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
}

/* ---------------- Quiz cards ---------------- */
.quiz-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.quiz-card {
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
  border: 2px solid transparent;
}
.quiz-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
  border-color: var(--primary);
  color: var(--text);
}
.quiz-card .thumb {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  background: #eee;
}
.quiz-card .body { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; }
.quiz-card .title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; line-height: 1.25; }
.quiz-card .meta { font-size: .78rem; color: #888; margin-bottom: 10px; display: flex; gap: 10px; flex-wrap: wrap; }
.quiz-card .start-btn {
  margin-top: auto;
  background: var(--primary);
  color: #fff;
  text-align: center;
  border-radius: 999px;
  padding: 8px 0;
  font-weight: 700;
  font-size: .85rem;
}

/* ---------------- Category "winner area" banner ---------------- */
.winner-area {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(120deg, var(--accent), var(--secondary));
  border-radius: 22px;
  padding: 22px 24px;
  margin: 18px 0 26px;
  color: #2D2D2D;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0,0,0,.1);
}
.winner-area::after {
  content: "";
  position: absolute;
  right: -30px; bottom: -30px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,.18);
  border-radius: 50%;
}
.winner-area-icon {
  font-size: 2.6rem;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.15));
}
.winner-area-heading { font-weight: 800; font-size: 1.2rem; margin-bottom: 4px; }
.winner-area-desc { margin: 0; opacity: .9; font-size: .92rem; }

/* ---------------- Winner popup (bottom, rotating on a loop) ---------------- */
.winner-popup {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 150;
  max-width: 390px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,.22);
  padding: 16px 40px 16px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-left: 5px solid var(--accent);
  opacity: 0;
  transform: translateY(30px) scale(.96);
  pointer-events: none;
}
.winner-popup.show {
  animation: winnerPopIn .4s ease forwards, winnerPopOut .4s ease 4.4s forwards;
  pointer-events: auto;
}
@keyframes winnerPopIn {
  from { opacity: 0; transform: translateY(30px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes winnerPopOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(30px) scale(.96); }
}

.winner-popup-body {
    display: flex;
}
.winner-popup-icon { font-size: 1.6rem; flex-shrink: 0; }
.winner-popup-name { font-weight: 800; font-size: .95rem; color: var(--text); }
.winner-popup-quiz { font-size: .78rem; color: #999; margin-bottom: 6px; font-style: italic; }
.winner-popup-heading { font-weight: 700; font-size: .88rem; margin-bottom: 3px; color: var(--primary); }
.winner-popup-desc { font-size: .82rem; color: #777; line-height: 1.35; }
.winner-popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  font-size: .8rem;
  color: #aaa;
  cursor: pointer;
}
.winner-popup-close:hover { color: #666; }
@media (max-width: 480px) {
  .winner-popup { left: 12px; right: 12px; max-width: none; bottom: 12px; }
  .winner-area { flex-direction: column; text-align: center; padding: 20px 18px; }
}

/* ---------------- Category grid (category listing page) ---------------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.cat-tile {
  background: #fff;
  border-radius: 18px;
  padding: 16px 10px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  font-weight: 700;
  transition: transform .15s ease;
}
.cat-tile:hover { transform: translateY(-3px); color: var(--text); }
.cat-tile img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 50%;
  margin: 0 auto 8px; display: block; background: #eee;
}

/* ---------------- Name gate modal ---------------- */
.name-gate-card {
  max-width: 420px;
  margin: 60px auto;
  background: #fff;
  border-radius: 22px;
  padding: 30px 26px;
  box-shadow: 0 10px 30px rgba(0,0,0,.1);
  text-align: center;
}
.name-gate-card .emoji { font-size: 2.8rem; }
.name-gate-card input {
  border-radius: 14px;
  padding: 12px 16px;
  border: 2px solid #eee;
  width: 100%;
  font-size: 1rem;
  margin: 16px 0;
}
.name-gate-card input:focus { outline: none; border-color: var(--primary); }
.btn-fun {
  background: var(--primary);
  border: none;
  color: #fff;
  font-weight: 700;
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 1rem;
  transition: transform .1s ease, opacity .1s ease;
}
.btn-fun:hover { opacity: .92; color:#fff; transform: translateY(-2px); }
.btn-fun:active { transform: translateY(0); }
.btn-outline-fun {
  background: #fff;
  border: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 700;
  border-radius: 999px;
  padding: 10px 26px;
}

/* ---------------- Quiz play screen ---------------- */
.quiz-play-wrap { max-width: 640px; margin: 0 auto; padding-bottom: 40px; }
.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 8px;
  font-weight: 700;
}
.progress-track {
  height: 10px;
  background: #E7E5FA;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 999px;
  transition: width .3s ease;
}
.timer-badge {
  background: #fff;
  border: 2px solid var(--accent);
  color: var(--text);
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.timer-badge.low-time { border-color: #E74C3C; color: #E74C3C; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.06);} }

.question-card {
  background: #fff;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(0,0,0,.07);
}
.question-card img.q-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 16px;
}
.question-text { font-weight: 700; font-size: 1.15rem; margin-bottom: 18px; line-height: 1.4; }

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: #F6F5FF;
  border: 2px solid #ECEAFB;
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all .15s ease;
  color: var(--text);
}
.option-btn:hover { border-color: var(--primary); background: #EFECFF; }
.option-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.option-btn img.opt-image {
  width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
}
.option-letter {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.06);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; flex-shrink: 0;
}
.option-btn.selected .option-letter { background: rgba(255,255,255,.25); }
.option-btn.locked { cursor: default; opacity: 1; }
.option-btn.correct {
  background: #E7F8EE;
  border-color: #34C77B;
  color: #12703F;
}
.option-btn.correct .option-letter { background: #34C77B; color: #fff; }
.option-btn.wrong {
  background: #FDEBEC;
  border-color: #EF4A55;
  color: #8C1A22;
}
.option-btn.wrong .option-letter { background: #EF4A55; color: #fff; }
.answer-feedback {
  margin: -4px 0 14px;
  font-weight: 700;
  font-size: .95rem;
}
.answer-feedback.is-correct { color: #12703F; }
.answer-feedback.is-wrong { color: #8C1A22; }

/* ---------------- Featured quiz slider ---------------- */
.featured-slider { position: relative; overflow: hidden; border-radius: 24px; }
.featured-slider .featured-slide {
  display: none;
}
.featured-slider .featured-slide.active { display: block; }
.featured-slider .slider-dots {
  display: flex; justify-content: center; gap: 8px; margin-top: 12px;
}
.featured-slider .slider-dots button {
  width: 9px; height: 9px; border-radius: 50%; border: none;
  background: #D9D5F5; padding: 0; cursor: pointer;
}
.featured-slider .slider-dots button.active { background: var(--primary); width: 22px; border-radius: 5px; }

.quiz-nav-btns { display: flex; gap: 10px; margin-top: 18px; }
.quiz-nav-btns button { flex: 1; }

/* ---------------- Result page ---------------- */
.result-wrap { max-width: 520px; margin: 30px auto 50px; text-align: center; }
.result-card {
  background: #fff;
  border-radius: 26px;
  padding: 34px 26px;
  box-shadow: 0 10px 30px rgba(0,0,0,.09);
}
.result-emoji { font-size: 3rem; }
.result-score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  margin: 6px 0 0;
}
.result-percent { font-size: 1.4rem; font-weight: 700; color: var(--secondary); margin-bottom: 20px; }
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}
.result-stats .stat {
  background: var(--background);
  border-radius: 14px;
  padding: 12px 6px;
}
.result-stats .stat .num { font-weight: 800; font-size: 1.3rem; }
.result-stats .stat .label { font-size: .75rem; color: #888; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 20px; }

/* ---------------- Misc ---------------- */
.badge-timer { background: #FFF3D6; color: #B8860B; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.empty-state { text-align: center; padding: 60px 20px; color: #999; }

/* ---------------- Responsive tweaks (down to 320px) ---------------- */
@media (max-width: 480px) {
  .hero-featured { padding: 20px; text-align: center; }
  .hero-featured .row { flex-direction: column-reverse; }
  .hero-featured img { margin: 0 auto 14px; }
  .quiz-scroll { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
  .result-score { font-size: 2.3rem; }
  .question-text { font-size: 1.02rem; }
  .site-nav { font-size: .85rem; }
  .live-search-box { padding: 9px 14px; }
  .live-search-input { font-size: .9rem; }
}
@media (max-width: 340px) {
  .quiz-scroll { grid-template-columns: repeat(2, 1fr); }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}

.site-footer {
  background: var(--footer-bg, #2D3436);
  color: var(--footer-text, #fff);
  margin-top: 40px;
}
.site-footer .footer-brand strong { color: var(--footer-text, #fff); }
.footer-muted { color: var(--footer-text, #fff); opacity: .7; }
.site-footer nav a {
  color: var(--footer-text, #fff);
  opacity: .85;
  text-decoration: none;
  font-weight: 600;
}
.site-footer nav a:hover { opacity: 1; color: var(--accent); }

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}
