/* ============================
   JWQuiz — Mobile CSS (Portrait ≤1024px or Phone)
   Premium design: glassmorphism,
   gradient accents, dark mode
   ============================ */

/* ═══════════════════════════════
   1. CSS VARIABLES & DARK MODE
   ═══════════════════════════════ */
:root {
  /* PWA Banner CSS Moved here for reliability */
}

/* ═══════════════════════════════
   PWA INSTALL TOP BANNER
   ═══════════════════════════════ */
#pwa-install-banner {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 9999999 !important; /* Extremely high z-index */
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  transition:
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.35s ease,
    visibility 0.35s ease;
}

#pwa-install-banner.show {
  transform: translateY(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

#pwa-install-banner .pwa-banner-inner {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 10px 12px !important;
  background: var(--gradient-primary) !important;
  box-shadow: 0 4px 20px rgba(108, 63, 197, 0.35) !important;
  flex-wrap: nowrap !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

#pwa-install-banner .pwa-banner-icon {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  border-radius: 6px !important;
  flex-shrink: 0 !important;
  filter: none !important;
  display: block !important;
  object-fit: contain !important;
  margin: 0 !important;
  padding: 0 !important;
}

#pwa-install-banner .pwa-banner-text {
  flex: 1 !important;
  font-family: var(--font) !important;
  font-weight: 700 !important;
  font-size: 0.82rem !important;
  color: #fff !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  min-width: 0 !important;
  text-align: left !important;
}

#pwa-install-banner .pwa-banner-btn-install {
  flex-shrink: 0 !important;
  padding: 6px 14px !important;
  background: rgba(255, 255, 255, 0.2) !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.35) !important;
  border-radius: 50px !important;
  color: #fff !important;
  font-family: var(--font) !important;
  font-weight: 700 !important;
  font-size: 0.78rem !important;
  cursor: pointer !important;
  transition:
    background 0.2s ease,
    transform 0.15s ease !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  line-height: 1.2 !important;
  margin: 0 !important;
}

#pwa-install-banner .pwa-banner-btn-close {
  flex-shrink: 0 !important;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border: none !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  transition: background 0.2s ease !important;
  padding: 0 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  margin-left: 4px !important;
}

#pwa-install-banner .pwa-close-icon {
  width: 12px !important;
  height: 12px !important;
  filter: brightness(0) invert(1) !important;
  display: block !important;
  margin: 0 !important;
}

:root {
  /* Core palette */
  --primary: #6c3fc5;
  --primary-light: #8b6ce0;
  --primary-dark: #4a2494;
  --primary-bg: rgba(108, 63, 197, 0.06);
  --primary-glow: rgba(108, 63, 197, 0.25);

  /* Accent */
  --magenta: #d946ef;
  --magenta-light: rgba(217, 70, 239, 0.1);
  --accent: #e8b931;

  /* Semantic */
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);

  /* Gradients */
  --gradient-primary: linear-gradient(
    135deg,
    #6c3fc5 0%,
    #a855f7 50%,
    #d946ef 100%
  );
  --gradient-text: linear-gradient(
    135deg,
    #8b6ce0 0%,
    #a855f7 50%,
    #d946ef 100%
  );
  --gradient-hero: radial-gradient(
    ellipse at 50% 0%,
    rgba(108, 63, 197, 0.12) 0%,
    transparent 70%
  );
  --gradient-surface: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(255, 255, 255, 0.6) 100%
  );
  --gradient-sidebar: linear-gradient(
    180deg,
    #4a2494 0%,
    #2d1564 50%,
    #1a0d3b 100%
  );

  /* Surfaces */
  --bg: #f5f3fb;
  --bg-alt: #ffffff;
  --bg-body: linear-gradient(160deg, #f5f3fb 0%, #ede8f7 40%, #f0ecf9 100%);
  --bg-waves: url("/assets/img/bg-waves.png");
  --surface: rgba(255, 255, 255, 0.75);
  --surface-hover: rgba(255, 255, 255, 0.9);

  /* Text */
  --text: #1e1433;
  --text-light: #6b6080;
  --text-muted: #9990a8;

  /* Borders & Shadows */
  --border: rgba(108, 63, 197, 0.1);
  --border-hover: rgba(108, 63, 197, 0.25);
  --shadow-sm: 0 2px 8px rgba(108, 63, 197, 0.06);
  --shadow: 0 4px 24px rgba(108, 63, 197, 0.08);
  --shadow-hover: 0 12px 40px rgba(108, 63, 197, 0.14);
  --shadow-glow: 0 0 30px rgba(108, 63, 197, 0.15);

  /* Radii */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  /* Typography */
  --font: "Outfit", sans-serif;

  /* Transition */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-blur: 12px;

  /* Icon */
  --icon-size: 1.1em;
  --icon-filter: brightness(0) saturate(100%);
}

/* ── Dark Mode ─────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #a78bfa;
    --primary-light: #c4b5fd;
    --primary-dark: #7c3aed;
    --primary-bg: rgba(167, 139, 250, 0.08);
    --primary-glow: rgba(167, 139, 250, 0.2);

    --magenta: #e879f9;
    --magenta-light: rgba(232, 121, 249, 0.12);

    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.12);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);

    --gradient-primary: linear-gradient(
      135deg,
      #7c3aed 0%,
      #a855f7 50%,
      #e879f9 100%
    );
    --gradient-text: linear-gradient(
      135deg,
      #c4b5fd 0%,
      #a855f7 50%,
      #e879f9 100%
    );
    --gradient-hero: radial-gradient(
      ellipse at 50% 0%,
      rgba(124, 58, 237, 0.15) 0%,
      transparent 70%
    );
    --gradient-surface: linear-gradient(
      135deg,
      rgba(30, 20, 51, 0.9) 0%,
      rgba(30, 20, 51, 0.6) 100%
    );
    --gradient-sidebar: linear-gradient(
      180deg,
      #2d1564 0%,
      #1a0d3b 50%,
      #0f0822 100%
    );

    --bg: #0f0a1a;
    --bg-alt: #1a1128;
    --bg-body: linear-gradient(160deg, #0f0a1a 0%, #150e26 40%, #110c1f 100%);
    --bg-waves: url("/assets/img/bg-waves.png");
    --surface: rgba(30, 20, 51, 0.7);
    --surface-hover: rgba(30, 20, 51, 0.85);

    --text: #e8e4f0;
    --text-light: #a89fc0;
    --text-muted: #6b5f82;

    --border: rgba(167, 139, 250, 0.12);
    --border-hover: rgba(167, 139, 250, 0.25);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(167, 139, 250, 0.12);

    --glass-bg: rgba(26, 17, 40, 0.7);
    --glass-border: rgba(167, 139, 250, 0.1);
    --glass-blur: 12px;
    --icon-filter: brightness(0) invert(1);
  }
}

/* ═══════════════════════════════
   2. RESET & BASE
   ═══════════════════════════════ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* iOS Button Compatibility */
button {
  -webkit-appearance: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  user-select: none;
  -moz-appearance: none;
  appearance: none;
  background-color: transparent;
}

input,
textarea,
select {
  -webkit-appearance: none;
  border-radius: 4px;
}

