/* ============================================
   Da Vinci Mind - Design System
   ============================================ */

:root {
  --primary: #7B6EF6;
  --primary-light: #9B92FF;
  --secondary: #5B8DEF;
  --accent: #4DDFFF;
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
  --bg-dark: #0B0B12;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --bg-surface: #101018;
  --text-primary: #F0F0F5;
  --text-secondary: #8E8EA0;
  --text-muted: #55556A;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-full: 50px;
  --shadow: 0 8px 40px rgba(0,0,0,0.4);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ---- Screen transitions ---- */
.screen {
  min-height: 100%;
  padding: 24px 20px;
  animation: fadeIn 0.4s ease;
  display: flex;
  flex-direction: column;
}

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

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-200px) rotate(720deg); opacity: 0; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes numberSpin {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes ringFill {
  from { stroke-dashoffset: 283; }
  /* to value set inline */
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108,99,255,0.4), 0 8px 32px rgba(108,99,255,0.3); }
  50%       { box-shadow: 0 0 0 12px rgba(108,99,255,0), 0 8px 40px rgba(108,99,255,0.5); }
}

@keyframes confettiPop {
  0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(-120px) rotate(540deg) scale(0.5); opacity: 0; }
}

@keyframes streakBounce {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25%  { transform: scale(1.3) rotate(-10deg); }
  75%  { transform: scale(1.3) rotate(10deg); }
}

@keyframes xpFloat {
  0%   { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-40px); opacity: 0; }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes shine {
  0%   { left: -100%; }
  100% { left: 200%; }
}

/* ── Staggered card entrance ── */
.card-enter { animation: fadeInUp 0.4s ease both; }
.card-enter:nth-child(1) { animation-delay: 0.05s; }
.card-enter:nth-child(2) { animation-delay: 0.10s; }
.card-enter:nth-child(3) { animation-delay: 0.15s; }
.card-enter:nth-child(4) { animation-delay: 0.20s; }
.card-enter:nth-child(5) { animation-delay: 0.25s; }
.card-enter:nth-child(6) { animation-delay: 0.30s; }
.card-enter:nth-child(n+7) { animation-delay: 0.35s; }

/* ── Active press feedback ── */
.tappable { transition: transform 0.1s, opacity 0.1s; cursor: pointer; }
.tappable:active { transform: scale(0.96); opacity: 0.85; }

/* ── Start button glow pulse ── */
.start-btn-ring { animation: pulseGlow 2.5s ease-in-out infinite !important; }

/* ── Celebration confetti ── */
.confetti-container {
  position: fixed; inset: 0; pointer-events: none; z-index: 9998; overflow: hidden;
}
.confetti-piece {
  position: absolute; top: 0; width: 10px; height: 10px; border-radius: 2px;
  animation: confettiPop 1.2s ease-out forwards;
}

/* ── Number pop (score reveal) ── */
.score-reveal {
  display: inline-block;
  animation: fadeInScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Weekly ring ── */
.weekly-ring-svg circle.ring-track {
  fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 8;
}
.weekly-ring-svg circle.ring-fill {
  fill: none; stroke-width: 8; stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.4,0,0.2,1);
}

/* ── Progress bar animated fill ── */
.progress-bar__fill {
  animation: progressFill 0.8s ease both;
}
@keyframes progressFill {
  from { width: 0 !important; }
}

