/* ===== مختبر هجرة الأيونات — الأنماط ===== */
:root {
  --bg: #0B1220;
  --card: #131C2F;
  --text: #E8EEF9;
  --muted: #94A3B8;
  --accent: #2DD4BF;
  --purple: #A855F7;
  --blue: #3B82F6;
  --orange: #F97316;
  --red: #EF4444;
  --gray: #64748B;
  --ion-clear: #CBD5E1;
  --top-h: 56px;
  --bot-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius: 14px;
  --font: "IBM Plex Sans Arabic", system-ui, sans-serif;
}

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

html {
  font-size: 17px;
  direction: rtl;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  overflow: hidden;
  height: 100dvh;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

button, input { font-family: inherit; }

/* ===== Canvas ===== */
#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  outline: none;
}

/* ===== Loader ===== */
.loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.6s ease, visibility 0.6s;
}
.loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loader-atom {
  position: relative;
  width: 80px;
  height: 80px;
  margin-bottom: 1.5rem;
}
.nucleus {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 20px var(--accent);
}
.orbit {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}
.o2 { border-top-color: var(--blue); animation-duration: 1.6s; animation-direction: reverse; transform: rotateX(60deg); }
.o3 { border-top-color: var(--orange); animation-duration: 2s; transform: rotateY(60deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  font-size: 1.05rem;
  color: var(--muted);
  letter-spacing: 0;
}

/* ===== Gates ===== */
.gates {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: auto;
}
.gate {
  position: absolute;
  left: 0; right: 0;
  background: rgba(11, 18, 32, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.7s ease,
              backdrop-filter 0.7s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gate-top {
  top: 0;
  height: 55%;
  border-bottom: 1px solid rgba(45, 212, 191, 0.15);
}
.gate-bottom {
  bottom: 0;
  height: 45%;
  flex-direction: column;
  gap: 1.2rem;
  border-top: 1px solid rgba(45, 212, 191, 0.15);
}
.gates.open .gate-top { transform: translateY(-110%); opacity: 0; }
.gates.open .gate-bottom { transform: translateY(110%); opacity: 0; }
.gates.open { pointer-events: none; }

.gate-content { text-align: center; padding: 1rem; position: relative; }
.gate-greeting {
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  font-weight: 700;
  background: linear-gradient(135deg, #2DD4BF, #A855F7, #3B82F6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(45, 212, 191, 0.35);
  margin-bottom: 0.4rem;
}
.wave { display: inline-block; animation: wave 1.5s ease-in-out infinite; }
@keyframes wave {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(20deg); }
  75% { transform: rotate(-10deg); }
}
.gate-subtitle {
  font-size: clamp(0.95rem, 3vw, 1.2rem);
  color: var(--muted);
  font-weight: 400;
}
.floating-ions {
  position: absolute;
  inset: -40px;
  pointer-events: none;
  overflow: hidden;
}
.floating-ions span {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  opacity: 0.7;
  animation: floatIon 4s ease-in-out infinite;
}
@keyframes floatIon {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.5; }
  50% { transform: translateY(-18px) scale(1.2); opacity: 1; }
}

/* Pull handle */
.pull-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  width: min(280px, 80vw);
}
.pull-track {
  width: 100%;
  height: 56px;
  background: rgba(19, 28, 47, 0.8);
  border: 1px solid rgba(45, 212, 191, 0.3);
  border-radius: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(45, 212, 191, 0.1), 0 0 30px rgba(45, 212, 191, 0.08);
}
.pull-handle {
  position: absolute;
  top: 4px; bottom: 4px;
  right: 4px;
  width: 48px;
  border-radius: 24px;
  cursor: grab;
  touch-action: none;
  z-index: 2;
}
.pull-handle:active { cursor: grabbing; }
.handle-metal {
  display: block;
  width: 100%; height: 100%;
  border-radius: inherit;
  background: linear-gradient(145deg, #94A3B8, #475569, #64748B);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.3);
}
.handle-glow {
  position: absolute;
  inset: -4px;
  border-radius: 28px;
  background: radial-gradient(circle, rgba(45,212,191,0.5), transparent 70%);
  animation: pulseGlow 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulseGlow {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
.pull-chevrons {
  display: flex;
  gap: 2px;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 700;
  animation: chevronPulse 1.2s ease-in-out infinite;
}
.pull-chevrons span { display: inline-block; }
@keyframes chevronPulse {
  0%, 100% { opacity: 0.4; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(-6px); }
}
.pull-hint {
  font-size: 0.95rem;
  color: var(--muted);
}
.enter-link {
  font-size: 0.85rem;
  color: rgba(232, 238, 249, 0.45);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  transition: color 0.2s;
}
.enter-link:hover, .enter-link:focus-visible {
  color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== App shell ===== */
.app {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.app > * { pointer-events: auto; }
.app.hidden { display: none; }

.top-bar {
  height: calc(var(--top-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 12px;
  background: linear-gradient(180deg, rgba(11,18,32,0.92), rgba(11,18,32,0.6));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  flex-shrink: 0;
}
.app-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
}
.icon-btn {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover, .icon-btn:focus-visible {
  background: rgba(45, 212, 191, 0.12);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* TikTok pill */
.tiktok-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 10px;
  border-radius: 20px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: rgba(19, 28, 47, 0.7);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(45, 212, 191, 0.15);
  animation: pillPulse 3s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pillPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(45,212,191,0.12); }
  50% { box-shadow: 0 0 22px rgba(45,212,191,0.3); }
}
.tiktok-pill:hover, .tiktok-pill:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.tiktok-fallback {
  font-size: 1.1rem;
  color: var(--accent);
}
.tiktok-label { white-space: nowrap; }

/* Side tools */
.side-tools {
  position: absolute;
  left: 10px;
  bottom: calc(var(--bot-h) + var(--safe-b) + 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
}
.tool-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(19, 28, 47, 0.85);
  border: 1px solid rgba(45, 212, 191, 0.2);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.tool-btn:hover, .tool-btn:focus-visible, .tool-btn[aria-pressed="true"] {
  background: rgba(45, 212, 191, 0.18);
  border-color: var(--accent);
  outline: none;
}

/* Bottom bar */
.bottom-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bot-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 12px;
  background: linear-gradient(0deg, rgba(11,18,32,0.95), rgba(11,18,32,0.7));
  backdrop-filter: blur(10px);
  z-index: 50;
}
.bar-btn {
  min-width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(45, 212, 191, 0.15);
  border: 1px solid rgba(45, 212, 191, 0.3);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0 14px;
  flex-shrink: 0;
}
.bar-btn:hover, .bar-btn:focus-visible {
  background: rgba(45, 212, 191, 0.28);
  outline: 2px solid var(--accent);
}
.controls-btn { min-width: 72px; }
.timer-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.timer-label, .timer-max {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: rgba(100, 116, 139, 0.35);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  border-radius: 3px;
  transition: width 0.15s linear;
}

/* Toast */
.toast {
  position: absolute;
  top: calc(var(--top-h) + var(--safe-t) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(19, 28, 47, 0.95);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: var(--text);
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Info panel */
.info-panel {
  position: absolute;
  bottom: calc(var(--bot-h) + var(--safe-b) + 8px);
  left: 12px; right: 12px;
  max-height: 35vh;
  overflow-y: auto;
  background: rgba(19, 28, 47, 0.95);
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  z-index: 45;
  backdrop-filter: blur(12px);
}
.info-panel.hidden { display: none; }
.info-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.3rem;
  padding-left: 28px;
}
.info-role { font-size: 0.95rem; margin-bottom: 0.4rem; }
.info-discuss {
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid rgba(100,116,139,0.3);
  padding-top: 0.5rem;
  margin-top: 0.3rem;
}
.panel-close {
  position: absolute;
  top: 10px; left: 10px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(100,116,139,0.2);
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 2;
}
.panel-close:hover, .panel-close:focus-visible {
  background: rgba(239, 68, 68, 0.3);
  outline: 2px solid var(--red);
}

/* Bottom sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet.hidden { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.sheet-panel {
  position: relative;
  max-height: 45vh;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid rgba(45, 212, 191, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1;
  padding-bottom: var(--safe-b);
  overflow: hidden;
}
.sheet-handle {
  width: 40px; height: 4px;
  background: rgba(100,116,139,0.5);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(100,116,139,0.2);
  flex-shrink: 0;
}
.sheet-header h2 { font-size: 1.05rem; font-weight: 600; }
.sheet-body {
  overflow-y: auto;
  padding: 0.8rem 1rem 1.2rem;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.slider-group {
  margin-bottom: 1rem;
}
.slider-group label {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.slider-group input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(100,116,139,0.35);
  border-radius: 3px;
  outline: none;
}
.slider-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(45,212,191,0.4);
}
.compound-group { margin-bottom: 1rem; }
.group-label {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 0.45rem 0.9rem;
  border-radius: 20px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  background: rgba(100,116,139,0.2);
  color: var(--text);
  min-height: 40px;
}
.chip-purple { border-color: var(--purple); }
.chip-blue { border-color: var(--blue); }
.chip-orange { border-color: var(--orange); }
.chip-mix { border-color: var(--accent); }
.chip[aria-pressed="true"], .chip:hover {
  background: rgba(45, 212, 191, 0.2);
  border-color: var(--accent);
}
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 1rem;
}
.action-btn {
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(100,116,139,0.35);
  background: rgba(19,28,47,0.8);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  min-height: 44px;
  text-align: center;
}
.action-btn:hover, .action-btn:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.action-btn[data-state="off"] {
  opacity: 0.55;
}
.sheet-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-primary, .btn-secondary, .btn-danger {
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}
.btn-primary {
  background: var(--accent);
  color: #0B1220;
}
.btn-secondary {
  background: rgba(45, 212, 191, 0.15);
  color: var(--text);
  border: 1px solid rgba(45, 212, 191, 0.3);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-primary:hover, .btn-secondary:hover, .btn-danger:hover {
  filter: brightness(1.1);
}

/* Side menu */
.side-menu {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: flex-start; /* RTL: panel from right visually = flex-start in RTL */
}
.side-menu.hidden { display: none; }
.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.menu-panel {
  position: relative;
  width: min(300px, 85vw);
  height: 100%;
  background: var(--card);
  border-left: 1px solid rgba(45, 212, 191, 0.15);
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid rgba(100,116,139,0.2);
}
.menu-header h2 { font-size: 1.1rem; }
.menu-list {
  list-style: none;
  padding: 0.5rem 0;
  overflow-y: auto;
  flex: 1;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0.9rem 1.2rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  text-align: right;
  min-height: 52px;
}
.menu-item:hover, .menu-item:focus-visible {
  background: rgba(45, 212, 191, 0.1);
  outline: none;
}
.menu-icon { font-size: 1.2rem; width: 28px; text-align: center; }

/* Full screens */
.full-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
}
.full-screen.hidden { display: none; }
.fs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(100,116,139,0.25);
  flex-shrink: 0;
}
.fs-header h2 { font-size: 1.15rem; font-weight: 600; }
.fs-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  -webkit-overflow-scrolling: touch;
}
.prep-list {
  list-style: disc;
  padding-right: 1.4rem;
  margin-bottom: 1.2rem;
  color: var(--muted);
}
.checklist {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.checklist label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}
.checklist input[type="checkbox"] {
  width: 20px; height: 20px;
  margin-top: 3px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.safety-note {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  font-size: 0.92rem;
  line-height: 1.7;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(100,116,139,0.2);
  font-size: 0.98rem;
  cursor: pointer;
}
.toggle-row input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--accent);
}
.env-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 1rem;
}
.env-chip {
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  border: 1px solid rgba(100,116,139,0.4);
  background: rgba(19,28,47,0.8);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  min-height: 48px;
}
.env-chip.active, .env-chip:hover {
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.15);
}

/* Quiz */
.quiz-progress {
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(100,116,139,0.2);
}
.quiz-bar {
  flex: 1;
  height: 6px;
  background: rgba(100,116,139,0.3);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.quiz-bar::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  width: var(--pct, 0%);
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}
#quizCounter {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}
.quiz-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
}
.quiz-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(45, 212, 191, 0.15);
}
.quiz-q {
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: 1rem;
  line-height: 1.7;
}
.quiz-answers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quiz-ans {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(100,116,139,0.35);
  background: rgba(19,28,47,0.6);
  color: var(--text);
  font-size: 0.95rem;
  text-align: right;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.quiz-ans:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.08);
}
.quiz-ans.correct {
  border-color: #22C55E;
  background: rgba(34, 197, 94, 0.15);
  animation: correctPop 0.4s ease;
}
.quiz-ans.wrong {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.12);
  animation: shake 0.4s ease;
}
@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.quiz-explain {
  margin-top: 1rem;
  padding: 0.9rem;
  background: rgba(45, 212, 191, 0.08);
  border-radius: 10px;
  border-right: 3px solid var(--accent);
  font-size: 0.92rem;
  line-height: 1.7;
  animation: slideUp 0.35s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.quiz-next {
  margin-top: 1rem;
  width: 100%;
}
.quiz-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.2rem;
  text-align: center;
}
.quiz-result.hidden { display: none; }
.result-score {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.result-pct {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.8rem;
}
.result-stars {
  font-size: 1.8rem;
  letter-spacing: 4px;
  margin-bottom: 0.6rem;
}
.result-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}
.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* TikTok thanks */
.tiktok-thanks {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(16px);
}
.tiktok-thanks.hidden { display: none; }
.thanks-card {
  text-align: center;
  padding: 2rem;
}
.thanks-text {
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 600;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #A855F7, #EC4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Mute */
.mute-btn {
  position: absolute;
  top: calc(var(--top-h) + var(--safe-t) + 8px);
  left: 12px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(100,116,139,0.3);
  background: rgba(19,28,47,0.7);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 55;
  display: flex; align-items: center; justify-content: center;
}

/* No WebGL */
.no-webgl {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}
.no-webgl.hidden { display: none; }

/* Light theme */
body.light {
  --bg: #F0F4F8;
  --card: #FFFFFF;
  --text: #1E293B;
  --muted: #64748B;
}
body.light .top-bar,
body.light .bottom-bar {
  background: linear-gradient(180deg, rgba(240,244,248,0.95), rgba(240,244,248,0.7));
}
body.light .gate {
  background: rgba(240, 244, 248, 0.6);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden { display: none !important; }

/* Confetti container */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 2px;
  animation: confettiFall 2.5s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