html {
  height: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-y: auto;
  overflow-wrap: break-word;
  word-break: break-word;
  background:
    radial-gradient(
      circle at 15% 20%,
      rgba(174, 0, 255, 0.28) 0%,
      transparent 35%
    ),
    radial-gradient(
      circle at 85% 75%,
      rgba(132, 0, 255, 0.22) 0%,
      transparent 35%
    ),
    radial-gradient(
      circle at 50% 50%,
      rgba(75, 0, 130, 0.18) 0%,
      transparent 55%
    ),
    linear-gradient(135deg, #050816 0%, #090d22 30%, #060816 60%, #0b0618 100%);
  background-origin: border-box;
  background-attachment: fixed;
  background-blend-mode: screen, screen, soft-light, normal;
  color: var(--text);
  line-height: 1.6;
  position: relative;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* EFFETTO NEBBIA / ONDE LATERALI */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* LATO SINISTRO */
body::before {
  background:
    radial-gradient(
      circle at 0% 15%,
      rgba(183, 0, 255, 0.28) 0%,
      transparent 28%
    ),
    radial-gradient(
      circle at 10% 80%,
      rgba(140, 0, 255, 0.18) 0%,
      transparent 30%
    );
  filter: blur(60px);
  opacity: 0.9;
}

/* LATO DESTRO */
body::after {
  background:
    radial-gradient(
      circle at 100% 10%,
      rgba(76, 0, 255, 0.22) 0%,
      transparent 25%
    ),
    radial-gradient(
      circle at 100% 85%,
      rgba(183, 0, 255, 0.22) 0%,
      transparent 30%
    );
  filter: blur(70px);
  opacity: 0.85;
}

/* CONTENITORE PRINCIPALE */
.main-container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  /* Occupa tutto lo spazio che body gli dà */
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: visible;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Icon images */
.icon-img {
  width: var(--icon-size);
  height: var(--icon-size);
  vertical-align: middle;
  flex-shrink: 0;
  filter: var(--icon-filter);
}

/* Icons inside white-text contexts: force white */
.btn-start .icon-img,
.btn-go .icon-img,
.btn-next .icon-img,
.btn-submit .icon-img,
.btn.primary .icon-img,
.btn-primary .icon-img,
.btn-result.primary .icon-img,
.lang-btn.active .icon-img,
.diff-btn.selected .icon-img,
.count-btn.selected .icon-img,
.toolbar-btn.active .icon-img,
.filter-btn.active .icon-img,
.step-num .icon-img {
  filter: brightness(0) invert(1);
}

/* Danger icon filter */
.toolbar-btn.danger .icon-img {
  filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(1352%)
    hue-rotate(337deg);
}

/* Answer correct/wrong icon colors */
.answer-btn.correct .icon-img {
  filter: brightness(0) saturate(100%) invert(58%) sepia(62%) saturate(504%)
    hue-rotate(95deg);
}
.answer-btn.wrong .icon-img {
  filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(1352%)
    hue-rotate(337deg);
}

/* Quiz score icon: green */
.quiz-score .icon-img {
  filter: brightness(0) saturate(100%) invert(58%) sepia(62%) saturate(504%)
    hue-rotate(95deg);
}

/* Vote button icons: keep original */
.vote-btn .icon-img {
  filter: none;
}

/* Don't filter actual content images */
.question-image,
.question-thumb,
.image-preview {
  filter: none !important;
  border-radius: var(--radius-sm);
}

/* ═══════════════════════════════
   3. TOP BAR (Glass)
   ═══════════════════════════════ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.top-bar.nav-hidden {
  transform: translateY(-100%);
}

body.quiz-page.quiz-fullscreen .top-bar {
  display: none;
}

body.quiz-page.quiz-fullscreen .site-footer {
  display: none;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--primary);
  font-weight: 900;
  font-size: 1.2rem;
}

.logo-link .icon-img {
  width: 1.4em;
  height: 1.4em;
  filter: none;
}

.logo-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 1px 2px rgba(108, 63, 197, 0.15));
}

.lang-switch {
  display: flex;
  gap: 4px;
}

.lang-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.8rem;
  border: 1.5px solid var(--border);
  color: var(--text-light);
  background: var(--surface);
  transition: var(--transition);
}

.lang-btn.active {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(108, 63, 197, 0.25);
}

/* ═══════════════════════════════
   4. MAIN
   ═══════════════════════════════ */
/* Main normale (home, altre pagine) */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 80px;
  flex: 1;
  width: 100%;
  overflow-y: auto;
}

/* Quiz page: il body è già height:100dvh flex-column.
   Qui basta sovrascrivere il main per togliere padding/scroll extra */
body.quiz-page {
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

body.quiz-page main {
  flex: 1;
  min-height: 0;
  max-width: 100%;
  width: 100%;
  padding: 8px 10px !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.quiz-page .site-footer {
  display: none !important;
}

body.quiz-page.quiz-fullscreen main {
  padding-top: 12px;
}

/* ═══════════════════════════════
   5. HERO
   ═══════════════════════════════ */
.hero {
  text-align: center;
  padding: 12px 0 8px;
  position: relative;
}

.hero::before {
  content: "";
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(300px, 100%);
  height: 200px;
  background: radial-gradient(
    ellipse,
    rgba(108, 63, 197, 0.1) 0%,
    transparent 70%
  );
  pointer-events: none;
}

.hero > * {
  position: relative;
}

.hero-icon {
  width: 18rem !important;
  max-width: 85vw !important;
  height: auto !important;
  display: block;
  margin: -40px auto 4px;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 16px var(--primary-glow));
}

.hero h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: #fff;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.hero-title-light {
  color: #e5d0ff;
}

.hero-title-white {
  color: #ffffff;
}

.hero-title-gradient {
  background: linear-gradient(to right, #a855f7 0%, #7dd3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
  line-height: 1.3;
  padding: 0 10px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hero p {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 24px;
  padding: 0 12px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* ═══════════════════════════════
   6. HOW SECTION
   ═══════════════════════════════ */
.how-section {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 28px 18px;
  margin-bottom: 30px;
  box-shadow: var(--shadow);
}

.how-section h3 {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 20px;
}

.how-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.how-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.how-step .step-num {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(108, 63, 197, 0.25);
}

.how-step p {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* ═══════════════════════════════
   7. BUTTONS
   ═══════════════════════════════ */
.btn-start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  font-size: 1.2rem;
  font-weight: 800;
  font-family: var(--font);
  color: #fff;
  background: var(--gradient-primary);
  background-size: 200% 200%;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  animation:
    gradient-shift 4s ease infinite,
    pulse-glow 2.5s ease-in-out infinite;
  box-shadow: 0 4px 18px rgba(108, 63, 197, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-start::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.15),
    transparent
  );
  transform: skewX(-20deg);
  animation: shimmer 3s ease-in-out infinite;
}

/* ═══════════════════════════════
   8. CONFIG
   ═══════════════════════════════ */
.config-section {
  display: none;
  padding: 24px 0 36px;
  margin-top: 0;
  position: relative;
}

/* Removed top bar gradient */

.config-section.active {
  display: block;
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.config-section h3 {
  text-align: center;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 32px;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.3px;
  filter: drop-shadow(0 2px 8px rgba(108, 63, 197, 0.2));
}

.config-label {
  display: block;
  text-align: center;
  font-weight: 400;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text);
}

/* Removed pink line */

.difficulty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 32px;
  padding: 0 4px;
}

#mode-grid .mode-btn {
  padding: 14px 6px;
}

#mode-grid .mode-btn .diff-title {
  font-size: 0.85rem;
}

#mode-grid .mode-btn .diff-desc {
  font-size: 0.65rem;
}

.diff-btn {
  padding: 16px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-family: var(--font);
  font-weight: 900;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-spring);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.diff-text-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.diff-title {
  font-size: 1rem;
  font-weight: 800;
  transition: color 0.3s ease;
}

.title-easy {
  color: #d946ef;
}
.title-medium {
  color: #60a5fa;
}
.title-hard {
  color: #c084fc;
}
.title-mixed {
  color: #e2e8f0;
}

.diff-btn.selected .diff-title {
  color: #fff;
}

.diff-desc {
  font-size: 0.65rem;
  color: var(--text-light);
  font-weight: 600;
  line-height: 1.15;
}

.diff-btn.selected .diff-desc {
  color: rgba(255, 255, 255, 0.85);
}

.diff-btn .icon-img {
  width: 2.2rem;
  height: 2.2rem;
}

.diff-btn.selected {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(108, 63, 197, 0.4);
  transform: scale(1.02);
}