/* ---- Typography ---- */
h1 { font-size: 28px; font-weight: 800; line-height: 1.2; }
h2 { font-size: 22px; font-weight: 700; line-height: 1.3; }
h3 { font-size: 18px; font-weight: 600; }
p { color: var(--text-secondary); line-height: 1.6; font-size: 15px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 32px;
  border: none;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
}
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid rgba(108, 99, 255, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-large {
  padding: 20px 48px;
  font-size: 18px;
  border-radius: var(--radius-full);
}

.btn-block { width: 100%; }

.btn-icon {
  width: 48px; height: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
}

.card-glow {
  box-shadow: 0 0 40px rgba(123, 110, 246, 0.08);
  border: 1px solid rgba(123, 110, 246, 0.15);
}

/* ---- Inputs ---- */
.input {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: var(--transition);
}
.input:focus { border-color: var(--primary); }
.input::placeholder { color: var(--text-muted); }

/* ---- Progress bar ---- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ---- Circular timer ---- */
.timer-circle {
  position: relative;
  width: 80px;
  height: 80px;
}
.timer-circle svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}
.timer-circle__bg {
  fill: none;
  stroke: var(--bg-card);
  stroke-width: 4;
}
.timer-circle__fill {
  fill: none;
  stroke: url(#timerGrad);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.timer-circle__text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}
.badge-primary { background: rgba(108, 99, 255, 0.2); color: var(--primary-light); }
.badge-success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

/* ---- Chip select ---- */
.chip-group { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 10px 20px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.chip.active {
  background: rgba(108, 99, 255, 0.2);
  border-color: var(--primary);
  color: var(--primary-light);
}

/* ---- Stat box ---- */
.stat-box {
  text-align: center;
  padding: 16px;
}
.stat-box__value {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-box__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- Grid helpers ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.mt-auto { margin-top: auto; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

/* ---- Splash / Logo ---- */
.logo-container {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  position: relative;
}
.logo-container svg { width: 100%; height: 100%; }

/* ---- Onboarding ---- */
.onboarding-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-card);
  transition: var(--transition);
}
.onboarding-dot.active {
  width: 24px;
  border-radius: 4px;
  background: var(--primary);
}

/* ---- Home screen ---- */
.start-btn-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 24px 0;
}
.start-btn-ring {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--primary), var(--secondary), var(--accent), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 4s ease-in-out infinite;
  cursor: pointer;
  box-shadow: 0 0 60px rgba(123, 110, 246, 0.2), inset 0 0 30px rgba(0,0,0,0.3);
}
.start-btn-inner {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 800;
  font-size: 20px;
  transition: var(--transition);
  letter-spacing: 2px;
}
.start-btn-ring:active .start-btn-inner {
  transform: scale(0.95);
}
.start-btn-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---- Streak flame ---- */
.streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
}
.streak-flame { font-size: 22px; }

/* ---- Week chart ---- */
.week-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 80px;
  gap: 6px;
  padding: 0 4px;
}
.week-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  background: var(--bg-card);
  min-height: 4px;
  transition: var(--transition);
}
.week-bar.filled {
  background: linear-gradient(to top, var(--primary), var(--accent));
}
.week-labels {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px 0;
}
.week-labels span {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Game area ---- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
}
.game-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
.game-level {
  font-size: 12px;
  color: var(--text-muted);
}
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  position: relative;
  width: 100%;
  max-width: 100%;
  padding: 0 8px;
  overflow: hidden;
}
.game-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 64px;
  z-index: 100;
  pointer-events: none;
}
.game-feedback.show {
  animation: popIn 0.4s ease forwards;
}

/* ---- N-Back grid ---- */
.nback-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 240px;
  height: 240px;
}
.nback-cell {
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.05);
  transition: var(--transition);
}
.nback-cell.active {
  background: var(--primary);
  box-shadow: 0 0 20px rgba(108, 99, 255, 0.5);
}
.nback-buttons {
  display: flex;
  gap: 16px;
  margin-top: 32px;
}
.nback-btn {
  padding: 16px 32px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 2px solid rgba(108, 99, 255, 0.3);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.nback-btn:active { background: var(--primary); }
.nback-btn.correct { border-color: var(--success); background: rgba(16,185,129,0.2); }
.nback-btn.wrong { border-color: var(--danger); background: rgba(239,68,68,0.2); }

/* ---- Stroop ---- */
.stroop-word {
  font-size: 64px;
  font-weight: 900;
  text-align: center;
  margin-bottom: 28px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  filter: saturate(1.4) brightness(1.1);
}
.stroop-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}
.stroop-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255,255,255,0.18);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.stroop-option:active { transform: scale(0.95); }
.stroop-swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  flex-shrink: 0;
}

/* ---- Speed / UFOV ---- */
.speed-display {
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid rgba(108,99,255,0.2);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.speed-center {
  font-size: 48px;
  transition: opacity 0.1s;
}
.speed-target {
  position: absolute;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: opacity 0.1s;
}
.speed-sectors {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 300px;
  margin-top: 24px;
}
.speed-sector {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
}
.speed-sector:active { background: var(--primary); }

/* ---- Rotation ---- */
.rotation-shapes {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}
.rotation-shape {
  width: 140px;
  height: 140px;
  background: var(--bg-card);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.1);
}
.rotation-shape canvas { width: 120px; height: 120px; }
.rotation-answer-btns {
  display: flex;
  gap: 16px;
}

