:root {
  --ink: #2c2c2c;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --correct: #00b894;
  --incorrect: #e17055;
  --bg: #f8f7ff;
  --card: #ffffff;
  --card-border: #e8e6f0;
  --shadow: 0 2px 12px rgba(108,92,231,0.08);
  --shadow-lg: 0 8px 30px rgba(108,92,231,0.12);
  --xp-bar: #fdcb6e;
  --streak: #e17055;
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Heebo', sans-serif;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  position: relative;
}

h1 { font-family: 'Secular One', sans-serif; font-size: 1.8rem; }
h2 { font-family: 'Secular One', sans-serif; font-size: 1.5rem; }
h3 { font-family: 'Secular One', sans-serif; font-size: 1.2rem; }

.screen {
  min-height: 100dvh;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

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

@keyframes popIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes glow { 0%,100% { box-shadow: 0 0 5px var(--accent-light); } 50% { box-shadow: 0 0 20px var(--accent-light); } }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.5rem;
  border: 2px solid var(--card-border);
  border-radius: 50px;
  background: var(--card);
  color: var(--ink);
  font-family: 'Heebo', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:active { background: #5b4bd6; }
.btn--correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.btn--incorrect { background: var(--incorrect); border-color: var(--incorrect); color: #fff; }
.btn--disabled { opacity: 0.35; pointer-events: none; }
.btn--full { width: 100%; }
.btn--big { padding: 1rem 2rem; font-size: 1.2rem; }
.btn--icon { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 1.3rem; }

/* === CARDS === */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
}

/* === PROFILE SELECT === */
.profile-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  text-align: center;
}

.profile-title {
  font-family: 'Secular One', sans-serif;
  font-size: 2rem;
  color: var(--accent);
}

.profile-subtitle { color: #888; font-size: 1.1rem; }

.profile-grid {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.profile-card {
  background: var(--card);
  border: 3px solid var(--card-border);
  border-radius: 20px;
  padding: 1.5rem 1.25rem;
  width: 130px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.profile-card:active { transform: scale(0.95); }
.profile-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }

.profile-card__avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 0.75rem;
  color: #fff;
}

.profile-card__name {
  font-family: 'Secular One', sans-serif;
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

.profile-card__age { font-size: 0.9rem; color: #888; }
.profile-card__level { font-size: 0.85rem; color: var(--accent); font-weight: 600; margin-top: 0.25rem; }

/* === GAME HEADER === */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--card-border);
}
.game-header__title { font-family: 'Secular One', sans-serif; font-size: 1.15rem; }
.game-header__timer {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  direction: ltr;
}
.game-header__back {
  background: none; border: none;
  font-size: 1.4rem; cursor: pointer;
  padding: 0.25rem; color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.game-header__info { font-size: 0.9rem; color: #888; }

/* === HUB === */
.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.hub-profile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.hub-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff;
}

.hub-name { font-weight: 700; font-size: 1.05rem; }
.hub-level { font-size: 0.8rem; color: var(--accent); font-weight: 600; }

.hub-date { text-align: center; font-size: 0.9rem; color: #888; margin-bottom: 0.5rem; }

/* XP Bar */
.xp-bar-wrap {
  background: var(--card-border);
  border-radius: 50px;
  height: 22px;
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 50px;
  transition: width 0.5s ease;
  min-width: 2px;
}
.xp-bar-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink);
}

/* Streak */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #fff3e0;
  color: var(--streak);
  padding: 0.3rem 0.7rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Section title */
.section-title {
  font-family: 'Secular One', sans-serif;
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem;
  color: var(--ink);
}

/* Daily session card */
.daily-card {
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  border: none;
  border-radius: var(--radius);
  padding: 1.25rem;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: var(--shadow-lg);
  margin-bottom: 1rem;
}
.daily-card:active { transform: scale(0.98); }
.daily-card h3 { color: #fff; font-size: 1.2rem; margin-bottom: 0.3rem; }
.daily-card p { opacity: 0.9; font-size: 0.95rem; }

/* Game grid */
.game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.game-card {
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.game-card:active { transform: scale(0.97); }
.game-card:hover { border-color: var(--accent-light); }
.game-card--done { border-color: var(--correct); background: #f0fff4; }
.game-card__icon { font-size: 1.8rem; margin-bottom: 0.2rem; }
.game-card__name { font-size: 0.95rem; font-weight: 600; line-height: 1.2; }
.game-card__score { font-size: 0.8rem; color: #999; margin-top: 0.15rem; direction: ltr; }
.game-card__category { font-size: 0.65rem; color: var(--accent); font-weight: 600; margin-top: 0.15rem; text-transform: uppercase; }

/* Hub bottom */
.hub-bottom {
  margin-top: auto;
  display: flex;
  gap: 0.6rem;
  padding-top: 1rem;
}
.hub-bottom .btn { flex: 1; }

/* === TTS button === */
.tts-btn {
  background: var(--accent-light);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.tts-btn:active { transform: scale(0.9); }

/* === INSTRUCTION === */
.instruction {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  gap: 1rem;
}
.instruction__icon { font-size: 3.5rem; animation: popIn 0.4s ease; }
.instruction__title { font-size: 1.4rem; }
.instruction__text { font-size: 1.05rem; color: #666; line-height: 1.5; max-width: 340px; }

/* === EXERCISE AREAS === */
.exercise-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.exercise-progress { font-size: 0.9rem; color: #888; direction: ltr; }

.exercise-problem {
  font-family: 'Secular One', sans-serif;
  font-size: 3rem;
  text-align: center;
  min-height: 4rem;
  direction: ltr;
}

.exercise-input {
  width: 160px;
  font-family: 'Secular One', sans-serif;
  font-size: 2.5rem;
  text-align: center;
  border: none;
  border-bottom: 3px solid var(--ink);
  background: transparent;
  color: var(--ink);
  outline: none;
  padding: 0.25rem;
  direction: ltr;
}
.exercise-input:focus { border-bottom-color: var(--accent); }

/* Stroop */
.stroop-word {
  font-family: 'Secular One', sans-serif;
  font-size: 3.5rem;
  text-align: center;
}
.stroop-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  width: 100%;
  max-width: 300px;
}
.stroop-btn {
  padding: 0.6rem;
  border: 3px solid;
  border-radius: var(--radius-sm);
  background: var(--card);
  font-family: 'Heebo', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.stroop-btn:active { transform: scale(0.95); }

/* Memory display */
.memo-display {
  font-family: 'Secular One', sans-serif;
  font-size: 3.5rem;
  text-align: center;
  letter-spacing: 0.3rem;
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
}

/* Number tracking */
.suivi-area {
  position: relative;
  width: 100%;
  height: 350px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.suivi-number {
  position: absolute;
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Secular One', sans-serif;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.suivi-number--visible { background: var(--accent); color: #fff; }
.suivi-number--hidden { background: #e8e6f0; color: #e8e6f0; }
.suivi-number--revealed { background: var(--correct); color: #fff; }
.suivi-number--wrong { background: var(--incorrect); color: #fff; animation: shake 0.4s ease; }

/* Attention (CPT) */
.cpt-display {
  width: 120px; height: 120px;
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: all 0.15s;
}
.cpt-btn {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.cpt-btn:active { transform: scale(0.9); background: #5b4bd6; }

/* Grid Memory */
.grid-wrap {
  display: inline-grid;
  gap: 4px;
  background: var(--card-border);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.grid-cell {
  width: 60px; height: 60px;
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.grid-cell--lit { background: var(--accent); }
.grid-cell--correct { background: var(--correct); }
.grid-cell--wrong { background: var(--incorrect); }
.grid-cell--missed { background: var(--accent-light); opacity: 0.5; }

/* Rotation */
.rotation-grid {
  display: inline-grid;
  gap: 2px;
  background: var(--card-border);
  padding: 2px;
  border-radius: 4px;
}
.rotation-cell {
  width: 28px; height: 28px;
  border-radius: 3px;
}
.rotation-cell--on { background: var(--accent); }
.rotation-cell--off { background: #f0eef5; }

.rotation-choices {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}
.rotation-choice {
  padding: 0.5rem;
  border: 3px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--card);
}
.rotation-choice:active { transform: scale(0.95); }
.rotation-choice--correct { border-color: var(--correct); background: #f0fff4; }
.rotation-choice--wrong { border-color: var(--incorrect); background: #fff5f5; }

/* Word intruder */
.word-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 300px;
}
.word-btn {
  padding: 0.8rem 1rem;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-family: 'Heebo', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.word-btn:active { transform: scale(0.97); }
.word-btn--correct { background: var(--correct); color: #fff; border-color: var(--correct); }
.word-btn--wrong { background: var(--incorrect); color: #fff; border-color: var(--incorrect); }

/* Sequence choices */
.seq-choices {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.seq-btn {
  width: 60px; height: 60px;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-family: 'Secular One', sans-serif;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  direction: ltr;
}
.seq-btn:active { transform: scale(0.95); }

/* Chain display */
.chain-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  font-family: 'Secular One', sans-serif;
  font-size: 1.6rem;
  direction: ltr;
}
.chain-op { color: var(--accent); font-weight: 700; }
.chain-num { color: var(--ink); }

/* === SUMMARY === */
.summary {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
}
.summary__icon { font-size: 3rem; animation: popIn 0.4s ease; }
.summary__big {
  font-family: 'Secular One', sans-serif;
  font-size: 3.5rem;
  color: var(--accent);
}
.summary__label { font-size: 1rem; color: #888; }
.summary__detail { font-size: 0.9rem; color: #666; }
.summary__xp {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #fff3e0;
  color: #e67e22;
  padding: 0.4rem 0.8rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 1.1rem;
  animation: popIn 0.5s ease;
}
.summary__buttons {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* === BRAIN AGE === */
.brain-age { text-align: center; margin: 1rem 0; }
.brain-age__label { font-size: 1rem; color: #888; }
.brain-age__value {
  font-family: 'Secular One', sans-serif;
  font-size: 5rem;
  color: var(--accent);
  line-height: 1;
  direction: ltr;
}
.brain-age__unit { font-size: 1.2rem; color: var(--accent); }

/* === HISTORY === */
.history-list { list-style: none; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--card-border);
}
.history-item__date { font-size: 0.9rem; font-weight: 500; }
.history-item__age { font-family: 'Secular One', sans-serif; font-size: 1.2rem; color: var(--accent); direction: ltr; }
.history-item__games { font-size: 0.8rem; color: #999; }

/* === BADGES === */
.badges-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--card-border);
  width: 80px;
  text-align: center;
}
.badge--locked { opacity: 0.3; filter: grayscale(1); }
.badge__icon { font-size: 1.5rem; }
.badge__name { font-size: 0.65rem; font-weight: 600; line-height: 1.2; }

/* === ENTRY TEST === */
.test-step {
  text-align: center;
  font-size: 1.1rem;
  color: #888;
  margin-bottom: 1rem;
}
.test-progress-dots {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.test-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--card-border);
}
.test-dot--active { background: var(--accent); }
.test-dot--done { background: var(--correct); }

/* === PROFILE STATS === */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--card-border);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 0.95rem; color: #666; }
.stat-value { font-weight: 700; color: var(--accent); direction: ltr; }

/* === FLASH === */
.flash-correct { animation: flashGreen 0.4s ease; }
@keyframes flashGreen { 0% { background-color: transparent; } 30% { background-color: rgba(0,184,148,0.15); } 100% { background-color: transparent; } }
.flash-incorrect { animation: flashRed 0.4s ease; }
@keyframes flashRed { 0% { background-color: transparent; } 30% { background-color: rgba(225,112,85,0.15); } 100% { background-color: transparent; } }

/* === RESPONSIVE === */
@media (max-width: 380px) {
  .screen { padding: 0.75rem; }
  .exercise-problem { font-size: 2.5rem; }
  .suivi-area { height: 280px; }
  .game-grid { gap: 0.4rem; }
  .game-card { padding: 0.75rem 0.5rem; }
  .grid-cell { width: 50px; height: 50px; }
  .profile-card { width: 110px; padding: 1rem; }
}