.diff-btn[data-diff="easy"].selected {
  background: linear-gradient(135deg, #16a34a, #22c55e, #4ade80);
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.diff-btn[data-diff="medium"].selected {
  background: linear-gradient(135deg, #d97706, #f59e0b, #fbbf24);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.diff-btn[data-diff="hard"].selected {
  background: linear-gradient(135deg, #dc2626, #ef4444, #f87171);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.count-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 40px;
}

.start-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
  align-items: center;
  justify-content: center;
}

.btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-light);
  background: var(--primary-bg);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: var(--transition);
}

.btn-outline:active {
  transform: scale(0.97);
  background: var(--primary-bg);
}

.home-join-wrapper {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  margin-bottom: 0;
  text-align: center;
  width: 100%;
  padding: 0 20px;
  transition:
    opacity 0.4s ease,
    max-height 0.4s ease,
    margin 0.4s ease;
}

.home-join-wrapper.show {
  opacity: 1;
  max-height: 100px;
  margin-bottom: 30px;
  margin-top: 5px;
}

@media (min-width: 480px) {
  .start-actions {
    flex-direction: row;
  }
}

.count-btn {
  width: 46px;
  height: 46px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-spring);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1;
  flex: 0 0 auto;
}

.count-btn .icon-img {
  width: 1.25em;
  height: 1.25em;
}

.count-btn[data-count="all"] .icon-img {
  width: 0.9em;
  height: 0.9em;
}

.count-btn[data-count="all"] span {
  font-size: 0.7rem;
  font-weight: 600;
}

.count-btn.selected {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(108, 63, 197, 0.4);
  transform: scale(1.04);
}

.btn-go {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  padding: 11px;
  font-size: 1rem;
  font-weight: 900;
  font-family: var(--font);
  color: #fff;
  background: var(--gradient-primary);
  background-size: 200% 200%;
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(108, 63, 197, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
  animation: gradient-shift 3s ease infinite;
}

.btn-go .icon-img {
  width: 1.3em;
  height: 1.3em;
}

.btn-go::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transform: skewX(-20deg);
  animation: shimmer 2.5s ease-in-out infinite;
}

.btn-go:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  animation: none;
}

.btn-go:disabled::after {
  display: none;
}

/* ═══════════════════════════════
   9. QUIZ
   ═══════════════════════════════ */
.quiz-container {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden; /* clip children so toolbar is never pushed off-screen */
}

.quiz-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.quiz-progress-text {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.82rem;
  white-space: nowrap;
}

.quiz-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  background-size: 200% 100%;
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  animation: gradient-shift 3s ease infinite;
}

.quiz-score {
  font-weight: 700;
  color: var(--success);
  font-size: 0.8rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ═══════════════════════════════
   QUIZ SPLIT LAYOUT (MOBILE: verticale)
   ═══════════════════════════════ */
.quiz-main-split {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.quiz-image-panel {
  flex: 0 1 auto;
  width: 100%;
  max-width: 32vh;
  aspect-ratio: 1 / 1;
  min-height: 0;
  margin: 0 auto 6px auto;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: max-width 0.3s ease;
}

.quiz-question-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.question-card {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: transparent !important;
  border: none;
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: var(--shadow);
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain; /* Torna a contain per non tagliare */
  object-position: center;
  display: block;
  filter: none !important;
  border-radius: 24px; /* Arrotondamento diretto sull'immagine */
  transition: opacity 0.3s ease;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

body.quiz-page.quiz-fullscreen .quiz-image-panel {
  height: auto;
  max-height: none;
  aspect-ratio: 1 / 1;
  max-width: 48vh !important; /* Forza una dimensione maggiore in fullscreen */
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: #f3e8ff;
  text-align: center;
  line-height: 1.35;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(108, 63, 197, 0.2));
}

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.answer-btn {
  padding: 14px 8px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--primary);
  font-family: var(--font);
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  position: relative;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.answer-btn.correct {
  border: 4px solid #00e676;
  background: var(--surface);
  color: var(--text);
  animation: bounceIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.answer-btn.wrong {
  border: 4px solid #ff1744;
  background: var(--surface);
  color: var(--text);
  animation: shake 0.5s ease;
}

.answer-btn.show-correct {
  border: 4px solid #00e676;
  background: var(--surface);
  color: var(--text);
}

.answer-btn.disabled {
  cursor: default;
  opacity: 0.55;
}

.answer-btn.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: transparent !important;
}

/* === CANVAS WATER FILL (mobile) — container only, animation handled by JS canvas === */
.answer-btn .water-fill {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
  z-index: 0;
}

.answer-text {
  position: relative;
  z-index: 2;
  transition:
    color 0.2s ease,
    text-shadow 0.2s ease;
}

/* White + shadow when water is filling */
.answer-btn.counting .answer-text,
.answer-btn.selected .answer-text {
  color: #fff;
  text-shadow:
    0 0 12px rgba(255, 255, 255, 0.6),
    0 1px 6px rgba(0, 0, 0, 0.55);
}

/* ═══════════════════════════════
   10. QUIZ TOOLBAR — nuovo design
   ═══════════════════════════════ */

/* Riga vote buttons — centrata sopra la progress bar */
.quiz-vote-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-shrink: 0;
  padding: 2px 0;
}

/* Vote buttons — grandi, quadrati, con glow neon */
.vote-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: var(--transition-spring);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.vote-btn .icon-img {
  width: 1.8em;
  height: 1.8em;
  filter: none;
}

/* Like — verde neon */
.vote-btn-like {
}
.vote-btn-like .icon-img {
  filter: brightness(0) saturate(100%) invert(62%) sepia(54%) saturate(500%)
    hue-rotate(95deg) brightness(1.1);
}
.vote-btn-like:active,
.vote-btn-like.voted {
  border-color: #22c55e;
  box-shadow:
    0 0 20px rgba(34, 197, 94, 0.7),
    0 0 6px rgba(34, 197, 94, 0.5),
    inset 0 0 12px rgba(34, 197, 94, 0.15);
  background: rgba(34, 197, 94, 0.12);
}

/* Dislike — rosso neon */
.vote-btn-dislike {
}
.vote-btn-dislike .icon-img {
  filter: brightness(0) saturate(100%) invert(45%) sepia(80%) saturate(600%)
    hue-rotate(337deg) brightness(1.1);
}
.vote-btn-dislike:active,
.vote-btn-dislike.voted {
  border-color: #ef4444;
  box-shadow:
    0 0 20px rgba(239, 68, 68, 0.7),
    0 0 6px rgba(239, 68, 68, 0.5),
    inset 0 0 12px rgba(239, 68, 68, 0.15);
  background: rgba(239, 68, 68, 0.12);
}

/* Toolbar — contenitore pill glassmorphism */
.quiz-toolbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 10px;
  background: rgba(26, 17, 40, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(167, 139, 250, 0.12);
  border-radius: 20px;
}

/* Singolo pulsante toolbar */
.toolbar-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 12px 4px 6px 4px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: #ffffff;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.58rem;
  letter-spacing: 0.01em;
  line-height: 1.2;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  min-width: 0;
}

.toolbar-btn .icon-img {
  width: 1.9em;
  height: 1.9em;
  /* rosa chiaro #f9a8d4 */
  filter: brightness(0) saturate(100%) invert(75%) sepia(30%) saturate(600%)
    hue-rotate(295deg) brightness(1.1);
}

.toolbar-btn span {
  color: #ffffff;
  font-size: 0.6rem;
  text-align: center;
  line-height: 1.15;
  max-width: 44px;
  word-break: break-word;
  white-space: normal;
}

/* Active state — pulsante evidenziato (es. audio muted) */
.toolbar-btn.active,
.toolbar-btn.voted {
  background: rgba(108, 63, 197, 0.2);
  border-color: rgba(108, 63, 197, 0.45);
  box-shadow:
    0 0 10px rgba(108, 63, 197, 0.3),
    inset 0 0 6px rgba(108, 63, 197, 0.1);
}
.toolbar-btn.active .icon-img,
.toolbar-btn.voted .icon-img {
  filter: brightness(0) saturate(100%) invert(56%) sepia(60%) saturate(400%)
    hue-rotate(230deg) brightness(1.3);
}
.toolbar-btn.active span,
.toolbar-btn.voted span {
  color: #c4b5fd;
}