/* ---- Trails ---- */
.trails-canvas-container {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1;
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
}
.trails-canvas-container canvas {
  width: 100%;
  height: 100%;
}
.trails-node {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
  border: 2px solid var(--primary);
}
.trails-node.done {
  background: var(--primary);
  border-color: var(--accent);
}
.trails-node.current {
  box-shadow: 0 0 16px rgba(108, 99, 255, 0.6);
  animation: pulse 1s infinite;
}

/* ---- Chess ---- */
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: calc(100% - 8px);
  max-width: min(92vw, 400px);
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.1);
  margin: 0 auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.chess-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(10vw, 44px);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  line-height: 1;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
  color: #1a1a1a;
}
.chess-cell.light { background: #EEEED2; }
.chess-cell.dark { background: #769656; }
.chess-cell.selected { background: #BACA44 !important; }
.chess-cell.highlight { background: rgba(186,202,68,0.5) !important; }
.chess-cell.last-move { background: rgba(255,255,100,0.35) !important; }

/* ---- Memory Pairs ---- */
.memory-grid {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: min(90vw, 340px);
  margin: 0 auto;
}
.memory-grid.g4x3 { grid-template-columns: repeat(4, 1fr); }
.memory-grid.g4x4 { grid-template-columns: repeat(4, 1fr); }
.memory-grid.g5x4 { grid-template-columns: repeat(5, 1fr); }
.memory-card {
  aspect-ratio: 1;
  border-radius: 12px;
  background: rgba(108,99,255,0.25);
  border: 2px solid rgba(108,99,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(7vw, 28px);
  cursor: pointer;
  transition: var(--transition);
}
.memory-card.flipped {
  background: rgba(108,99,255,0.35);
  border-color: #6C63FF;
  box-shadow: 0 0 12px rgba(108,99,255,0.5);
}
.memory-card.matched {
  background: rgba(52,211,153,0.25);
  border-color: #34D399;
  box-shadow: 0 0 12px rgba(52,211,153,0.4);
}
.memory-card-back {
  font-size: min(5vw, 22px);
  color: rgba(108,99,255,0.8);
  font-weight: 800;
}

/* ---- Math Sprint ---- */
.math-problem {
  font-size: 48px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}
.math-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}
.math-answer {
  padding: 18px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.15);
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
  font-family: inherit;
}
.math-answer:active { transform: scale(0.95); }

/* ---- Word Chain ---- */
.word-display {
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 24px;
}
.word-input-area {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 300px;
}
.word-input-area .input { flex: 1; text-align: center; font-size: 20px; font-weight: 700; text-transform: uppercase; }

/* ---- Pattern Matrix ---- */
.pattern-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 24px;
}
.pattern-grid.g3 { grid-template-columns: repeat(3, 1fr); }
.pattern-grid.g4 { grid-template-columns: repeat(4, 1fr); }
.pattern-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.05);
}
.pattern-cell.mystery {
  border: 2px dashed var(--primary);
  font-size: 24px;
  color: var(--primary);
}
.pattern-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 320px;
}
.pattern-option {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: var(--transition);
}
.pattern-option:active { border-color: var(--primary); }

/* ---- Results screen ---- */
.screen-scroll {
  min-height: 100%;
  max-height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px;
}
.result-score {
  font-size: 64px;
  font-weight: 800;
  text-align: center;
}
.radar-container {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  margin: 0 auto;
}
.radar-container canvas { width: 100%; height: 100%; }

/* ---- Badges ---- */
.badge-item {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: var(--transition);
}
.badge-item.unlocked {
  border-color: var(--warning);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.3);
}
.badge-item.locked { opacity: 0.3; filter: grayscale(1); }

/* ---- Subscription ---- */
.plan-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 2px solid rgba(255,255,255,0.1);
  transition: var(--transition);
}
.plan-card.premium {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.plan-card.premium::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(108,99,255,0.08), rgba(0,217,255,0.05));
}
.plan-price {
  font-size: 36px;
  font-weight: 800;
}
.plan-price span { font-size: 16px; font-weight: 600; color: var(--text-muted); }
.plan-features { list-style: none; }
.plan-features li {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.plan-features li::before {
  content: '✓';
  color: var(--success);
  font-weight: 700;
}

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(11, 11, 18, 0.92);
  backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255,255,255,0.04);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 50;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
}
.nav-item.active { color: var(--primary-light); }
.nav-icon { font-size: 22px; }

/* ---- Language toggle ---- */
.lang-toggle {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 0; }

/* ---- When session is active, hide bottom nav ---- */
body.in-session .bottom-nav { display: none; }
body.in-session #app { padding-bottom: 0; }

