:root {
  --navy: #1a1a4e;
  --purple: #7c3aed;
  --turquoise: #2dd4bf;
  --gold: #f59e0b;
  --red: #ef4444;
  --green: #10b981;
  --bg: #f7f8fc;
  --card: #ffffff;
  --text: #1a1a4e;
  --text-light: #6b7280;
  --border: #e8eaf0;
  --radius: 16px;
  --shadow: 0 4px 12px rgba(26,26,78,0.06);
  --shadow-lg: 0 8px 24px rgba(26,26,78,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  justify-content: center;
}

.app { width: 100%; max-width: 480px; min-height: 100vh; position: relative; }
.app:has(.screen-home.active) { max-width: 100%; max-height: 100vh; overflow: hidden; border-radius: 0; box-shadow: none; min-height: 100vh; }
.app:has(.screen-map.active) { max-width: 100%; }
.app:has(#screen-welcome.active) { max-width: 600px; }

/* ============ SCREENS ============ */
.screen { display: none !important; background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-lg); animation: fadeIn 0.3s ease; margin: 0.5rem; }
.screen.active { display: block !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============ WELCOME ============ */
.welcome-header { text-align: center; padding-top: 1.5rem; margin-bottom: 2rem; }
.welcome-logo { max-width: 200px; width: 80%; height: auto; margin-bottom: 0.5rem; }
.subtitle { color: var(--purple); font-size: 1rem; font-weight: 600; }
.welcome-description { color: var(--text-light); font-size: 0.82rem; line-height: 1.6; margin-top: 1rem; max-width: 320px; margin-left: auto; margin-right: auto; }
.welcome-actions { display: flex; flex-direction: column; gap: 0.8rem; }

/* Dragon evolution showcase */
.dragon-evolution { margin-bottom: 0.5rem; text-align: center; }
.dragon-evo-title { font-size: 0.75rem; font-weight: 700; color: var(--purple); margin-bottom: 0.5rem; }
.dragon-evo-row { display: flex; align-items: center; justify-content: center; gap: 0.15rem; padding: 0.3rem 0; flex-wrap: nowrap; }
.dragon-evo-item { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.dragon-evo-img { width: 36px; height: 36px; object-fit: contain; }
.dragon-evo-item span { font-size: 0.42rem; font-weight: 600; color: var(--text-light); margin-top: 0.1rem; }
.dragon-evo-arrow { font-size: 0.5rem; color: var(--purple); font-weight: 700; flex-shrink: 0; }

@media (min-width: 500px) {
  .dragon-evo-img { width: 50px; height: 50px; }
  .dragon-evo-item span { font-size: 0.55rem; }
  .dragon-evo-row { gap: 0.3rem; }
  .dragon-evo-arrow { font-size: 0.7rem; }
}

/* ============ BUTTONS ============ */
.btn { padding: 0.85rem 1.5rem; border: none; border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s; width: 100%; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--purple), var(--turquoise)); color: white; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-light); font-size: 0.9rem; }
.btn-ghost:hover { background: var(--bg); }
.btn-icon { background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 0.4rem; color: var(--text); }
.btn-continue { margin-top: 0.8rem; padding: 0.6rem 1.2rem; background: var(--green); color: white; font-size: 0.9rem; width: auto; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; }
.link-btn { background: none; border: none; color: var(--purple); font-weight: 600; font-size: 0.8rem; cursor: pointer; }
.screen-topbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.screen-topbar h2 { margin: 0; text-align: left; font-size: 1.1rem; }
.topics-intro, .levels-intro { display: flex; align-items: center; gap: 0.3rem; padding: 0.4rem 0.6rem; margin-bottom: 0.6rem; background: linear-gradient(135deg, #f5f0ff, #ede9fe); border-radius: 10px; border: 1px solid #e0d4fc; }
.topics-intro-text, .levels-intro-text { font-size: 0.72rem; font-weight: 600; color: var(--purple); }

/* ============ FORMS ============ */
.form-field { margin-bottom: 1.2rem; }
.form-field label { display: block; margin-bottom: 0.4rem; font-weight: 600; color: var(--text); font-size: 0.85rem; }
.form-field input, .form-select, textarea { width: 100%; padding: 0.8rem 1rem; border: 2px solid var(--border); border-radius: 12px; font-size: 1rem; outline: none; transition: border-color 0.2s; font-family: inherit; background: var(--card); }
.form-field input:focus, .form-select:focus, textarea:focus { border-color: var(--purple); }
.form-error { margin-top: 0.4rem; padding: 0.5rem 0.7rem; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; color: #dc2626; font-size: 0.78rem; font-weight: 600; animation: fadeIn 0.3s ease; }
h2 { font-size: 1.2rem; color: var(--text); margin-bottom: 1rem; text-align: center; }

/* ============ AVATAR SELECTOR ============ */
.avatar-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.avatar-option { display: flex; flex-direction: column; align-items: center; padding: 0.6rem 0.3rem; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; transition: all 0.2s; }
.avatar-option.selected { border-color: var(--purple); background: #f5f0ff; box-shadow: 0 2px 8px rgba(124,58,237,0.2); }
.avatar-preview { font-size: 1.6rem; }
.avatar-option span { font-size: 0.6rem; font-weight: 600; color: var(--text-light); margin-top: 0.2rem; }

/* ============ PLAYERS LIST ============ */
.players-list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 50vh; overflow-y: auto; margin-bottom: 1rem; }
.player-card { display: flex; align-items: center; justify-content: space-between; padding: 0.8rem; background: var(--bg); border-radius: 12px; cursor: pointer; transition: all 0.2s; border: 2px solid transparent; }
.player-card:hover { border-color: var(--purple); background: #f5f0ff; }
.player-card-info { display: flex; align-items: center; gap: 0.6rem; }
.player-avatar { font-size: 1.5rem; }
.player-card-name { font-weight: 600; color: var(--text); font-size: 0.9rem; }
.player-card-age { color: var(--text-light); font-size: 0.75rem; }

/* ============ HOME ============ */
.home-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, var(--navy), var(--purple));
  border-radius: 0 0 20px 20px;
}
.home-brand { font-size: 1.3rem; font-weight: 800; color: white; font-style: italic; letter-spacing: -0.5px; }
.home-stats { display: flex; gap: 0.4rem; }
.stat-pill { background: rgba(255,255,255,0.15); color: white; padding: 0.25rem 0.6rem; border-radius: 16px; font-size: 0.75rem; font-weight: 700; }
.xp-pill { border: 1px solid rgba(45,212,191,0.4); }
.streak-pill { border: 1px solid rgba(245,158,11,0.4); }

.home-greeting {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.9rem 1rem; margin: 0.7rem 0.7rem;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.greeting-avatar { font-size: 2.2rem; }
.greeting-text { flex: 1; min-width: 0; }
.greeting-hello { color: var(--text); font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.greeting-sub { color: var(--text-light); font-size: 0.72rem; margin-bottom: 0.3rem; }
.greeting-level { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.level-badge { background: linear-gradient(135deg, var(--purple), var(--turquoise)); color: white; padding: 0.12rem 0.45rem; border-radius: 6px; font-size: 0.62rem; font-weight: 700; white-space: nowrap; }
.xp-bar { flex: 1; min-width: 40px; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--turquoise), var(--purple)); border-radius: 3px; transition: width 0.5s; }
.xp-text { color: var(--text-light); font-size: 0.58rem; white-space: nowrap; }
.greeting-streak-box { text-align: center; background: #fff7ed; padding: 0.4rem 0.6rem; border-radius: 10px; border: 1px solid #fed7aa; flex-shrink: 0; }
.streak-fire { font-size: 1.2rem; line-height: 1; }
.streak-days { color: #ea580c; font-weight: 800; font-size: 0.85rem; line-height: 1.2; }
.streak-label { color: var(--text-light); font-size: 0.55rem; }

.home-section { padding: 0.6rem 0.8rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; padding: 0 0.2rem; }
.section-header span { font-weight: 700; color: var(--text); font-size: 0.9rem; }

/* ============ AREAS CAROUSEL ============ */
.worlds-carousel { display: flex; gap: 0.6rem; overflow-x: auto; padding: 0.3rem 0.2rem 0.6rem; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.worlds-carousel::-webkit-scrollbar { height: 3px; }
.worlds-carousel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.world-carousel-card {
  min-width: 120px; flex-shrink: 0; scroll-snap-align: start;
  background: var(--card); border-radius: 14px; padding: 0.9rem 0.6rem;
  text-align: center; cursor: pointer; transition: all 0.2s;
  border: 2px solid var(--border); position: relative;
  box-shadow: var(--shadow);
}
.world-carousel-card:hover:not(.locked) { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--purple); }
.world-carousel-card.locked { opacity: 0.5; cursor: not-allowed; }
.world-carousel-card .world-card-icon { font-size: 1.8rem; margin-bottom: 0.3rem; }
.world-carousel-card .world-card-name { font-size: 0.72rem; font-weight: 700; color: var(--text); margin-bottom: 0.15rem; }
.world-carousel-card .world-card-status { font-size: 0.6rem; color: var(--text-light); }
.world-carousel-card .world-card-progress { margin-top: 0.35rem; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.world-carousel-card .world-card-progress-fill { height: 100%; background: linear-gradient(90deg, var(--turquoise), var(--purple)); border-radius: 2px; }
.world-carousel-card .world-lock { position: absolute; top: 6px; right: 6px; font-size: 0.65rem; }

/* ============ TODAY'S PATH ============ */
.today-path { display: flex; flex-direction: column; gap: 0.5rem; }
.path-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.8rem; background: var(--card); border-radius: 12px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.path-item-icon { font-size: 1.3rem; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: #f0f0ff; border-radius: 10px; flex-shrink: 0; }
.path-item-info { flex: 1; min-width: 0; }
.path-item-name { font-weight: 600; font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.path-item-detail { font-size: 0.7rem; color: var(--text-light); }
.path-item-btn { background: linear-gradient(135deg, var(--purple), var(--turquoise)); color: white; border: none; padding: 0.4rem 0.8rem; border-radius: 8px; font-size: 0.72rem; font-weight: 600; cursor: pointer; flex-shrink: 0; }

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0;
  width: 100%; max-width: 100%;
  display: flex; justify-content: space-around;
  background: var(--card); padding: 0.5rem 0 0.6rem;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
  z-index: 100;
}
.nav-item { display: flex; flex-direction: column; align-items: center; background: none; border: none; cursor: pointer; padding: 0.2rem 0.6rem; color: var(--text-light); transition: color 0.2s; }
.nav-item.active { color: var(--purple); }
.nav-icon { font-size: 1.15rem; }
.nav-label { font-size: 0.58rem; font-weight: 600; margin-top: 0.1rem; }

/* ============ WORLDS GRID ============ */
.worlds-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.world-card { display: flex; align-items: center; padding: 0.9rem; border-radius: 14px; border: 2px solid var(--border); cursor: pointer; transition: all 0.2s; gap: 0.7rem; background: var(--card); }
.world-card:hover:not(.locked) { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--purple); }
.world-card.locked { opacity: 0.4; cursor: not-allowed; }
.world-card.completed { border-color: var(--turquoise); background: #f0fdfa; }
.world-icon { font-size: 1.6rem; }
.world-info { flex: 1; }
.world-name { font-weight: 700; color: var(--text); font-size: 0.85rem; }
.world-progress { font-size: 0.7rem; color: var(--text-light); }
.world-status { font-size: 1rem; }

/* ============ TOPICS & LEVELS ============ */
.topics-grid, .levels-grid { display: flex; flex-direction: column; gap: 0.4rem; }

/* Zone headers */
.zone-header { display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.2rem; margin-top: 0.3rem; }
.zone-header-icon { font-size: 1rem; }
.zone-header-text { font-size: 0.75rem; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.5px; }
.zone-header-boss { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 2px dashed var(--border); }
.zone-header-boss .zone-header-text { color: var(--red); }
.zone-header-secret { margin-top: 0.6rem; }
.zone-header-secret .zone-header-text { color: var(--gold); }

/* Topic cards - adventure style */
.topic-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem;
  border-radius: 14px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card);
}
.topic-card:hover:not(.locked) { border-color: var(--purple); transform: translateX(4px); box-shadow: var(--shadow); }
.topic-card.locked { opacity: 0.6; cursor: not-allowed; }
.topic-card.mastered { border-color: var(--green); background: linear-gradient(135deg, #f0fdfa, #d1fae5); }
.topic-card.available { border-color: var(--purple); background: linear-gradient(135deg, #faf5ff, #f3e8ff); }
.topic-card.boss-card { border-width: 2px; }
.topic-card.boss-card.available { border-color: var(--red); background: linear-gradient(135deg, #fef2f2, #fee2e2); }
.topic-card.boss-card.mastered { border-color: var(--gold); background: linear-gradient(135deg, #fffbeb, #fef3c7); }

.topic-card-left { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; }
.topic-card-info { flex: 1; min-width: 0; }
.topic-card-right { display: flex; align-items: center; gap: 0.3rem; }

.topic-node {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 800; flex-shrink: 0;
  border: 2px solid var(--border);
}
.topic-node.node-active { background: linear-gradient(135deg, var(--purple), var(--turquoise)); color: white; border-color: var(--purple); animation: nodeGlow 2s ease-in-out infinite; }
.topic-node.node-mastered { background: var(--green); color: white; border-color: var(--green); }
.topic-node.node-locked { background: var(--bg); color: var(--text-light); }
.topic-node.node-boss { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; border-color: var(--red); }

@keyframes nodeGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(124,58,237,0.3); } 50% { box-shadow: 0 0 0 6px rgba(124,58,237,0); } }

/* Beacon effect for active world */
.mnode-beacon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(124,58,237,0.4);
  animation: beaconPulse 2s ease-out infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes beaconPulse {
  0% { width: 50px; height: 50px; opacity: 1; }
  100% { width: 90px; height: 90px; opacity: 0; }
}

.topic-name { font-weight: 600; color: var(--text); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-progress { font-size: 0.65rem; color: var(--text-light); margin-top: 0.1rem; }
.topic-chest { font-size: 1.1rem; animation: chestBounce 1.5s ease-in-out infinite; }
@keyframes chestBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.topic-arrow { font-size: 0.9rem; color: var(--text-light); }

/* Secret zone card */
.secret-zone-card {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.8rem; border-radius: 12px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px dashed var(--gold);
  font-size: 0.7rem; color: #92400e;
}
.secret-icon { font-size: 1.2rem; }
.secret-text { flex: 1; font-weight: 600; }

/* Level cards - path style */
.level-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem;
  border-radius: 14px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card);
}
.level-card:hover:not(.locked) { border-color: var(--purple); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.level-card.locked { opacity: 0.5; cursor: not-allowed; }
.level-card.completed { border-color: var(--green); background: linear-gradient(135deg, #f0fdfa, #d1fae5); }
.level-card.available { border-color: var(--purple); background: linear-gradient(135deg, #faf5ff, #f3e8ff); }
.level-card.level-boss { border-width: 3px; }
.level-card.level-boss.available { border-color: var(--red); background: linear-gradient(135deg, #fef2f2, #fee2e2); }

.level-node {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 3px solid var(--border);
  background: var(--bg);
}
.level-node.completed { background: var(--green); border-color: var(--green); }
.level-node.available { background: linear-gradient(135deg, var(--purple), var(--turquoise)); border-color: var(--purple); animation: nodeGlow 2s ease-in-out infinite; }
.level-node.locked { background: var(--bg); border-color: var(--border); }
.level-node-icon { font-size: 1.1rem; }
.level-node.completed .level-node-icon, .level-node.available .level-node-icon { filter: brightness(10); }

.level-info { flex: 1; }
.level-info h3 { font-size: 0.85rem; color: var(--text); margin-bottom: 0.1rem; }
.level-info p { font-size: 0.68rem; color: var(--text-light); }

.level-go {
  background: linear-gradient(135deg, var(--purple), var(--turquoise));
  color: white; padding: 0.35rem 0.7rem; border-radius: 8px;
  font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}

/* Path connector between levels */
.level-path { display: flex; justify-content: center; padding: 0.1rem 0; }
.level-path-line { width: 3px; height: 16px; border-radius: 2px; background: var(--border); }
.level-path.path-done .level-path-line { background: var(--green); }

.topic-status { font-size: 0.95rem; font-weight: 600; color: var(--purple); }

/* ============ GAME ============ */
.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.game-progress { flex: 1; margin-right: 1rem; }
#game-question-num { font-size: 0.75rem; color: var(--text-light); display: block; margin-bottom: 0.2rem; }
.game-mission-info { font-size: 0.65rem; color: var(--purple); font-weight: 600; display: block; margin-bottom: 0.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-bar { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--turquoise), var(--purple)); border-radius: 4px; transition: width 0.3s; width: 0%; }
.game-score { font-weight: 700; color: var(--gold); font-size: 1rem; }
.game-content { text-align: center; }
.question-emoji { font-size: 2rem; margin-bottom: 0.5rem; animation: bounce 2s ease infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.question-text { font-size: 1.05rem; font-weight: 600; color: var(--text); margin-bottom: 1.2rem; line-height: 1.5; min-height: 2rem; padding: 0 0.5rem; }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.option-btn { padding: 0.9rem 0.5rem; border: 2px solid var(--border); border-radius: 12px; background: var(--card); font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: all 0.15s; color: var(--text); }
.option-btn:hover { border-color: var(--purple); background: #f5f0ff; }
@media (hover: none) { .option-btn:hover { border-color: var(--border); background: var(--card); } }
.option-btn.correct { border-color: var(--green); background: #d1fae5; color: #065f46; animation: pulse 0.3s; }
.option-btn.wrong { border-color: var(--red); background: #fee2e2; color: #991b1b; animation: shake 0.3s; }
.option-btn.disabled { pointer-events: none; }
@keyframes pulse { 0%{transform:scale(1)}50%{transform:scale(1.04)}100%{transform:scale(1)} }
@keyframes shake { 0%,100%{transform:translateX(0)}25%{transform:translateX(-4px)}75%{transform:translateX(4px)} }
.game-feedback { text-align: center; margin-top: 1rem; font-size: 1.1rem; min-height: 2rem; }
.feedback-wrong { font-size: 0.9rem; text-align: center; }
.feedback-wrong-icon { font-size: 2rem; margin-bottom: 0.3rem; animation: shake 0.4s; }
.feedback-answer { color: var(--green); font-size: 1rem; margin-bottom: 0.5rem; font-weight: 600; }
.option-btn.correct { border-color: var(--green); background: #d1fae5; color: #065f46; animation: correctPulse 0.6s ease; box-shadow: 0 0 12px rgba(16,185,129,0.5); }
@keyframes correctPulse { 0%{transform:scale(1);box-shadow:0 0 0 rgba(16,185,129,0)} 50%{transform:scale(1.06);box-shadow:0 0 16px rgba(16,185,129,0.6)} 100%{transform:scale(1);box-shadow:0 0 12px rgba(16,185,129,0.5)} }
.btn-next-delayed { transition: opacity 0.3s ease; }
.feedback-explanation { background: #fef9e7; border: 1px solid var(--gold); border-radius: 10px; padding: 0.7rem; font-size: 0.8rem; color: #78350f; line-height: 1.5; text-align: left; }
.explanation-header { font-weight: 700; margin-bottom: 0.2rem; }
.explanation-body { white-space: pre-line; }

/* ============ RESULTS ============ */
.results-content { text-align: center; }
#results-title { font-size: 1.4rem; margin-bottom: 0.5rem; color: var(--text); }
.results-status { margin-bottom: 1.2rem; font-size: 0.9rem; }
.results-status .passed { color: var(--green); font-weight: 700; }
.results-status .failed { color: var(--red); font-weight: 600; }
.results-stats { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 1.5rem; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-value { font-size: 1.4rem; font-weight: bold; color: var(--text); }
.stat-label { font-size: 0.7rem; color: var(--text-light); }
.results-actions { display: flex; flex-direction: column; gap: 0.6rem; }

/* ============ LEADERBOARD ============ */
.leaderboard-table { margin-bottom: 1rem; }
.leaderboard-row { display: flex; align-items: center; padding: 0.65rem 0.7rem; border-radius: 10px; margin-bottom: 0.4rem; background: var(--bg); }
.leaderboard-row:nth-of-type(1) { background: #fef3c7; }
.leaderboard-row:nth-of-type(2) { background: #f3f4f6; }
.leaderboard-row:nth-of-type(3) { background: #fed7aa; }
.leaderboard-rank { width: 26px; font-weight: bold; font-size: 0.9rem; }
.leaderboard-avatar { font-size: 1.1rem; margin-right: 0.4rem; }
.leaderboard-name { flex: 1; font-weight: 600; color: var(--text); font-size: 0.85rem; }
.leaderboard-score { color: var(--gold); font-weight: 700; font-size: 0.8rem; }

/* Leaderboard tabs */
.leaderboard-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  background: var(--bg);
  padding: 0.3rem;
  border-radius: 12px;
}

.lb-tab {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-light);
  transition: all 0.2s;
}

.lb-tab.active {
  background: var(--card);
  color: var(--purple);
  box-shadow: var(--shadow);
}

.lb-grade-badge {
  display: inline-block;
  background: #ede9fe;
  color: var(--purple);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  margin-left: 0.3rem;
}

/* ============ DAILY REWARD ============ */
.daily-reward-content, .daily-reward-claimed { text-align: center; }
.daily-reward-icon { font-size: 2.8rem; margin-bottom: 0.4rem; }
.daily-streak { font-size: 0.8rem; color: var(--gold); font-weight: 600; margin-bottom: 0.7rem; }
.daily-reward-box { background: linear-gradient(135deg, #fef9e7, #fde68a); border: 2px solid var(--gold); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; }
.reward-label { font-size: 1rem; font-weight: 700; color: #78350f; }
.reward-desc { font-size: 0.78rem; color: #a16207; }
.daily-mystery-question { background: #f5f0ff; border: 2px solid var(--purple); border-radius: 12px; padding: 0.8rem; margin: 0.8rem 0; }
.mystery-q { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.6rem; color: var(--text); }
.daily-mystery-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.daily-mystery-options button { padding: 0.6rem; border: 2px solid var(--border); border-radius: 10px; background: var(--card); font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.daily-mystery-options button.correct { border-color: var(--green); background: #d1fae5; }
.daily-mystery-options button.wrong { border-color: var(--red); background: #fee2e2; }
.feedback-success-msg { text-align: center; padding: 2rem 0; }
.success-emoji { font-size: 2.5rem; margin-bottom: 0.7rem; }
.empty-state { text-align: center; padding: 1.5rem; color: var(--text-light); font-size: 0.85rem; }

/* ============ CONFETTI ============ */
.confetti-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; overflow: hidden; }
.confetti-piece { position: absolute; top: -10px; width: 10px; height: 10px; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0%{transform:translateY(0) rotate(0deg);opacity:1}100%{transform:translateY(100vh) rotate(720deg);opacity:0} }
.confetti-square { border-radius: 2px; }
.confetti-circle { border-radius: 50%; }

/* ============ RESPONSIVE ============ */

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
  .app { max-width: 600px; }
  .bottom-nav { max-width: 600px; }
  .home-greeting { padding: 1.1rem 1.3rem; }
  .worlds-carousel { gap: 0.8rem; }
  .world-carousel-card { min-width: 140px; padding: 1rem; }
  .options-grid { gap: 0.7rem; }
  .option-btn { padding: 1.1rem; font-size: 1.1rem; }
}

/* Desktop / Laptop */
@media (min-width: 769px) {
  body { align-items: center; padding: 1rem; }
  body:has(.screen-home.active) { padding: 0; align-items: stretch; }
  .app { max-width: 420px; min-height: auto; max-height: 90vh; overflow-y: auto; border-radius: 24px; box-shadow: var(--shadow-lg); background: var(--bg); }
  .screen { margin: 1rem; }
}

/* Small phones */
@media (max-width: 360px) {
  .home-greeting { flex-wrap: wrap; gap: 0.5rem; padding: 0.7rem; }
  .greeting-streak-box { width: 100%; display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
  .question-text { font-size: 0.95rem; }
  .options-grid { grid-template-columns: 1fr; }
  .world-carousel-card { min-width: 100px; }
  .avatar-selector { grid-template-columns: repeat(2, 1fr); }
}


/* Profile */
.profile-avatar-section { text-align: center; margin-bottom: 1.2rem; }
.profile-avatar { font-size: 3.5rem; margin-bottom: 0.3rem; }
.profile-name { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.profile-grade { font-size: 0.8rem; color: var(--text-light); }
.profile-stats-row { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 1.5rem; padding: 0.8rem; background: var(--bg); border-radius: 12px; }
.profile-stat { text-align: center; }
.ps-val { display: block; font-size: 1.2rem; font-weight: 800; color: var(--purple); }
.ps-lbl { font-size: 0.65rem; color: var(--text-light); }
.profile-section { margin-bottom: 1rem; }
.profile-section label span { display: block; font-weight: 600; font-size: 0.85rem; color: var(--text); margin-bottom: 0.4rem; }
.form-field-label { display: block; font-weight: 600; font-size: 0.85rem; color: var(--text); margin-bottom: 0.4rem; }


/* ============ ADVENTURE MAP ============ */
.screen-map { padding: 0 !important; margin: 0 !important; border-radius: 0 !important; box-shadow: none !important; overflow: hidden; max-width: 100vw !important; width: 100vw !important; position: fixed !important; top: 0; left: 0; z-index: 200; }
.screen-map.active { display: flex !important; flex-direction: column; height: 100vh; }

.map-topbar { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1rem; background: linear-gradient(135deg, #0f172a, #1e3a5f, #1e40af); flex-shrink: 0; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.map-title { flex: 1; }
.map-title-name { color: white; font-weight: 700; font-size: 0.95rem; }
.map-title-sub { color: rgba(255,255,255,0.6); font-size: 0.65rem; }
.map-top-stats { display: flex; gap: 0.4rem; }
.map-stat { background: rgba(255,255,255,0.15); color: white; padding: 0.2rem 0.5rem; border-radius: 10px; font-size: 0.7rem; font-weight: 600; }

.map-container { display: flex; flex: 1; overflow: hidden; }

/* Landscape (main map area) - uses background image */
.map-landscape {
  display: block !important;
  flex: 1; position: relative; overflow-y: auto; overflow-x: hidden;
  background: url('map-bg.png') center top / cover no-repeat;
  min-height: 500px;
}

/* Language arts (comunicacion) map background - uses grade-specific image with gradient fallback */
.map-landscape.map-comunicacion {
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 25%, #0f3460 50%, #533483 75%, #2c1654 100%);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}
.map-landscape.map-comunicacion::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(124, 58, 237, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 75% 60%, rgba(59, 130, 246, 0.12) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 85%, rgba(139, 92, 246, 0.1) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.map-start-badge { display: none; }

/* Map ambient decorations */
.map-deco {
  position: absolute;
  font-size: 1.5rem;
  pointer-events: none;
  z-index: 5;
  opacity: 0.7;
}
.deco-cloud { animation: cloudFloat 20s linear infinite; font-size: 2rem; opacity: 0.5; }
.deco-cloud-slow { animation-duration: 30s; animation-delay: -10s; }
@keyframes cloudFloat { 0% { transform: translateX(0); } 100% { transform: translateX(80px); } }

.deco-sparkle { animation: sparkleAnim 2s ease-in-out infinite; font-size: 1rem; }
.deco-sparkle-delay { animation-delay: 1s; }
@keyframes sparkleAnim { 0%,100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }

.deco-butterfly { animation: butterflyFly 6s ease-in-out infinite; font-size: 1.2rem; }
@keyframes butterflyFly { 0%,100% { transform: translate(0,0); } 25% { transform: translate(15px,-10px); } 50% { transform: translate(30px,5px); } 75% { transform: translate(10px,10px); } }

.deco-bird { animation: birdFly 8s linear infinite; font-size: 1rem; }
@keyframes birdFly { 0% { transform: translate(0,0); } 50% { transform: translate(40px,-15px); } 100% { transform: translate(80px,0); } }

/* Map events (cofres, portales, NPCs) */
.map-event {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 8;
  cursor: pointer;
  transition: transform 0.2s;
}
.map-event:hover { transform: scale(1.15); }
.map-event-icon { font-size: 1.5rem; animation: eventBounce 2s ease-in-out infinite; }
@keyframes eventBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.map-event-label {
  background: rgba(255,255,255,0.9);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.4rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  margin-top: 0.1rem;
}

/* Mobile map events */
@media (max-width: 767px) {
  .map-deco { font-size: 1rem; }
  .deco-cloud { font-size: 1.3rem; }
  .map-event-icon { font-size: 1.2rem; }
  .map-event-label { font-size: 0.35rem; }
}

/* Map overlay popups */
.map-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.map-popup {
  background: var(--card);
  border-radius: 20px;
  padding: 1.5rem;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: popupSlide 0.3s ease;
}
@keyframes popupSlide { 0% { transform: translateY(20px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

.map-popup-icon { font-size: 3rem; margin-bottom: 0.3rem; }
.map-popup h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 0.3rem; }
.map-popup-desc { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.8rem; }
.map-popup-question { font-size: 1.3rem; font-weight: 800; color: var(--purple); margin-bottom: 0.8rem; }
.map-popup-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-bottom: 0.8rem; }
.map-popup-btn {
  padding: 0.7rem; border: 2px solid var(--border); border-radius: 10px;
  background: var(--card); font-size: 1.1rem; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
}
.map-popup-btn:hover { border-color: var(--purple); background: #f5f0ff; }
.map-popup-btn.popup-correct { border-color: var(--green); background: #d1fae5; color: #065f46; }
.map-popup-btn.popup-wrong { border-color: var(--red); background: #fee2e2; color: #991b1b; }
.map-popup-close { background: none; border: none; color: var(--text-light); font-size: 0.75rem; cursor: pointer; margin-top: 0.3rem; }
.map-popup-close:hover { color: var(--text); }

/* NPC popup */
.map-popup-npc { padding: 1.5rem 1.2rem; }
.map-popup-nivi { width: 70px; height: 70px; object-fit: contain; margin-bottom: 0.5rem; }
.map-popup-msg { font-size: 0.9rem; color: var(--text); line-height: 1.5; margin-bottom: 1rem; font-weight: 600; }
.map-popup-close-btn {
  background: linear-gradient(135deg, var(--purple), var(--turquoise));
  color: white; border: none; padding: 0.6rem 1.2rem;
  border-radius: 10px; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
}
.map-popup-close-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(124,58,237,0.3); }

/* Mobile: map fullscreen, hide sidebar */
@media (max-width: 767px) {
  .map-container { flex-direction: column; }
  .map-landscape { min-height: 600px; height: 100%; background-size: cover; background-position: center; }
  .map-sidebar { display: none !important; }
  .mnode-circle { width: 40px; height: 40px; font-size: 1.1rem; }
  .mnode-label { max-width: 70px; }
  .mnode-label-name { font-size: 0.45rem; }
  .mnode-label-info { font-size: 0.38rem; }
  .mnode-num { width: 14px; height: 14px; font-size: 0.45rem; top: -4px; right: -4px; }
}

/* Map nodes positioned over the background image */
.mnode {
  position: absolute; display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: transform 0.2s; z-index: 10;
}
.mnode:hover:not(.mnode-locked) { transform: scale(1.12); }
.mnode-locked { opacity: 0.8; cursor: not-allowed; }

.mnode-circle {
  width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; border: 3px solid white; box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  position: relative; backdrop-filter: blur(2px);
}
.mnode-circle.active { background: rgba(124,58,237,0.85); animation: nodeGlow 2s ease-in-out infinite; }
.mnode-circle.locked { background: rgba(100,100,100,0.3); }
.mnode-circle.mastered { background: rgba(16,185,129,0.85); }

.mnode-num { position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; border-radius: 50%; background: #1e40af; color: white; font-size: 0.5rem; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 2px solid white; }
.mnode-locked .mnode-num { background: #6b7280; }
.mnode-circle.mastered + .mnode-label .mnode-num { background: var(--green); }

.mnode-status { position: absolute; bottom: -3px; left: 50%; transform: translateX(-50%); font-size: 0.7rem; }

.mnode-label { margin-top: 0.2rem; background: rgba(255,255,255,0.92); padding: 0.15rem 0.4rem; border-radius: 6px; text-align: center; max-width: 80px; box-shadow: 0 2px 6px rgba(0,0,0,0.15); backdrop-filter: blur(3px); }
.mnode-label-name { font-size: 0.5rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.mnode-label-info { font-size: 0.42rem; color: var(--text-light); }
.mnode-label-bar { height: 2px; background: #e0e0e0; border-radius: 1px; margin-top: 0.1rem; overflow: hidden; }
.mnode-label-bar-fill { height: 100%; background: var(--green); border-radius: 1px; }

/* Map nodes positioned organically */
.mnode {
  position: absolute; display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: transform 0.2s;
}
.mnode:hover:not(.mnode-locked) { transform: scale(1.08); }
.mnode-locked { opacity: 0.8; cursor: not-allowed; filter: grayscale(0); }

.mnode-circle {
  width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; border: 3px solid white; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  position: relative;
}
.mnode-circle.active { background: linear-gradient(135deg, #7c3aed, #2dd4bf); animation: nodeGlow 2s ease-in-out infinite; }
.mnode-circle.locked { background: rgba(120,120,140,0.3); }
.mnode-circle.mastered { background: linear-gradient(135deg, #10b981, #059669); }

.mnode-num { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: #1e40af; color: white; font-size: 0.55rem; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 2px solid white; }
.mnode-locked .mnode-num { background: #6b7280; }

.mnode-status { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); font-size: 0.8rem; }
.mnode-locked .mnode-status { font-size: 1.8rem; bottom: -8px; }

.mnode-label { margin-top: 0.3rem; background: rgba(255,255,255,0.9); padding: 0.2rem 0.5rem; border-radius: 8px; text-align: center; max-width: 100px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.mnode-label-name { font-size: 0.6rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.mnode-label-info { font-size: 0.5rem; color: var(--text-light); }
.mnode-label-bar { height: 3px; background: #e0e0e0; border-radius: 2px; margin-top: 0.15rem; overflow: hidden; }
.mnode-label-bar-fill { height: 100%; background: var(--green); border-radius: 2px; }

/* Sidebar - visible on tablet+, hidden on mobile */
.map-sidebar { display: block; width: 100%; background: var(--card); overflow-y: auto; padding: 1rem; flex-shrink: 0; }
.map-sb-header { text-align: center; margin-bottom: 1rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--border); }
.map-sb-label { font-size: 0.7rem; color: var(--text-light); }
.map-sb-area { font-size: 1rem; font-weight: 800; color: var(--text); }
.map-sb-pct { font-size: 2rem; font-weight: 800; color: var(--purple); margin: 0.3rem 0; }
.map-sb-detail { font-size: 0.7rem; color: var(--text-light); }
.map-sb-list { display: flex; flex-direction: column; gap: 0.4rem; }
.map-sb-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem; border-radius: 10px; border: 1px solid var(--border); font-size: 0.75rem; cursor: pointer; transition: all 0.2s; }
.map-sb-item:hover { border-color: var(--purple); transform: translateY(-1px); box-shadow: var(--shadow); }
.map-sb-item.sb-active { background: #f0f0ff; border-color: var(--purple); }
.map-sb-item.sb-locked { opacity: 0.9; cursor: not-allowed; border-style: dashed; border-color: #c4b5fd; }
.map-sb-item.sb-locked:hover { border-color: #c4b5fd; transform: none; box-shadow: none; }
.map-sb-item-icon { font-size: 1.1rem; }
.map-sb-item-info { flex: 1; }
.map-sb-item-name { font-weight: 600; color: var(--text); font-size: 0.72rem; }
.map-sb-item-detail { font-size: 0.6rem; color: var(--text-light); }
.map-sb-item-pct { font-size: 0.7rem; font-weight: 700; color: var(--purple); }
.map-sb-item.sb-locked .map-sb-item-pct { font-size: 1.8rem; }
.map-sb-tip { margin-top: 1rem; font-size: 0.65rem; color: var(--text-light); text-align: center; padding: 0.5rem; background: #fef9e7; border-radius: 8px; }

/* Mascot - hidden on mobile, shown on tablet+ via media query */
.map-mascot-float { display: none; }
.map-mascot-bubble { display: none; }
.map-mascot-char { display: none; }

/* Tablet+: show landscape map + sidebar side by side */
@media (min-width: 768px) {
  .map-landscape { display: block !important; overflow: hidden; }
  .map-sidebar { display: block; }
  .map-start-badge { display: block; position: absolute; top: 8px; left: 8%; background: rgba(16,185,129,0.9); color: white; padding: 0.25rem 0.6rem; border-radius: 10px; font-size: 0.65rem; font-weight: 700; z-index: 10; }
  .map-sidebar { width: 280px; border-left: 1px solid var(--border); }
  .map-mascot-float { display: flex !important; position: absolute; bottom: 10px; left: 1rem; align-items: flex-end; gap: 0.4rem; z-index: 20; }
  .map-mascot-bubble { display: block; background: rgba(255,255,255,0.95); border-radius: 10px 10px 10px 2px; padding: 0.4rem 0.6rem; font-size: 0.6rem; color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.1); max-width: 180px; }
  .map-mascot-char { display: block; font-size: 2rem; }
  .mnode-circle { width: 48px; height: 48px; font-size: 1.3rem; }
  .mnode-label { max-width: 85px; }
  .mnode-label-name { font-size: 0.5rem; }
}

@media (min-width: 1200px) {
  .map-sidebar { width: 340px; }
  .mnode-circle { width: 60px; height: 60px; font-size: 1.7rem; }
  .mnode-label { max-width: 110px; }
  .mnode-label-name { font-size: 0.62rem; }
}



/* ============ EXPLORATION BANNER ============ */
.exploration-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, #7c3aed, #3b82f6);
  color: white;
  border-radius: 0;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  z-index: 250;
  position: relative;
  flex-shrink: 0;
  animation: fadeIn 0.3s ease;
}
.exploration-banner-text {
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.exploration-banner-text strong {
  font-weight: 800;
}
.btn-back-grade {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-back-grade:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ============ HISTORY PROGRESS BAR ============ */
.history-bar {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  margin-top: 0.3rem;
  overflow: hidden;
}
.history-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #3b82f6);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Game exit button */
.game-exit { font-size: 1.2rem; color: var(--text-light); padding: 0.3rem; margin-right: 0.5rem; }
.game-exit:hover { color: var(--red); }


/* Home-specific styles are in home.css */

/* ============ ACHIEVEMENTS ============ */
.ach-summary { text-align: center; padding: 0.8rem; margin-bottom: 0.5rem; background: linear-gradient(135deg, #f5f0ff, #ede9fe); border-radius: 14px; }
.ach-summary-pct { font-size: 2rem; font-weight: 800; color: var(--purple); }
.ach-summary-text { font-size: 0.7rem; color: var(--text-light); }

.ach-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.6rem; overflow-x: auto; }
.ach-tab { padding: 0.4rem 0.7rem; border: none; border-radius: 8px; background: var(--bg); font-size: 0.7rem; font-weight: 600; cursor: pointer; color: var(--text-light); white-space: nowrap; }
.ach-tab.active { background: var(--purple); color: white; }

.ach-list { display: flex; flex-direction: column; gap: 0.4rem; }
.ach-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem; border-radius: 12px; border: 2px solid var(--border); background: var(--card); transition: all 0.2s; opacity: 0.5; filter: grayscale(0.5); }
.ach-item.ach-unlocked { opacity: 1; filter: none; transform: none; box-shadow: var(--shadow); }
.ach-item.ach-common.ach-unlocked { border-color: #6b7280; background: linear-gradient(135deg, #f9fafb, #f3f4f6); }
.ach-item.ach-rare.ach-unlocked { border-color: #3b82f6; background: linear-gradient(135deg, #eff6ff, #dbeafe); box-shadow: 0 2px 10px rgba(59,130,246,0.15); }
.ach-item.ach-epic.ach-unlocked { border-color: #7c3aed; background: linear-gradient(135deg, #f5f3ff, #ede9fe); box-shadow: 0 2px 12px rgba(124,58,237,0.2); }
.ach-item.ach-legendary.ach-unlocked { border-color: #f59e0b; background: linear-gradient(135deg, #fffbeb, #fef3c7); box-shadow: 0 4px 16px rgba(245,158,11,0.25); animation: legendaryGlow 2s ease-in-out infinite; }
@keyframes legendaryGlow { 0%,100% { box-shadow: 0 4px 16px rgba(245,158,11,0.2); } 50% { box-shadow: 0 4px 24px rgba(245,158,11,0.4); } }

.ach-item.ach-unlocked .ach-icon { font-size: 1.8rem; }
.ach-item:not(.ach-unlocked) .ach-icon { font-size: 1.3rem; }

.ach-icon { font-size: 1.5rem; flex-shrink: 0; }
.ach-info { flex: 1; min-width: 0; }
.ach-name { font-size: 0.8rem; font-weight: 700; color: var(--text); }
.ach-desc { font-size: 0.6rem; color: var(--text-light); margin-top: 0.1rem; }
.ach-badge { font-size: 0.5rem; font-weight: 700; padding: 0.15rem 0.4rem; border-radius: 6px; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.3px; }

.ach-progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 0.3rem; overflow: hidden; }
.ach-progress-fill { height: 100%; background: linear-gradient(90deg, var(--turquoise), var(--purple)); border-radius: 2px; }
.ach-progress-text { font-size: 0.5rem; color: var(--text-light); }

/* Achievement popup */
.achievement-popup { position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px); background: white; border-radius: 16px; padding: 0.8rem 1.2rem; box-shadow: 0 8px 30px rgba(0,0,0,0.2); z-index: 10000; transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); display: flex; align-items: center; gap: 0.6rem; max-width: 320px; }
.achievement-popup.show { transform: translateX(-50%) translateY(0); }
.achievement-popup-content { display: flex; align-items: center; gap: 0.6rem; }
.achievement-popup-icon { font-size: 2rem; }
.achievement-popup-text { flex: 1; }
.achievement-popup-title { font-size: 0.6rem; color: var(--gold); font-weight: 700; text-transform: uppercase; }
.achievement-popup-name { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.achievement-popup-desc { font-size: 0.65rem; color: var(--text-light); }

/* ============ MULTIPLY GAME ============ */
.mult-select { text-align: center; }
.mult-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-top: 0.8rem; }
.mult-btn { padding: 0.8rem; border: 2px solid var(--border); border-radius: 12px; background: var(--card); font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: all 0.2s; color: var(--text); }
.mult-btn:hover { border-color: var(--purple); background: #f5f0ff; transform: translateY(-2px); }
.mult-btn.mult-mix { grid-column: span 4; background: linear-gradient(135deg, var(--purple), var(--turquoise)); color: white; border: none; }

.mult-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.mult-timer { font-size: 1rem; font-weight: 700; color: var(--red); }
.mult-progress { font-size: 0.8rem; color: var(--text-light); }
.mult-score { font-size: 1rem; font-weight: 700; color: var(--gold); }
.mult-timer-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 1rem; }
.mult-timer-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--gold), var(--red)); border-radius: 3px; transition: width 0.1s linear; width: 100%; }
.mult-question { font-size: 1.5rem; font-weight: 800; text-align: center; color: var(--text); margin: 1.5rem 0; }
.mult-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.mult-opt { padding: 1rem; border: 2px solid var(--border); border-radius: 12px; background: var(--card); font-size: 1.2rem; font-weight: 700; cursor: pointer; transition: all 0.15s; text-align: center; }
.mult-opt:hover { border-color: var(--purple); background: #f5f0ff; }
.mult-opt.m-correct { border-color: var(--green); background: #d1fae5; }
.mult-opt.m-wrong { border-color: var(--red); background: #fee2e2; }
.mult-results-content { text-align: center; }
.mult-results-stats { display: flex; justify-content: center; gap: 1.5rem; margin: 1rem 0; }
.home-quickgames { padding: 0.7rem 0.8rem; }
.quickgames-scroll { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.qg-card { padding: 0.6rem 0.4rem; border-radius: 12px; text-align: center; cursor: pointer; transition: all 0.2s; border: 2px solid var(--border); background: var(--card); }
.qg-card:hover { border-color: var(--purple); transform: translateY(-2px); box-shadow: var(--shadow); }
.qg-card-icon { font-size: 1.3rem; margin-bottom: 0.15rem; }
.qg-card-name { font-size: 0.6rem; font-weight: 700; color: var(--text); }
.qg-card-desc { font-size: 0.45rem; color: var(--text-light); margin-top: 0.1rem; }
@media (max-width: 360px) { .quickgames-scroll { grid-template-columns: repeat(2, 1fr); } }


/* ============ ONBOARDING WIZARD (Multi-step) ============ */
.onb-progress { display: flex; justify-content: center; gap: 0.6rem; margin-bottom: 1.5rem; }
.onb-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); transition: all 0.3s ease; }
.onb-dot.active { background: var(--purple); transform: scale(1.3); }
.onb-dot.done { background: var(--green); }

.onb-step { display: none; animation: onbFadeIn 0.3s ease; text-align: center; }
.onb-step.active { display: block; }
@keyframes onbFadeIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.onb-title { font-size: 1.4rem; font-weight: 800; color: var(--navy); margin-bottom: 0.4rem; }
.onb-subtitle { font-size: 0.85rem; color: var(--text-light); margin-bottom: 1.5rem; font-weight: 500; }

.onb-input-big { width: 100%; padding: 1rem; font-size: 1.2rem; border: 2px solid var(--border); border-radius: 14px; text-align: center; font-weight: 600; color: var(--navy); transition: border-color 0.2s; }
.onb-input-big:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,58,237,0.1); }
.onb-input-big::placeholder { font-weight: 400; color: #aaa; }

/* Grade selector */
.onb-grade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.onb-grade-btn { padding: 1.2rem 0.5rem; font-size: 1.5rem; font-weight: 800; border: 3px solid var(--border); border-radius: 16px; background: var(--bg); color: var(--navy); cursor: pointer; transition: all 0.2s ease; }
.onb-grade-btn:hover { border-color: var(--purple); background: #f5f0ff; transform: translateY(-2px); }
.onb-grade-btn.selected { border-color: var(--purple); background: var(--purple); color: white; transform: scale(1.05); box-shadow: 0 4px 12px rgba(124,58,237,0.3); }

/* Avatar grid (larger) */
.onb-avatar-grid .avatar-preview { font-size: 2.2rem; }
.onb-avatar-grid .avatar-option { padding: 0.8rem 0.4rem; border-radius: 14px; }
.onb-avatar-grid .avatar-option.selected { transform: scale(1.08); }

/* Subject selector */
.onb-subject-grid { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1rem; }
.onb-subject-btn { display: flex; align-items: center; gap: 1rem; padding: 1.2rem 1.5rem; border: 2px solid var(--border); border-radius: 16px; background: white; cursor: pointer; transition: all 0.2s ease; text-align: left; }
.onb-subject-btn:hover { border-color: var(--purple); background: #f9f5ff; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(124,58,237,0.1); }
.onb-subject-btn.selected { border-color: var(--purple); background: linear-gradient(135deg, #f5f0ff, #ede9fe); box-shadow: 0 4px 16px rgba(124,58,237,0.2); }
.onb-subject-icon { font-size: 2rem; flex-shrink: 0; }
.onb-subject-name { font-size: 1rem; font-weight: 700; color: var(--navy); display: block; }
.onb-subject-desc { font-size: 0.75rem; color: var(--text-light); font-weight: 500; display: block; margin-top: 0.2rem; }

.onb-btn-next { margin-top: 1.2rem; width: 100%; }
.onb-btn-back { margin-top: 0.6rem; width: 100%; }

/* ============ QUICK GAMES SELECTION SCREEN ============ */
.qg-selection-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; padding: 0 0.5rem; }
.qg-sel-card { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem; background: var(--card); border: 2px solid var(--border); border-radius: 16px; cursor: pointer; transition: all 0.2s ease; text-align: center; }
.qg-sel-card:hover { border-color: var(--purple); background: #f9f5ff; transform: translateY(-3px); box-shadow: 0 6px 16px rgba(124,58,237,0.12); }
.qg-sel-card:active { transform: translateY(0); }
.qg-sel-icon { font-size: 2.2rem; margin-bottom: 0.6rem; }
.qg-sel-name { font-size: 0.95rem; font-weight: 700; color: var(--navy); margin-bottom: 0.2rem; }
.qg-sel-desc { font-size: 0.72rem; color: var(--text-light); font-weight: 500; }
@media (max-width: 380px) { .qg-selection-grid { grid-template-columns: 1fr; } }

/* ============ ADVENTURE SELECTOR (Header) ============ */
.header-adventure-selector { position: relative; }
.adventure-toggle { display: flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.8rem; background: rgba(124,58,237,0.08); border: 2px solid rgba(124,58,237,0.2); border-radius: 10px; cursor: pointer; transition: all 0.2s; font-size: 0.8rem; font-weight: 600; color: var(--navy); }
.adventure-toggle:hover { border-color: var(--purple); background: rgba(124,58,237,0.12); }
.adventure-toggle-icon { font-size: 1rem; }
.adventure-toggle-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adventure-toggle-arrow { font-size: 0.6rem; color: var(--text-light); transition: transform 0.2s; }
.adventure-toggle.open .adventure-toggle-arrow { transform: rotate(180deg); }
.adventure-dropdown { display: none; position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: white; border: 2px solid var(--border); border-radius: 14px; box-shadow: 0 8px 24px rgba(26,26,78,0.12); padding: 0.5rem; min-width: 220px; z-index: 100; animation: dropIn 0.2s ease; }
.adventure-dropdown.open { display: block; }
@keyframes dropIn { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.adventure-option { display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 0.8rem; border-radius: 10px; cursor: pointer; transition: all 0.15s; }
.adventure-option:hover { background: rgba(124,58,237,0.06); }
.adventure-option.active { background: rgba(124,58,237,0.1); border-left: 3px solid var(--purple); }
.adventure-opt-icon { font-size: 1.4rem; }
.adventure-opt-info { display: flex; flex-direction: column; }
.adventure-opt-name { font-size: 0.82rem; font-weight: 700; color: var(--navy); }
.adventure-opt-pct { font-size: 0.68rem; color: var(--text-light); font-weight: 600; }
@media (max-width: 480px) { .adventure-toggle-name { display: none; } .adventure-dropdown { min-width: 200px; left: 0; transform: none; } }

/* ============ ADVENTURE BAR (Desktop visible) ============ */
.adventure-bar { display: flex; gap: 0.8rem; margin: 1rem 0; }
.adventure-bar-btn { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 1.2rem; background: white; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; transition: all 0.2s ease; flex: 1; }
.adventure-bar-btn:hover { border-color: var(--purple); background: #f9f5ff; transform: translateY(-2px); }
.adventure-bar-btn.active { border-color: var(--purple); background: linear-gradient(135deg, #f5f0ff, #ede9fe); box-shadow: 0 3px 10px rgba(124,58,237,0.15); }
.adventure-bar-icon { font-size: 1.4rem; }
.adventure-bar-label { font-size: 0.85rem; font-weight: 700; color: var(--navy); }
.adventure-bar-pct { margin-left: auto; font-size: 0.75rem; font-weight: 700; color: var(--purple); background: rgba(124,58,237,0.1); padding: 0.2rem 0.5rem; border-radius: 6px; }

/* ============ HOME EMBEDDED MAP ============ */
.home-map-section { margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.home-map-container { background: var(--card); border-radius: 0; overflow: hidden; box-shadow: none; flex: 1; position: relative; min-height: 0; display: flex; flex-direction: column; }
.home-map-container .home-map-loading { text-align: center; padding: 3rem; color: var(--text-light); font-size: 0.9rem; }
.home-map-container .map-worlds-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.8rem; padding: 1rem; }
.home-map-world { display: flex; flex-direction: column; align-items: center; padding: 1rem 0.6rem; border: 2px solid var(--border); border-radius: 14px; cursor: pointer; transition: all 0.2s ease; text-align: center; background: white; }
.home-map-world:hover { border-color: var(--purple); transform: translateY(-3px); box-shadow: 0 4px 12px rgba(124,58,237,0.12); }
.home-map-world.locked { opacity: 0.5; cursor: not-allowed; }
.home-map-world.locked:hover { transform: none; border-color: var(--border); box-shadow: none; }
.home-map-world.current { border-color: var(--green); background: rgba(16,185,129,0.05); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.home-map-world-icon { font-size: 2rem; margin-bottom: 0.4rem; }
.home-map-world-name { font-size: 0.78rem; font-weight: 700; color: var(--navy); margin-bottom: 0.3rem; line-height: 1.2; }
.home-map-world-pct { font-size: 0.68rem; font-weight: 600; color: var(--text-light); }
.home-map-world-bar { width: 80%; height: 4px; background: var(--border); border-radius: 2px; margin-top: 0.4rem; overflow: hidden; }
.home-map-world-bar-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--turquoise)); border-radius: 2px; transition: width 0.3s; }
.home-map-world-lock { font-size: 1rem; opacity: 0.4; }

/* ============ COURSE HEADER (Combo Dropdown) ============ */
.course-header { position: fixed; top: 0; left: 0; right: 0; z-index: 90; background: var(--bg); padding: 0.3rem 1rem; box-shadow: 0 2px 8px rgba(26,26,78,0.06); display: flex; align-items: center; gap: 0.8rem; }
@media (min-width: 1024px) { .course-header { left: 220px !important; } }
.screen-home .home-main { padding-top: 44px; }
.ch-player-info { display: flex; align-items: center; gap: 0.5rem; }
.ch-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--purple), var(--turquoise)); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; color: white; border: 2px solid var(--purple); }
.ch-dragon-info { display: flex; align-items: center; gap: 0.4rem; }
.ch-dragon-img { width: 32px; height: 32px; object-fit: contain; }
.ch-player-text { display: flex; flex-direction: column; }
.ch-player-name { font-size: 0.78rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.ch-dragon-level { font-size: 0.6rem; font-weight: 600; color: var(--purple); }
.ch-player-grade { font-size: 0.6rem; font-weight: 600; color: var(--purple); }
.course-selector-btn { display: flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.7rem; background: white; border: 2px solid var(--purple); border-radius: 10px; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 2px 6px rgba(124,58,237,0.08); white-space: nowrap; font-size: 0.78rem; }
.course-selector-btn:hover { box-shadow: 0 4px 12px rgba(124,58,237,0.15); }
.course-sel-icon { font-size: 1rem; }
.course-sel-name { font-weight: 700; color: var(--navy); }
.course-sel-arrow { font-size: 0.7rem; color: var(--purple); transition: transform 0.2s; }
.course-selector-btn.open .course-sel-arrow { transform: rotate(180deg); }
.course-header-stats { display: flex; align-items: center; gap: 0.8rem; margin-left: auto; }
.ch-stat { display: flex; align-items: center; gap: 0.2rem; }
.ch-stat-icon { font-size: 0.8rem; }
.ch-stat-val { font-size: 0.8rem; font-weight: 800; color: var(--navy); }
.ch-stat-lbl { font-size: 0.6rem; color: var(--text-light); font-weight: 600; }
@media (max-width: 480px) { .ch-stat-lbl { display: none; } .course-header-stats { gap: 0.5rem; } .ch-player-grade { display: none; } }
.course-sel-arrow { font-size: 1rem; color: var(--purple); transition: transform 0.2s; }
.course-selector-btn.open .course-sel-arrow { transform: rotate(180deg); }
.course-dropdown { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: white; border: 2px solid var(--border); border-radius: 14px; box-shadow: 0 8px 24px rgba(26,26,78,0.12); overflow: hidden; animation: courseDropIn 0.2s ease; }
.course-dropdown.open { display: block; }
@keyframes courseDropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.course-dropdown-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.9rem 1.2rem; cursor: pointer; transition: all 0.15s; }
.course-dropdown-item:hover { background: rgba(124,58,237,0.05); }
.course-dropdown-item.active { background: rgba(124,58,237,0.08); border-left: 3px solid var(--purple); }
.course-dd-icon { font-size: 1.2rem; }
.course-dd-name { font-size: 0.9rem; font-weight: 700; color: var(--navy); flex: 1; }
.course-dd-pct { font-size: 0.75rem; font-weight: 700; color: var(--purple); }

/* ============ HOME FULL MAP IMAGE ============ */
.home-fullmap { position: relative; width: 100%; border-radius: 16px; overflow: hidden; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.home-fullmap:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(26,26,78,0.15); }
.home-fullmap-img { width: 100%; height: auto; display: block; min-height: 250px; object-fit: cover; }
.home-fullmap-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 1rem; background: linear-gradient(transparent, rgba(26,26,78,0.7)); display: flex; justify-content: center; }
.home-fullmap-cta { background: rgba(255,255,255,0.95); color: var(--navy); font-size: 0.9rem; font-weight: 700; padding: 0.5rem 1.5rem; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