/* Nascondi i nuovi pulsanti voto dalla barra su mobile verticale */
#btn-like-toolbar,
#btn-dislike-toolbar {
  display: none;
}

/* Ferma Quiz — mantiene rosso vivo */
.toolbar-btn-stop {
  border-color: rgba(239, 68, 68, 0.18);
}

.toolbar-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.08);
}

.toolbar-divider {
  display: none;
}

.vote-btns {
  display: none; /* rimpiazzati da .quiz-vote-row */
}

/* ═══════════════════════════════
   11. FEEDBACK
   ═══════════════════════════════ */
.feedback-area {
  text-align: center;
  padding: 4px 0 0 0;
  display: none;
  margin-top: 8px;
}

.feedback-area.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feedback-text:empty {
  display: none;
}

#btn-show-correct {
  display: none !important;
}

.feedback-text.correct {
  color: var(--success);
}
.feedback-text.wrong {
  color: var(--danger);
}

.btn-show-correct,
.btn-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
}

.btn-show-correct {
  border: 1.5px solid var(--primary);
  background: var(--surface);
  color: var(--primary);
}

.btn-next {
  border: none;
  background: var(--gradient-primary);
  color: #fff;
  font-size: 0.95rem;
  box-shadow: 0 3px 14px rgba(108, 63, 197, 0.2);
  padding: 11px;
}

/* ═══════════════════════════════
   HEIGHT-BASED RESPONSIVITY (Short screens)
   ═══════════════════════════════ */

/* Schermi medi (es. iPhone 12/13/14, Pixel 7) */
@media screen and (max-height: 850px) {
  .quiz-image-panel {
    max-width: 28vh;
  }
  .question-text {
    font-size: 1.15rem;
    margin-bottom: 6px;
  }
  .answer-btn {
    min-height: 54px;
    padding: 12px 8px;
    font-size: 1rem;
  }
}

/* Schermi piccoli (es. iPhone SE, schermi con tastiera/barre browser) */
@media screen and (max-height: 740px) {
  .quiz-image-panel {
    max-width: 25vh;
    margin-bottom: 8px;
  }
  .question-card {
    padding: 8px;
    gap: 6px;
  }
  .question-text {
    font-size: 1.05rem;
    margin-bottom: 4px;
  }
  .answers-grid {
    gap: 4px;
  }
  .answer-btn {
    min-height: 46px;
    padding: 8px 6px;
    font-size: 0.92rem;
  }
  .quiz-vote-row {
    gap: 12px;
    padding: 0;
  }
  .vote-btn {
    width: 48px;
    height: 48px;
  }
  .quiz-toolbar {
    padding: 6px 8px;
  }
  .toolbar-btn {
    padding: 8px 4px 4px 4px;
  }
  .feedback-area {
    margin-top: 4px;
    gap: 6px;
  }
  .btn-next {
    padding: 10px;
  }
}

/* Schermi ultra-compatti */
@media screen and (max-height: 600px) {
  .quiz-image-panel {
    max-width: 20vh;
    margin-bottom: 4px;
  }
  .question-text {
    font-size: 0.95rem;
  }
  .answer-btn {
    min-height: 38px;
    font-size: 0.85rem;
  }
  .quiz-vote-row {
    gap: 8px;
  }
  .vote-btn {
    width: 40px;
    height: 40px;
  }
  .quiz-toolbar {
    padding: 4px 6px;
  }
  .toolbar-btn span {
    display: none; /* Nascondi etichette per risparmiare spazio */
  }
  .toolbar-btn {
    padding: 6px;
  }
}

/* ═══════════════════════════════
   12. MODAL
   ═══════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 10, 26, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  width: 92%;
  max-width: 480px;
  max-height: 85vh;
  box-shadow: var(--shadow-hover);
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal h3 {
  color: var(--primary);
  margin-bottom: 14px;
  font-size: 1.1rem;
  font-weight: 800;
}

.modal textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  margin-bottom: 14px;
}

.modal textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.btn-cancel,
.btn-submit {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
}

.btn-cancel {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn-submit {
  border: none;
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(108, 63, 197, 0.2);
}

/* ═══════════════════════════════
   13. RESULTS
   ═══════════════════════════════ */
.results-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-body);
  z-index: 300;
  flex-direction: column;
  align-items: center;
  /* flex-start instead of center: centering a flex container with
       overflow-y:auto hides the top overflow and makes it unreachable by
       scrolling. margin:auto on .results-card handles centering when there
       is spare space. */
  justify-content: flex-start;
  padding: 24px 16px;
  overflow-y: auto;
  box-sizing: border-box;
}

.results-overlay.active {
  display: flex;
  animation: fadeIn 0.5s ease;
}

.results-card {
  text-align: center;
  max-width: 520px;
  width: 100%;
  /* auto margins center the card vertically when the overlay has spare
       space, but let it scroll naturally from the top when content is taller
       than the viewport. */
  margin: auto;
  position: relative;
  z-index: 10;
}

.results-icon {
  width: 4rem !important;
  height: 4rem !important;
  display: block;
  margin: 0 auto 16px;
  animation: float 2s ease-in-out infinite;
  filter: var(--icon-filter) drop-shadow(0 4px 16px var(--primary-glow));
}

.results-card h2 {
  font-size: 1.8rem;
  font-weight: 900;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 10px rgba(108, 63, 197, 0.2));
}

.results-card .results-msg {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 24px;
}

.results-percentage {
  font-size: 3.2rem;
  font-weight: 900;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 22px;
  filter: drop-shadow(0 4px 12px rgba(108, 63, 197, 0.25));
}

.results-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
}

.stat-box .stat-value {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--primary);
  display: block;
}

.stat-box .stat-label {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 600;
}

.stat-box.correct {
  border-color: rgba(34, 197, 94, 0.2);
}
.stat-box.correct .stat-value {
  color: var(--success);
}
.stat-box.wrong {
  border-color: rgba(239, 68, 68, 0.2);
}
.stat-box.wrong .stat-value {
  color: var(--danger);
}
.stat-box.skipped {
  border-color: rgba(245, 158, 11, 0.2);
}
.stat-box.skipped .stat-value {
  color: var(--warning);
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-home-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-result {
  padding: 14px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-result.primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 3px 14px rgba(108, 63, 197, 0.25);
}

.btn-result.secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1.5px solid var(--border);
}

/* ═══════════════════════════════
   14. FOOTER
   ═══════════════════════════════ */
.site-footer {
  text-align: center;
  padding: 10px 10px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-footer.nav-hidden {
  transform: translateY(100%);
}

.footer-link {
  color: var(--primary);
  font-weight: 600;
}

/* ═══════════════════════════════
   15. ADMIN (Mobile & Tablet)
   ═══════════════════════════════ */
.admin-layout {
  display: block;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar-toggle {
  display: flex;
  position: fixed;
  top: 15px;
  right: 15px; /* Moved to right to be less intrusive */
  z-index: 10001;
  width: 46px;
  height: 46px;
  background: var(--gradient-primary);
  border: none;
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(108, 63, 197, 0.4);
}

.hamburger {
  width: 22px;
  height: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 3px;
  background: #fff;
  border-radius: 4px;
  transition: 0.3s;
}

/* Open state logic - sync with body class from admin.js */
body.sidebar-open .admin-sidebar {
  transform: translateX(0);
  visibility: visible;
}

body.sidebar-open .admin-layout::after {
  opacity: 1;
  pointer-events: auto;
}

body.sidebar-open .hamburger span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
body.sidebar-open .hamburger span:nth-child(2) {
  opacity: 0;
}
body.sidebar-open .hamburger span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--gradient-sidebar);
  z-index: 10000;
  padding: 24px 0;
  transform: translateX(-100%);
  visibility: hidden;
  transition:
    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.4s;
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

.admin-sidebar .admin-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 15px;
  font-weight: 900;
  font-size: 1.2rem;
  color: #fff;
  text-decoration: none;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  gap: 6px;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 12px;
  text-decoration: none;
  transition: var(--transition);
}