/* ---- Floating quit button (visible during all in-session games) ---- */
.session-quit-fab {
  display: none;
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(15, 10, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.85);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, background 0.15s ease;
}
.session-quit-fab:active {
  transform: scale(0.92);
  background: rgba(239, 68, 68, 0.85);
}
body.in-session .session-quit-fab {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Padding for bottom nav ---- */
.has-nav { padding-bottom: calc(70px + var(--safe-bottom)); }

/* ============================================
   DESKTOP / TABLET RESPONSIVE LAYOUT
   Centre l'app comme une app mobile sur grand écran
   ============================================ */
@media (min-width: 600px) {
  html, body {
    overflow: auto;
    height: auto;
    min-height: 100%;
    background: #06060e;
    display: flex;
    justify-content: center;
    background-image:
      radial-gradient(ellipse at 20% 10%, rgba(108,99,255,0.12) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 90%, rgba(59,130,246,0.08) 0%, transparent 55%);
  }

  #app {
    width: 480px;
    min-height: 100vh;
    height: auto;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.05), 0 24px 80px rgba(0,0,0,0.7);
    border-left: 1px solid rgba(255,255,255,0.04);
    border-right: 1px solid rgba(255,255,255,0.04);
  }

  .screen { min-height: 100vh; }
  .bottom-nav { width: 480px; left: 50%; transform: translateX(-50%); }
  .game-feedback { left: calc(50% + 0px); }
}

@media (min-width: 900px) {
  body { align-items: flex-start; padding: 32px 0; }
  #app {
    min-height: calc(100vh - 64px);
    border-radius: 24px;
    overflow: hidden;
  }
  .bottom-nav { border-radius: 0 0 24px 24px; }
}

/* ============================================
   VISUAL POLISH v97 — Glassmorphism, Gradients, Micro-interactions
   ============================================ */

/* ── Animated gradient background ── */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

@keyframes breathe {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.03); }
}

@keyframes gradientText {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

@keyframes particleFly {
  0%   { transform: translateY(0) translateX(0) scale(1); opacity: 1; }
  100% { transform: translateY(-80px) translateX(var(--dx,20px)) scale(0); opacity: 0; }
}

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

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

@keyframes ripple {
  0%   { transform: scale(0); opacity: 0.5; }
  100% { transform: scale(4); opacity: 0; }
}

@keyframes borderGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108,99,255,0.3); }
  50%       { box-shadow: 0 0 0 4px rgba(108,99,255,0); }
}

/* ── Glass card variant ── */
.card-glass {
  background: rgba(255,255,255,0.035);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
}

/* ── Gradient border card ── */
.card-gradient-border {
  position: relative;
  border-radius: var(--radius);
  background: var(--bg-card);
}
.card-gradient-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius) + 1px);
  background: linear-gradient(135deg, rgba(108,99,255,0.6), rgba(0,217,255,0.4), rgba(52,211,153,0.3));
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s;
}
.card-gradient-border:hover::before { opacity: 1; }

/* ── Shimmer loading skeleton ── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

/* ── Pulse dot (live indicator) ── */
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34D399;
  display: inline-block;
  animation: borderGlow 2s ease infinite;
  box-shadow: 0 0 0 0 rgba(52,211,153,0.4);
}
@keyframes pulseRipple {
  0%   { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
  100% { box-shadow: 0 0 0 8px rgba(52,211,153,0); }
}
.pulse-dot { animation: pulseRipple 1.5s ease infinite; }

/* ── Glow chip label ── */
.glow-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 800;
  border: 1px solid transparent;
  letter-spacing: 0.04em;
}

/* ── Floating label badge ── */
.float-badge {
  animation: float 3s ease-in-out infinite;
}

/* ── Section heading with gradient line ── */
.section-heading {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(255,255,255,0.45);
  margin-bottom: 12px;
}
.section-heading::after {
  content: '';
  flex: 1; height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0.1), transparent);
}

/* ── Hover lift for cards ── */
.lift {
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), box-shadow 0.2s;
}
.lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.lift:active { transform: translateY(0) scale(0.98); }

/* ── XP bar ── */
.xp-bar {
  height: 6px; border-radius: 3px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  position: relative;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6C63FF, #00D9FF, #34D399);
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}