.admin-nav a.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.admin-content {
  padding: 70px 16px 40px; /* Padding top for toggle */
  transition: margin 0.3s;
  width: 100%;
  box-sizing: border-box;
}

/* Backdrop for closing menu (if applied via JS later, but layout should be clean) */
.admin-layout::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
}

@media screen and (max-width: 480px) {
  .admin-sidebar {
    width: 85%;
  }
  .admin-content {
    padding: 65px 12px 30px;
  }
}

.admin-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.admin-header h1 {
  font-size: 1.3rem;
  color: var(--primary);
  font-weight: 800;
}

/* Admin page header */
.admin-page-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.admin-page-header h1 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

/* Admin alerts */
.admin-alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 0.85rem;
  animation: slideUp 0.3s ease;
}

.admin-alert.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.admin-alert.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.admin-alert.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Admin filter bar */
.admin-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-count {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--primary-bg);
  padding: 3px 10px;
  border-radius: 16px;
}

/* Admin empty */
.admin-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
}

/* Admin table wrap */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-alt);
}

/* Dashboard cards */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.dash-card {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
  text-align: center;
}

.dash-card .dash-icon {
  margin-bottom: 6px;
}

.dash-card .dash-icon .icon-img {
  width: 1.4em;
  height: 1.4em;
}

.dash-card .dash-value {
  font-size: 1.5rem;
  font-weight: 900;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dash-card .dash-label {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 600;
}

/* Stats summary */
.stats-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
  text-align: center;
}

.stat-card .stat-icon {
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 1.4rem;
  font-weight: 900;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .stat-label {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 600;
  margin-top: 4px;
}

/* Admin card */
.admin-card {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  margin-bottom: 16px;
}

.admin-card h2 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Difficulty accuracy */
.difficulty-accuracy-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.difficulty-accuracy-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}

.diff-header {
  flex-shrink: 0;
}

.accuracy-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 900;
  color: var(--color);
  background: conic-gradient(
    var(--color) calc(var(--accuracy) * 1%),
    var(--border) calc(var(--accuracy) * 1%)
  );
  position: relative;
  flex-shrink: 0;
}

.accuracy-circle::before {
  content: "";
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-alt);
}

.accuracy-circle span {
  position: relative;
  z-index: 1;
}

.diff-stats {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 600;
}

/* Chart container */
.chart-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

/* Card layout on small screens (Refined Compact) */
@media screen and (max-width: 1024px) {
  .admin-table thead {
    display: none;
  }
  .admin-table,
  .admin-table tbody,
  .admin-table tr {
    display: block;
    width: 100%;
  }

  .admin-table tr {
    margin-bottom: 24px;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-xl);
    background: var(--surface);
    padding: 12px;
    box-shadow: var(--shadow-sm);
    display: grid !important;
    grid-template-columns: 120px repeat(5, auto) 1fr; /* Larger image + compact info + spacer */
    grid-auto-rows: min-content;
    column-gap: 24px; /* Increased space between info items on the left */
    row-gap: 8px;
    position: relative;
    width: 100%;
    overflow: hidden;
  }

  .admin-table td.question-cell,
  .question-cell-inner {
    display: contents !important;
  }

  .admin-table td:not(.question-cell):not(.id-cell):not(.actions-cell) {
    grid-column: span 1;
    display: block !important;
    border: none !important;
    padding: 0 !important;
    border-bottom: none !important;
    font-size: 0.72rem;
    text-align: left !important;
    align-items: flex-start !important;
    min-width: 0;
    overflow: hidden;
  }

  .admin-table td:not(.question-cell):not(.actions-cell) > * {
    text-align: left !important;
  }

  .admin-table td::before {
    content: attr(data-label);
    display: block !important;
    font-weight: 800;
    color: var(--text-muted);
    font-size: 0.55rem;
    text-transform: uppercase;
    margin-bottom: 2px;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
  }

  .question-thumb,
  .question-thumb-placeholder {
    grid-column: 1;
    grid-row: 1 / 4; /* Spans title and stats rows */
    width: 120px !important;
    height: 120px !important;
    border-radius: var(--radius-lg);
    margin: 0 !important;
    object-fit: contain !important;
    background: var(--bg-alt);
    display: block !important;
    border: 1.5px solid var(--border);
  }
  .question-thumb-placeholder {
    display: flex !important;
    background: var(--primary-bg);
    align-items: center;
    justify-content: center;
    border: 1.5px dashed var(--border);
  }

  .question-cell-text {
    grid-column: 2 / 8; /* Spans all data columns */
    grid-row: 1;
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--primary) !important;
    white-space: normal !important;
    margin-bottom: 4px;
    padding-top: 2px;
    padding-right: 12px;
  }

  .question-cell-text span[title] {
    display: block !important;
    margin-top: 2px;
    font-size: 0.75rem !important;
    opacity: 0.7;
  }

  /* Actions row under everything */
  .admin-table td.actions-cell {
    grid-column: 2 / 8;
    padding: 10px 0 0 0 !important;
    width: 100% !important;
    border-bottom: none !important;
  }
  .admin-table td.actions-cell::before {
    display: none !important;
  }
  .actions-cell-inner {
    display: flex !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    width: 100%;
  }
  .actions-cell .btn.icon-only {
    flex: 1;
    max-width: 110px;
    height: 40px !important;
    border-radius: var(--radius-lg) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Small screens / Portrait: stats on two rows */
  @media screen and (max-width: 600px) {
    .admin-table tr {
      column-gap: 12px !important;
    }
    .admin-table td.difficulty-cell {
      grid-column: 2 / 5 !important;
      grid-row: 2 !important;
    }
    .admin-table td.type-cell {
      grid-column: 5 / 8 !important;
      grid-row: 2 !important;
    }
    .admin-table td.ans-count-cell {
      grid-column: 2 / 4 !important;
      grid-row: 3 !important;
    }
    .admin-table td.shown-cell {
      grid-column: 4 / 6 !important;
      grid-row: 3 !important;
    }
    .admin-table td.feedback-cell {
      grid-column: 6 / 8 !important;
      grid-row: 3 !important;
    }

    .question-thumb,
    .question-thumb-placeholder {
      width: 80px !important;
      height: 80px !important;
      grid-row: 1 / 5 !important;
    }

    .admin-table td:not(.question-cell):not(.actions-cell) {
      text-align: left !important;
      display: flex !important;
      flex-direction: column !important;
      align-items: flex-start !important;
      padding: 0 !important;
      border: none !important;
    }
    .actions-cell-inner {
      justify-content: flex-start !important;
    }
    .admin-table-empty-row td {
      grid-column: 1 / 8 !important;
      text-align: left !important;
      padding: 16px !important;
    }
  }

  /* Generic Table Layout (For Tables without Image/Stats Grid) */
  .generic-table tr {
    display: grid !important;
    grid-template-columns: 1fr auto;
    gap: 16px !important;
    align-items: start;
    padding: 20px !important;
  }

  .generic-table td {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    width: 100% !important;
    padding: 0 !important;
    border: none !important;
  }

  .generic-table td::before {
    margin-bottom: 4px !important;
    font-size: 0.65rem !important;
  }

  .generic-table td.id-cell {
    grid-column: 1 !important;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
  }

  .generic-table td.status-cell {
    grid-column: 2 !important;
    align-items: flex-end !important;
  }

  .generic-table td.status-cell::before {
    display: none !important; /* Hide label, badge is enough */
  }

  .generic-table td.question-cell,
  .generic-table td.comment-cell {
    grid-column: 1 / -1 !important;
    font-size: 1.05rem;
    color: var(--text);
    line-height: 1.5;
    background: var(--bg-alt);
    padding: 16px !important;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border) !important;
    box-sizing: border-box !important;
    word-break: break-word;
  }

  .generic-table td.date-cell {
    grid-column: 1 / -1 !important;
    opacity: 0.8;
  }

  .generic-table td.actions-cell {
    grid-column: 1 / -1 !important;
    margin-top: 8px !important;
    border-top: 1px solid var(--border) !important;
    padding-top: 16px !important;
  }

  .generic-table .actions-cell-inner {
    width: 100%;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 12px !important;
  }

  .generic-table .actions-cell .btn {
    flex: 1;
    max-width: 140px;
  }
}

/* Enhanced Search & Filters for Mobile */
@media screen and (max-width: 1024px) {
  .qs-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    padding: 0 4px;
  }
  .qs-search-wrap {
    position: relative;
    width: 100%;
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-xl);
  }
  .qs-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 1.2em;
    opacity: 0.6;
    z-index: 10;
    filter: var(--icon-filter);
  }
  .qs-search-input {
    width: 100% !important;
    padding: 14px 16px 14px 48px !important;
    font-size: 1rem;
    background: var(--surface) !important;
    border: 2px solid var(--border) !important;
    border-radius: var(--radius-xl) !important;
    color: var(--text) !important;
    transition: all 0.3s ease;
  }
  .qs-search-input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px var(--primary-bg);
    outline: none;
  }

  .qs-filter-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
  }

  .qs-filter-pills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  .qs-filter-pills::-webkit-scrollbar {
    display: none;
  }

  .qs-pill {
    padding: 10px 18px !important;
    font-size: 0.85rem;
    font-weight: 800;
    border-radius: 100px !important;
    background: var(--surface) !important;
    border: 2px solid var(--border) !important;
    color: var(--text-light) !important;
    white-space: nowrap;
    transition: all 0.2s ease;
  }
  .qs-pill.active {
    background: var(--gradient-primary) !important;
    color: #fff !important;
    border-color: transparent !important;
    box-shadow: 0 4px 12px var(--primary-glow);
  }
  .qs-pill:active {
    transform: scale(0.96);
  }
  .qs-pill:hover {
    border-color: var(--primary) !important;
  }

  .qs-count {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--primary);
    background: var(--primary-bg);
    padding: 6px 14px;
    border-radius: 12px;
    align-self: flex-start;
  }

  .admin-page-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 16px !important;
    text-align: center;
    margin-bottom: 30px !important;
  }
  .admin-page-header h1 {
    white-space: normal !important;
    font-size: 1.5rem !important;
  }
}

.question-cell {
  max-width: 150px;
}

.question-thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 8px;
  margin-right: 4px;
  vertical-align: middle;
  border: 1px solid var(--border);
}

.question-thumb-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--primary-bg);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-comment {
  max-width: 140px;
  word-break: break-word;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Admin form */
.admin-form {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 24px 16px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-grid-3 {
  display: flex;
  flex-direction: column;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.form-group textarea,
.form-group select,
.form-group input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
}

.form-group input[type="file"] {
  padding: 6px;
  color: var(--text-light);
}

.form-group input[type="file"]::file-selector-button {
  background: var(--surface);
  color: var(--primary);
  border: 1.5px solid var(--border);
  padding: 6px 14px;
  border-radius: calc(var(--radius) - 2px);
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 12px;
}

.form-group input[type="file"]::file-selector-button:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.answer-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  margin-bottom: 16px;
}

.answer-row.is-correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.answer-row input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-alt);
}

.answer-row input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.answer-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.answer-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.answer-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.answer-label .answer-num {
  background: var(--primary-bg);
  color: var(--primary);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

.answer-correct-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-light);
  padding: 5px 12px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--bg-alt);
  white-space: nowrap;
}

.answer-correct-label.active {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.answer-correct-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--success);
}

.answer-correct-label.active input[type="checkbox"] {
  accent-color: #fff;
}

.remove-answer-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}

.remove-answer-btn img {
  width: 16px;
  height: 16px;
}

#addAnswerBtn {
  width: 100%;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

.current-image-preview {
  margin-top: 8px;
}

/* ═══════════════════════════════
   16. GENERAL BUTTONS
   ═══════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn.primary,
.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(108, 63, 197, 0.2);
}

.btn.secondary,
.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1.5px solid var(--border);
}

.btn.danger,
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn.small,
.btn-sm {
  padding: 7px 12px;
  font-size: 0.75rem;
}

.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
}

.filter-btn.active {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
}

/* ═══════════════════════════════
   17. BADGES
   ═══════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 16px;
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-easy,
.badge-success {
  background: var(--success-bg);
  color: var(--success);
}
.badge-medium,
.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}
.badge-hard {
  background: var(--danger-bg);
  color: var(--danger);
}
.badge-pending {
  background: var(--warning-bg);
  color: var(--warning);
}
.badge-resolved {
  background: var(--success-bg);
  color: var(--success);
}

.image-preview {
  max-width: 150px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 8px;
}

/* ═══════════════════════════════
   18. ALERTS
   ═══════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 0.85rem;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ═══════════════════════════════
   19. LOGIN
   ═══════════════════════════════ */
.login-container {
  max-width: 100%;
  margin: 40px 16px;
  padding: 36px 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow: var(--shadow-hover);
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(108, 63, 197, 0.06) 0%,
    transparent 50%
  );
  pointer-events: none;
}

.login-container h1 {
  color: var(--primary);
  margin-bottom: 6px;
  font-size: 1.4rem;
  font-weight: 900;
  position: relative;
}

.login-icon {
  width: 3.5rem !important;
  height: 3.5rem !important;
  display: block;
  margin: 0 auto 14px;
  filter: var(--icon-filter) drop-shadow(0 4px 12px var(--primary-glow));
  position: relative;
}

/* ═══════════════════════════════
   20. CHART
   ═══════════════════════════════ */
.chart-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
}

.chart-card h3 {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-chart.vertical {
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-start;
  padding-top: 35px;
  gap: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bar-label {
  width: 80px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
  text-align: right;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.bar-track {
  flex: 1;
  height: 22px;
  background: var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 12px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 0.65rem;
  color: #fff;
  font-weight: 700;
}

/* Vertical bars (stats) */
.bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-width: 32px;
  height: 100%;
}

.bar-item .bar-fill {
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--gradient-primary);
  position: relative;
  min-height: 3px;
}

.bar-value {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--primary);
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
}

.bar-item .bar-label {
  width: auto;
  text-align: center;
  font-size: 0.55rem;
  margin-top: 4px;
}

/* ═══════════════════════════════
   21. CONFETTI
   ═══════════════════════════════ */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ═══════════════════════════════
   22. ANIMATIONS
   ═══════════════════════════════ */
@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 4px 18px rgba(108, 63, 197, 0.3);
  }
  50% {
    box-shadow:
      0 4px 18px rgba(108, 63, 197, 0.3),
      0 0 0 10px rgba(108, 63, 197, 0);
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(108, 63, 197, 0.35);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(108, 63, 197, 0);
  }
}

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

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