/* ── Daily quote card ── */
.daily-quote-card {
  padding: 16px 18px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(0,217,255,0.06), rgba(108,99,255,0.08));
  border: 1px solid rgba(0,217,255,0.15);
  position: relative; overflow: hidden;
  animation: slideInUp 0.4s ease;
}
.daily-quote-card::before {
  content: '"';
  position: absolute; top: -10px; left: 10px;
  font-size: 80px; font-weight: 900; color: rgba(0,217,255,0.06);
  font-family: Georgia, serif; line-height: 1;
}

/* ── Science badge ── */
.science-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(52,211,153,0.12); border: 1px solid rgba(52,211,153,0.25);
  font-size: 10px; font-weight: 800; color: #34D399; letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Improved bottom nav active state ── */
.nav-item { position: relative; }
.nav-item.active::after {
  content: '';
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--primary-light);
}
.nav-item.active .nav-icon {
  animation: float 2s ease-in-out infinite;
}

/* ── Start button enhanced ── */
.start-btn-ring {
  position: relative;
}
.start-btn-ring::after {
  content: '';
  position: absolute; inset: -8px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, rgba(108,99,255,0.3) 50%, transparent 100%);
  animation: spin 4s linear infinite;
  pointer-events: none;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Results score ring enhanced ── */
.score-ring-track { stroke: rgba(255,255,255,0.05); }
.score-ring-fill {
  transition: stroke-dashoffset 1.4s cubic-bezier(0.4,0,0.2,1);
  filter: drop-shadow(0 0 6px currentColor);
}

/* ── Improved stat-box ── */
.stat-box {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  transition: border-color 0.2s;
}
.stat-box:hover { border-color: rgba(108,99,255,0.3); }

/* ── Achievement unlock animation ── */
@keyframes achievementPop {
  0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(5deg); opacity: 1; }
  80%  { transform: scale(0.95) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.achievement-unlock {
  animation: achievementPop 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ── Tooltip ── */
.tooltip {
  position: relative;
}
.tooltip-text {
  visibility: hidden;
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85); backdrop-filter: blur(10px);
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 5px 10px; border-radius: 8px; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity 0.15s;
  border: 1px solid rgba(255,255,255,0.1);
}
.tooltip:hover .tooltip-text { visibility: visible; opacity: 1; }

/* ── Improved badge items ── */
.badge-item {
  transition: transform 0.2s, box-shadow 0.2s;
}
.badge-item.unlocked:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 0 24px rgba(245,158,11,0.5);
}

/* ── Streak milestone ring ── */
.streak-milestone {
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: conic-gradient(from -90deg, #FF8C00, #FFD700, #FF8C00);
  box-shadow: 0 0 20px rgba(255,165,0,0.4);
  animation: float 2.5s ease-in-out infinite;
}

/* ── History session row ── */
.session-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: 16px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.05);
  transition: border-color 0.2s, background 0.2s;
  cursor: default;
}
.session-row:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(108,99,255,0.2);
}

/* ── Cognitive domain chip ── */
.domain-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  transition: all 0.2s;
}
.domain-chip:hover { background: rgba(255,255,255,0.06); }

/* ── Level progress bar ── */
.level-bar {
  height: 8px; border-radius: 4px;
  background: rgba(255,255,255,0.06);
  overflow: hidden; position: relative;
}
.level-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #6C63FF, #00D9FF);
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.level-bar-fill.max {
  background: linear-gradient(90deg, #FFD700, #FF8C00);
  box-shadow: 0 0 8px rgba(255,215,0,0.4);
}

/* ── IQ comparison bar ── */
.iq-bar {
  height: 10px; border-radius: 5px;
  background: rgba(255,255,255,0.05);
  overflow: visible; position: relative;
}
.iq-bar-fill {
  height: 100%; border-radius: 5px;
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
}
.iq-bar-marker {
  position: absolute; top: -3px;
  width: 2px; height: 16px; border-radius: 1px;
  background: rgba(255,255,255,0.4);
}

/* ── Improved game feedback ── */
.game-feedback {
  font-size: 64px;
  text-shadow: 0 0 30px rgba(108,99,255,0.5);
}

/* ── Schulte grid button hover ── */
#schulte-grid button:hover:not(:disabled) {
  box-shadow: 0 0 16px rgba(108,99,255,0.4);
  border-color: #6C63FF !important;
}

/* ── Cognition report cards ── */
.cognition-card {
  padding: 16px 18px; border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  transition: all 0.2s;
}
.cognition-card:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(108,99,255,0.25);
  transform: translateY(-1px);
}