@keyframes bounceIn {
  0% {
    transform: scale(0.85);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
}

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

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes shimmer {
  0% {
    left: -60%;
  }
  50%,
  100% {
    left: 120%;
  }
}

@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ═══════════════════════════════
   23. UTILITIES
   ═══════════════════════════════ */
.text-center {
  text-align: center;
}

/* ═══════════════════════════════
   24. RESULTS — VIEWPORT-HEIGHT RESPONSIVE (mobile)
   Shrink typography and spacing on short mobile viewports so the results
   card always fits or scrolls gracefully without overflowing.
   ═══════════════════════════════ */
@media (max-height: 680px) {
  .results-overlay {
    padding: 16px 16px;
  }
  .results-percentage {
    font-size: 2.6rem;
    margin-bottom: 14px;
  }
  .results-card h2 {
    font-size: 1.5rem;
  }
  .results-card .results-msg {
    font-size: 0.92rem;
    margin-bottom: 16px;
  }
  .results-stats {
    gap: 8px;
    margin-bottom: 16px;
  }
  .stat-box {
    padding: 12px 10px;
  }
  .stat-box .stat-value {
    font-size: 1.4rem;
  }
}

@media (max-height: 520px) {
  .results-overlay {
    padding: 10px 16px;
  }
  .results-icon {
    width: 2.8rem !important;
    height: 2.8rem !important;
    margin-bottom: 8px;
  }
  .results-percentage {
    font-size: 2rem;
    margin-bottom: 8px;
  }
  .results-card h2 {
    font-size: 1.25rem;
    margin-bottom: 4px;
  }
  .results-card .results-msg {
    font-size: 0.85rem;
    margin-bottom: 10px;
  }
  .results-stats {
    gap: 6px;
    margin-bottom: 12px;
  }
  .stat-box {
    padding: 8px 8px;
  }
  .stat-box .stat-value {
    font-size: 1.2rem;
  }
  .stat-box .stat-label {
    font-size: 0.68rem;
  }
  .results-actions {
    gap: 8px;
  }
  .btn-result {
    padding: 11px;
    font-size: 0.92rem;
  }
}

/* ============================
   Optimizzazione Mobile Landscape
   ============================ */
@media (max-height: 600px) and (orientation: landscape) {
  body.quiz-page main {
    padding: 4px 8px !important;
    height: 100dvh;
    overflow: hidden;
  }
  .quiz-container {
    gap: 4px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .quiz-main-split {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 100%;
    width: 100%;
    position: relative;
  }
  body.quiz-page .quiz-image-panel,
  body.quiz-fullscreen .quiz-image-panel,
  body.quiz-page.quiz-fullscreen .quiz-image-panel {
    position: relative;
    flex: 1;
    height: 100%;
    max-width: none !important;
    aspect-ratio: auto;
    margin: 0;
    padding: 24px;
    border-radius: 20px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .question-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 24px !important;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    -webkit-backface-visibility: hidden;
    -webkit-transform: translate3d(0, 0, 0);
  }
  .quiz-question-panel {
    position: relative;
    width: 50%;
    max-width: 440px;
    z-index: 10;
    background: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 16px 24px 16px 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Changed from center to prevent clipping */
    overflow-y: auto;
    border-radius: 0;
  }
  .question-card {
    padding: 0;
    gap: 12px;
    flex: 0 1 auto;
    background: transparent !important;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow-y: visible;
    margin: auto 0;
  }
  .question-text {
    font-size: 1.4rem;
    margin-bottom: 12px;
    line-height: 1.2;
  }
  .answers-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .answer-btn {
    padding: 10px 16px;
    min-height: 60px;
    font-size: 1.15rem;
  }
  .quiz-vote-row {
    display: none !important;
  }
  .quiz-progress {
    margin: 4px 0 0;
    padding: 4px 8px;
    gap: 8px;
    flex-shrink: 0;
  }
  .quiz-progress-text {
    font-size: 0.85rem;
  }
  .quiz-toolbar {
    padding: 8px 12px;
    gap: 8px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 16px;
    display: flex !important;
  }
  #btn-like-toolbar,
  #btn-dislike-toolbar {
    display: flex !important;
  }
  .toolbar-btn {
    padding: 4px 2px;
    border-radius: 8px;
  }
  .toolbar-btn span {
    display: none;
  }
  .toolbar-btn .icon-img {
    width: 2.2em;
    height: 2.2em;
  }
  .site-footer,
  .top-bar {
    display: none !important;
  }

  /* Schermo Intero Immersivo in Landscape */
  body.quiz-fullscreen main {
    padding: 0 !important;
  }
  body.quiz-fullscreen .quiz-container {
    gap: 0;
    padding: 0;
    height: 100dvh;
    position: relative;
  }
  body.quiz-fullscreen .quiz-main-split {
    border-radius: 0;
    padding-bottom: 90px;
  }
  body.quiz-fullscreen .quiz-image-panel {
    border-radius: 20px;
  }
  body.quiz-fullscreen .question-image {
    border-radius: 20px !important;
  }
  body.quiz-fullscreen .quiz-question-panel {
    border-radius: 0;
  }
  body.quiz-fullscreen .quiz-progress {
    position: absolute;
    bottom: 54px;
    left: 10px;
    right: 10px;
    z-index: 100;
    background: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 4px 10px;
  }
  body.quiz-fullscreen .quiz-toolbar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 101;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    margin-bottom: 0;
    border-radius: 20px 20px 0 0;
    padding: 10px;
  }
}
.mt-20 {
  margin-top: 20px;
}
.mb-20 {
  margin-bottom: 20px;
}
.hidden {
  display: none !important;
}

/* ============================
   Stats Premium Filter Mobile
   ============================ */
.stats-header-flex {
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  gap: 12px;
}
.stats-date-filter {
  width: 100%;
}
.filter-glass-pill {
  flex-direction: column;
  align-items: stretch;
  border-radius: var(--radius-lg);
  padding: 12px;
  gap: 10px;
}
.filter-glass-pill .form-select.filter-select {
  width: 100%;
  border-radius: var(--radius);
  background-color: var(--surface);
  padding: 10px 14px;
  height: 44px;
}
.custom-dates-wrapper {
  flex-direction: column;
  width: 100%;
  border-radius: var(--radius);
  padding: 8px;
  gap: 6px;
}
.filter-glass-pill .form-input.filter-date {
  width: 100%;
  border-radius: var(--radius);
  background-color: var(--surface);
  padding: 10px 12px;
  height: 44px;
}
.filter-submit {
  width: 100%;
  justify-content: center;
  border-radius: var(--radius);
  height: 44px;
}

/* Specific scaling for short mobile screens to ensure the results card fits */
@media (max-height: 740px) {
  .results-card {
    transform: scale(0.95);
    transform-origin: center;
    margin: auto;
  }
}
@media (max-height: 640px) {
  .results-card {
    transform: scale(0.85);
  }
}
@media (max-height: 540px) {
  .results-card {
    transform: scale(0.75);
  }
}
@media (max-height: 440px) {
  .results-card {
    transform: scale(0.65);
  }
}

/* Tablet Portrait optimization (600px - 1024px) */
@media screen and (min-width: 600px) {
  main {
    padding: 32px 20px 100px;
    max-width: 920px;
  }

  .hero-icon {
    width: 22rem !important;
    margin: -50px auto 10px;
  }

  .hero h1 {
    font-size: 2.4rem;
    margin-bottom: 12px;
  }

  .hero h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
  }

  .hero p {
    font-size: 1rem;
    max-width: 600px;
    margin: 0 auto 32px;
  }

  .difficulty-grid {
    gap: 16px;
    margin-bottom: 44px;
  }

  .diff-btn {
    padding: 28px 20px;
  }

  .diff-title {
    font-size: 1.2rem;
  }

  .count-grid {
    gap: 16px;
    margin-bottom: 48px;
  }

  .count-btn {
    width: 64px;
    height: 64px;
    font-size: 1.1rem;
  }

  .site-footer {
    padding: 16px 20px;
    font-size: 0.8rem;
  }
}

/* ═══════════════════════════════
   24. QUIZ SETTINGS SECTION
   ═══════════════════════════════ */
.settings-section {
  max-width: 440px;
  margin: 0 auto 10px;
  padding: 0;
  width: calc(100% - 32px);
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  margin: 0 auto;
  padding: 12px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.settings-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.settings-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
  font-size: 0.75rem;
}

.settings-body {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  margin-top: 8px;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 360px;
  width: 100%;
  justify-self: center;
}

.settings-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light);
}

.settings-field select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6080' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.settings-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.settings-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-input-row select {
  flex: 1;
}

.settings-preview-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.settings-preview-btn:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.settings-preview-btn .icon-img {
  width: 20px;
  height: 20px;
  filter: var(--icon-filter, none);
}

.settings-field-duration {
  grid-column: 1 / -1;
  max-width: 240px;
  justify-self: center;
  width: 100%;
}

/* ── Inline file input for custom sounds ── */
.settings-file-input {
  font-size: 0.7rem;
  padding: 3px 5px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  max-width: 120px;
}

/* ═══════════════════════════════
   25. DUO CARDS SECTION (Suggest + FAQ)
   ═══════════════════════════════ */
.cards-duo-section {
  max-width: 100%;
  margin: 30px 16px 20px;
  padding: 0;
}

.cards-duo-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.duo-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: var(--transition);
}

.duo-card-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.duo-card-link:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-hover);
}

.duo-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.duo-card-content h3 {
  color: var(--primary);
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.duo-card-content p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 16px;
  line-height: 1.5;
}

.duo-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 10px 20px;
  text-decoration: none;
}

/* ═══════════════════════════════
   TOUCH DEVICE OPTIMIZATION (NO HOVER CAPABILITY)
   ═══════════════════════════════ */
@media (hover: none) {
  /* Disable hover effects on pure touch devices */
  button:hover,
  a:hover {
    transform: none;
  }

  /* Ensure :active works properly on touch */
  button:active,
  .vote-btn:active,
  .toolbar-btn:active,
  .answer-btn:active {
    outline: 2px solid rgba(167, 139, 250, 0.4);
    outline-offset: 2px;
  }
}

/* ============================
   NEW LEADERBOARD (HOST/MULTI) - MOBILE
   ============================ */
#leaderboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 25, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--font, "Outfit", sans-serif);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  padding: 10px;
  overflow-y: auto;
  overflow-x: hidden;
}
#leaderboard-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.lb-inner {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
  padding: clamp(10px, 3vh, 20px) 10px;
  min-height: min-content;
}
.lb-title {
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  font-weight: 900;
  background: linear-gradient(135deg, #f1c40f, #e67e22, #e74c3c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: clamp(10px, 4vh, 30px);
  text-align: center;
  filter: drop-shadow(0 4px 10px rgba(241, 196, 15, 0.3));
  transform: translateY(-20px);
  opacity: 0;
  animation: lbFadeInDown 0.6s 0.2s forwards;
}
.lb-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(5px, 2vw, 10px);
  margin-bottom: clamp(10px, 4vh, 30px);
  margin-top: clamp(10px, 4vh, 30px);
}
.lb-podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  opacity: 0;
  transform: translateY(30px);
  animation: lbFadeInUp 0.6s var(--delay) forwards;
}
.lb-podium-first {
  margin: 0 5px;
}
.lb-avatar {
  width: clamp(50px, 12vh, 80px);
  height: clamp(50px, 12vh, 80px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.2rem, 3vh, 1.8rem);
  font-weight: 800;
  color: #fff;
  margin-bottom: clamp(5px, 2vh, 10px);
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  padding: 4px;
  box-sizing: border-box;
}
.lb-podium-first .lb-avatar {
  width: clamp(70px, 16vh, 110px);
  height: clamp(70px, 16vh, 110px);
  font-size: clamp(1.6rem, 4vh, 2.5rem);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.lb-medal {
  position: absolute;
  bottom: -8px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: bold;
  color: #000;
  border: 2px solid rgba(255, 255, 255, 0.5);
  z-index: 2;
}
.lb-podium-first .lb-medal {
  width: 24px;
  height: 24px;
  font-size: 0.8rem;
  bottom: -8px;
  right: -2px;
}
.lb-score {
  font-size: clamp(1rem, 2.5vh, 1.2rem);
  font-weight: 900;
  margin-bottom: 5px;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}
.lb-podium-first .lb-score {
  font-size: clamp(1.2rem, 3vh, 1.5rem);
  color: #f1c40f;
}
.lb-name {
  font-size: clamp(1rem, 2.5vh, 1.3rem);
  font-weight: 700;
  margin-bottom: clamp(5px, 2vh, 10px);
  color: rgba(255, 255, 255, 0.9);
}
.lb-bar {
  width: 70px;
  border-radius: 10px 10px 0 0;
  height: 0; /* Animated via scaleY */
  transform-origin: bottom;
  animation: lbBarGrow 1s var(--delay) cubic-bezier(0.175, 0.885, 0.32, 1.275)
    forwards;
  position: relative;
  overflow: hidden;
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.2);
}
.lb-podium-first .lb-bar {
  width: 90px;
}
.lb-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.3) 0%,
    transparent 100%
  );
}

.lb-rest {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 30px;
}
.lb-row {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transform: translateX(-20px);
  animation: lbSlideIn 0.5s var(--delay) forwards;
}
.lb-row-rank {
  width: 25px;
  font-weight: 800;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.5);
}
.lb-row-avatar {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  margin-right: 12px;
  padding: 4px;
  box-sizing: border-box;
}
.lb-row-name {
  flex: 1;
  font-weight: 600;
  font-size: 1.25rem;
}
.lb-row-score {
  font-weight: 800;
  font-size: 1.2rem;
  color: #a855f7;
}

.lb-continue-btn {
  padding: 12px 30px;
  border-radius: 25px;
  background: #a855f7;
  color: white;
  border: none;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(20px);
  animation: lbFadeInUp 0.5s 1.2s forwards;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}
.lb-continue-btn:hover {
  transform: translateY(-2px) scale(1.05);
}
.lb-continue-btn .icon-img {
  width: 1.2rem;
  height: 1.2rem;
}

@keyframes lbFadeInDown {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes lbFadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes lbSlideIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes lbBarGrow {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

/* ═══════════════════════════════
   PWA SAFE AREA — iOS / Android
   L'altezza reale è gestita da var(--app-height) settata via JS
   ═══════════════════════════════ */

body.quiz-page {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  body.quiz-page {
    height: var(--app-height, 100dvh);
    overflow: hidden;
  }
}

/* Landscape fullscreen: toolbar ha position:absolute bottom:0 */
@media (max-height: 600px) and (orientation: landscape) {
  body.quiz-fullscreen .quiz-toolbar {
    bottom: env(safe-area-inset-bottom, 0px);
  }

  body.quiz-fullscreen .quiz-progress {
    bottom: calc(54px + env(safe-area-inset-bottom, 0px));
  }
}

/* Notch landscape (iPhone) */
body.quiz-page main,
body.quiz-page .quiz-container {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ═══════════════════════════════
   26. FAQ SECTION / PAGE
   ═══════════════════════════════ */
.faq-section {
  width: calc(100% - 32px);
  margin: 30px auto 20px;
  padding: 0;
}

.faq-page-section {
  width: calc(100% - 32px);
  margin: 16px auto 40px;
}

.faq-hero {
  width: calc(100% - 32px);
  margin: 0 auto;
  padding: 16px 0 8px;
  text-align: center;
}

.faq-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 16px;
  transition: color 0.2s;
}

.faq-back-link:hover {
  color: var(--primary);
}

.faq-hero h1 {
  font-size: 1.7rem;
  font-weight: 800;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.faq-hero-sub {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.faq-page-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-page-cta {
  text-align: center;
  margin-top: 30px;
  padding: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
}

.faq-page-cta p {
  color: var(--text-light);
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.faq-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-container h2 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.faq-subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 24px;
}

.faq-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}

.faq-question-btn {
  width: 100%;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

.faq-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  flex-shrink: 0;
  transition: var(--transition);
}

.faq-icon {
  width: 14px;
  height: 14px;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-card.open {
  border-color: var(--primary-light);
}

.faq-card.open .faq-icon-wrapper {
  background: var(--primary);
  color: #ffffff;
}

.faq-card.open .faq-icon {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-answer-content {
  padding: 0 20px 18px;
}

.faq-answer p {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.5;
}