/* ── Milestone track ── */
.milestone-track {
  display: flex; align-items: center; gap: 0;
  padding: 0 4px;
}
.milestone-node {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  transition: all 0.3s;
}
.milestone-node.done {
  background: linear-gradient(135deg,#6C63FF,#00D9FF);
  border-color: transparent;
  box-shadow: 0 0 12px rgba(108,99,255,0.4);
}
.milestone-node.current {
  border-color: #6C63FF;
  animation: borderGlow 2s ease infinite;
}
.milestone-line {
  flex: 1; height: 2px; background: rgba(255,255,255,0.06);
}
.milestone-line.done {
  background: linear-gradient(90deg, #6C63FF, #00D9FF);
}

/* ── Notification toast ── */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(20,20,35,0.95); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 14px;
  padding: 12px 20px; font-size: 14px; font-weight: 700;
  color: #fff; z-index: 9999; white-space: nowrap;
  animation: slideInUp 0.3s ease, fadeOut 0.3s 2.5s ease forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

/* ── Improved input focus ── */
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

/* ── Screen with gradient mesh BG ── */
.screen-mesh {
  background:
    radial-gradient(ellipse at 10% 0%, rgba(108,99,255,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(0,217,255,0.07) 0%, transparent 50%);
}

/* ── Smooth scroll ── */
#app { scroll-behavior: smooth; }

/* ════════════════════════════════════════════════════════
   🎨 DA VINCI MIND — CODEX / PARCHMENT THEMING
   Subtle vintage touches: aged paper, ink-bleed,
   serif headings, Vitruvian watermarks. Used on key
   "premium" surfaces (pitch, onboarding, IQ ladder).
   ════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&display=swap');

:root {
  --codex-parchment:    #F5E6D3;
  --codex-parchment-2:  #E8D5B8;
  --codex-ink:          #3D2914;
  --codex-ink-faded:    #5C4126;
  --codex-sepia:        #8B6F47;
  --codex-gold:         #C99B5C;
  --codex-burgundy:     #6B2D2D;
  --codex-shadow:       rgba(61, 41, 20, 0.18);
  --codex-serif:        'Cormorant Garamond', 'Times New Roman', Georgia, serif;
}

/* ── Codex section: parchment background with subtle vignette ── */
.codex-screen .codex-header {
  background:
    radial-gradient(circle at 20% 0%, rgba(201, 155, 92, 0.12), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(107, 45, 45, 0.10), transparent 50%),
    linear-gradient(160deg, rgba(245, 230, 211, 0.08) 0%, rgba(232, 213, 184, 0.04) 50%, transparent 100%);
}

/* Serif headings inside codex sections — Da Vinci notebook vibe */
.codex-screen h1,
.codex-screen h2 {
  font-family: var(--codex-serif);
  font-weight: 600;
  letter-spacing: 0.005em;
}

/* ── Parchment card variant ── */
.parchment-card {
  position: relative;
  background:
    radial-gradient(ellipse at top left, rgba(201, 155, 92, 0.06), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(107, 45, 45, 0.05), transparent 50%),
    linear-gradient(180deg, rgba(245, 230, 211, 0.07) 0%, rgba(232, 213, 184, 0.04) 100%);
  border: 1px solid rgba(201, 155, 92, 0.32);
  border-radius: 14px;
  box-shadow:
    inset 0 1px 0 rgba(245, 230, 211, 0.05),
    0 2px 12px rgba(61, 41, 20, 0.18);
}

.parchment-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 2px,
      rgba(201, 155, 92, 0.015) 2px,
      rgba(201, 155, 92, 0.015) 4px
    );
}

/* Inline ink-touch label */
.codex-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-family: var(--codex-serif);
  font-style: italic;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--codex-gold);
  background: rgba(201, 155, 92, 0.08);
  border: 1px solid rgba(201, 155, 92, 0.25);
}

/* Codex divider — handwritten flourish */
.codex-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}
.codex-divider::before,
.codex-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 155, 92, 0.45), transparent);
}
.codex-divider span {
  color: var(--codex-gold);
  font-size: 16px;
  opacity: 0.7;
}

/* Da Vinci IQ entry — special highlight at the top of the list */
.davinci-peak {
  position: relative;
  background: linear-gradient(135deg, rgba(201, 155, 92, 0.18), rgba(107, 45, 45, 0.10)) !important;
  border: 1.5px solid rgba(201, 155, 92, 0.55) !important;
}
.davinci-peak::after {
  content: '👑';
  position: absolute;
  top: -10px;
  right: -8px;
  font-size: 22px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
