/* ---------- Hide Scrollbars ---------- */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

/* ---------- CSS Variables ---------- */
:root {
  --primary: #00b4ff;
  --primary-dark: #008ecc;
  --primary-light: #e0f4ff;
  --secondary: #1cb0f6;
  --secondary-dark: #0e8dd0;
  --accent: #ff9600;
  --accent-dark: #e08400;
  --danger: #ff4b4b;
  --danger-dark: #e03e3e;
  --success: #00b4ff;
  --warning: #ffc800;
  --purple: #1a365d;
  --purple-dark: #0a2e5c;
  --bg: #ffffff;
  --bg-card: #f0f9ff;
  --bg-card-hover: #e1f5ff;
  --bg-elevated: #ffffff;
  --text: #0a2e5c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border: #d1e9ff;
  --border-light: rgba(0, 180, 255, 0.1);
  --radius: 24px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shadow: 0 10px 30px rgba(0, 180, 255, 0.1);
  --shadow-premium: 0 0 25px rgba(0, 180, 255, 0.2);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  --glass: blur(12px) saturate(180%);
}

/* ============================================
   LinguaQuest - Main Stylesheet
   Educational English Learning Game
   ============================================ */


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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(
      circle at 10% 10%,
      rgba(88, 204, 2, 0.08) 0%,
      transparent 40%
    ),
    radial-gradient(
      circle at 90% 10%,
      rgba(28, 176, 246, 0.08) 0%,
      transparent 40%
    ),
    radial-gradient(
      circle at 50% 90%,
      rgba(206, 130, 255, 0.05) 0%,
      transparent 40%
    ),
    radial-gradient(
      circle at 50% 50%,
      rgba(255, 150, 0, 0.02) 0%,
      transparent 60%
    );
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative !important;
  z-index: 1;
  width: 100% !important;
  height: 100vh !important;
  background: var(--bg) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.screen-content,
.home-content,
.activation-content,
.quiz-content,
.results-content {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 15px; /* Reducido de 20px para ganar espacio lateral */
  flex: 1;
  word-break: break-word; /* Evita que palabras largas rompan el layout */
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ---------- Screens ---------- */
.screen { height: 100vh !important; overflow-y: auto !important; overflow-x: hidden !important; -webkit-overflow-scrolling: touch; 
  display: none;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  flex-direction: column;
  animation: fadeIn 0.4s ease;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  z-index: 5;
}

.screen.active {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  text-align: center !important;
  padding-top: 0 !important;
}

.home-content,
.activation-content,
.quiz-content,
.results-content,
.screen-content {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 30px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

@media (min-width: 768px) {
  .levels-container,
  .courses-container,
  .achievements-list {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px !important;
  }

  .level-card.wide,
  .achievement-card.wide {
    grid-column: span 2 !important;
  }

  .screen-content,
  .home-content,
  .activation-content,
  .quiz-content,
  .results-content {
    max-width: 1000px !important;
    padding: 40px !important;
  }

  .profile-stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

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

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

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

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

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

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}

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

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

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

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

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

/* ---------- Loading Screen ---------- */
#loading-screen {
  justify-content: center !important;
  align-items: center !important;
  background: var(--bg);
}

.loading-content {
  text-align: center;
  animation: scaleIn 0.5s ease;
}

.loading-logo {
  margin-bottom: 40px;
}

.logo-icon { height: auto !important; width: auto !important; 
  font-size: 80px;
  animation: float 3s ease-in-out infinite;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  width: 1em;
  height: 1em;
  object-fit: contain;
}

.logo-text {
  font-size: 44px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -2px;
}

.logo-text span {
  color: var(--primary);
}

.loading-bar-container {
  width: 240px;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  margin: 0 auto 20px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ---------- Activation Screen ---------- */
#activation-screen {
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

.activation-content {
  width: 100%;
  padding: 30px;
  max-width: 400px;
  text-align: center;
  animation: scaleIn 0.5s ease;
  margin: 0 auto; /* Centrado horizontal */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.activation-logo {
  margin-bottom: 30px;
}

.logo-badge { color: white !important; 
  display: inline-block;
  background: var(--purple);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(206, 130, 255, 0.3);
}

.activation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}

.activation-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
}

.activation-card p { color: #4a5568 !important; 
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 24px;
}

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

#activation-key-input { background: #ffffff !important; color: #0a2e5c !important; border: 2px solid #d1e9ff !important; 
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  font-size: 18px;
  text-align: center;
  letter-spacing: 2px;
  transition: var(--transition);
}

#activation-key-input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 15px rgba(206, 130, 255, 0.2);
}

.activation-btn { color: #ffffff !important; 
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(206, 130, 255, 0.3);
}

.activation-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(206, 130, 255, 0.4);
}

.activation-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.activation-info {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.activation-info p {
  font-size: 12px;
  margin-bottom: 0;
}

.activation-footer { color: #4a5568 !important; opacity: 1 !important; 
  margin-top: 30px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- Home Screen ---------- */
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2100 !important;
  transform: translateZ(10000px);
  width: 100%;
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}

.home-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon-sm {
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text-sm {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -1px;
}

.logo-text-sm span {
  color: var(--primary);
}

.home-stats-bar {
  display: flex;
  gap: 8px;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.stat-badge .stat-icon {
  font-size: 14px;
}

.home-content {
  padding: 20px;
  flex: 1;
}

.welcome-section {
  text-align: center;
  padding: 30px 0 20px;
  animation: slideDown 0.5s ease;
}

.welcome-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
}

@media (max-width: 480px) {
  .home-header {
    padding: 12px 14px !important;
  }
  .logo-text-sm {
    font-size: 18px !important;
  }
  .logo-icon-sm {
    font-size: 20px !important;
  }
  .home-stats-bar {
    gap: 4px !important;
  }
  .stat-badge {
    padding: 4px 6px !important;
    font-size: 11px !important;
  }
}

@media (max-width: 360px) {
  .logo-text-sm {
    display: none !important;
  }
}

.home-menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.5s ease 0.1s both;
  max-width: 500px;
  margin: 0 auto;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 22px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-family: var(--font);
}

.menu-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateX(4px);
}

.menu-btn:active {
  transform: translateX(2px) scale(0.99);
}

.menu-btn.play-btn { color: #ffffff !important; 
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary-dark);
  box-shadow: 0 4px 15px rgba(88, 204, 2, 0.3);
}

.menu-btn.play-btn:hover {
  box-shadow: 0 6px 20px rgba(88, 204, 2, 0.4);
  transform: translateX(4px);
}

.menu-btn-icon {
  font-size: 34px;
  width: 44px;
  text-align: center;
}

.menu-btn-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.btn-title {
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
}

.btn-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.play-btn .btn-desc {
  color: rgba(255, 255, 255, 0.8);
}

.menu-btn-arrow {
  font-size: 18px;
  color: var(--text-muted);
  transition: var(--transition);
}

.menu-btn:hover .menu-btn-arrow {
  color: var(--primary);
}

/* ---------- Screen Headers ---------- */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2100 !important;
  transform: translateZ(10000px);
  width: 100%;
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}

.screen-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.back-btn { color: #0a2e5c !important; border-color: #0a2e5c !important; 
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-family: var(--font);
}

.back-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.header-spacer {
  width: 38px;
}

.screen-content {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 40px;
}

/* ---------- Profile Screen ---------- */
.profile-card {
  text-align: center;
  padding: 30px 0;
  animation: slideDown 0.4s ease;
}

.profile-avatar {
  position: relative;
  display: inline-block;
  margin-bottom: 16px;
}

.avatar-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50px;
  box-shadow: 0 4px 20px rgba(88, 204, 2, 0.3);
}

.profile-level-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--accent);
  color: #000;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 12px;
  display: flex;
  gap: 2px;
  border: 3px solid var(--bg);
}

#profile-name {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.profile-title-text {
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
}

.profile-xp-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  animation: slideUp 0.4s ease 0.1s both;
}

.xp-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}

.xp-bar-container {
  height: 12px;
  background: var(--bg-elevated);
  border-radius: 6px;
  overflow: hidden;
}

.xp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 6px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.xp-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
  animation: slideUp 0.4s ease 0.2s both;
}

.profile-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.profile-stat-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 14px;
  opacity: 0.6;
}

.profile-recent-achievements h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.mini-achievements-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-achievement {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.mini-achievement.locked {
  opacity: 0.5;
}

.mini-achievement-icon {
  font-size: 24px;
  width: 36px;
  text-align: center;
}

.mini-achievement-info {
  flex: 1;
}

.mini-achievement-name {
  font-size: 14px;
  font-weight: 600;
}

.mini-achievement-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---------- Level Select ---------- */
.levels-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.level-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  animation: slideUp 0.4s ease both;
}

.level-card:nth-child(1) {
  animation-delay: 0s;
}
.level-card:nth-child(2) {
  animation-delay: 0.1s;
}
.level-card:nth-child(3) {
  animation-delay: 0.2s;
}

.level-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.level-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.level-card.locked:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: none;
}

.level-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.level-card.basic::before {
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
}
.level-card.intermediate::before {
  background: linear-gradient(90deg, var(--secondary), #4fc3f7);
}
.level-card.advanced::before {
  background: linear-gradient(90deg, var(--purple), var(--purple-dark));
}

.level-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.level-icon {
  font-size: 40px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.level-info {
  flex: 1;
}

.level-name {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 2px;
}

.level-description {
  font-size: 13px;
  color: var(--text-secondary);
}

.level-lock {
  font-size: 24px;
}

.level-progress {
  margin-top: 8px;
}

.level-progress-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.level-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.level-card.basic .level-progress-fill {
  background: var(--primary);
}
.level-card.intermediate .level-progress-fill {
  background: var(--secondary);
}
.level-card.advanced .level-progress-fill {
  background: var(--purple);
}

.level-progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
}

/* ---------- Course Select ---------- */
.courses-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 16px;
  animation: slideUp 0.3s ease both;
  backdrop-filter: blur(5px);
}

.course-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.course-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.course-card.locked:hover {
  transform: none;
  border-color: var(--border);
  background: var(--bg-card);
}

.course-card.completed {
  border-color: var(--primary);
}

.course-icon {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.course-info {
  flex: 1;
  min-width: 0;
}

.course-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 3px;
}

.course-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.course-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.course-status {
  font-size: 18px;
  flex-shrink: 0;
}

.course-progress-mini {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.course-progress-mini-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ---------- Quiz Screen ---------- */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}

.quiz-exit-btn {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 18px;
}

.quiz-exit-btn:hover {
  background: rgba(255, 75, 75, 0.1) !important;
  color: var(--danger) !important;
  border-color: var(--danger) !important;
  transform: rotate(90deg);
}

.quiz-progress-bar-container {
  flex: 1;
  height: 10px;
  background: var(--bg-elevated);
  border-radius: 5px;
  overflow: hidden;
}

.quiz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 5px;
  transition: width 0.5s ease;
  width: 0%;
}

.quiz-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.quiz-stats-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 30px;
  background: var(--bg-elevated);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-premium);
}

.quiz-score,
.quiz-streak,
.quiz-xp,
#quiz-question-number {
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Timer */
.timer-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.timer-circle {
  width: 70px;
  height: 70px;
  position: relative;
}

.timer-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 6;
}

.timer-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transition:
    stroke-dashoffset 1s linear,
    stroke 0.3s ease;
}

.timer-progress.warning {
  stroke: var(--warning);
}

.timer-progress.danger {
  stroke: var(--danger);
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 800;
}

/* Question */
.quiz-question-container {
  text-align: center;
  margin-bottom: 24px;
  animation: slideDown 0.3s ease;
}

.question-category {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-weight: 500;
}

.question-text {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
}

.question-hint {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

/* Options */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
  flex: 1;
}

@media (min-width: 600px) {
  .quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
}

.option-btn {
  width: 100%;
  padding: 20px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(5px);
}

.option-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.option-btn:active:not(:disabled) {
  transform: translateX(2px) scale(0.99);
}

.option-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.option-text {
  flex: 1;
}

.option-btn.correct {
  background: rgba(88, 204, 2, 0.15);
  border-color: var(--success);
  animation: pulse 0.3s ease;
}

.option-btn.correct .option-letter {
  background: var(--success);
  color: #000;
  border-color: var(--success);
}

.option-btn.incorrect {
  background: rgba(255, 75, 75, 0.15);
  border-color: var(--danger);
  animation: shake 0.3s ease;
}

.option-btn.incorrect .option-letter {
  background: var(--danger);
  color: var(--text);
  border-color: var(--danger);
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Feedback */
.quiz-feedback {
  display: none;
  flex-direction: column;
  text-align: center;
  background: var(--bg-card);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  margin: auto;
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  animation: zoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: var(--glass);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.feedback-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px 30px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

.feedback-footer {
  padding: 20px 30px 30px;
  background: linear-gradient(to top, var(--bg-card) 80%, transparent);
  width: 100%;
}


.quiz-feedback.show {
  display: flex;
}

@keyframes popCorrect {
  0% { transform: scale(0.9); opacity: 0; }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 1; }
}

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

.quiz-feedback.correct {
  border-color: var(--success);
  background: rgba(88, 204, 2, 0.1);
  animation: popCorrect 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.quiz-feedback.incorrect {
  border-color: var(--danger);
  background: rgba(255, 75, 75, 0.1);
  animation: shakeIncorrect 0.4s ease-in-out;
}

@keyframes pulseIcon {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.feedback-icon {
  font-size: 42px;
  margin-bottom: 12px;
  animation: pulseIcon 1.5s infinite;
}

.feedback-text {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}

.feedback-explanation {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.4;
}

.feedback-next-btn {
  padding: 12px 32px;
  background: var(--primary);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.feedback-next-btn:hover {
  background: var(--primary-light);
  transform: scale(1.02);
}

/* ---------- Results Screen ---------- */
#results-screen {
  justify-content: center !important;
  align-items: center !important;
  padding: 20px;
}

.results-content {
  width: 100%;
  max-width: 400px;
}

.results-header-section {
  text-align: center;
  margin-bottom: 24px;
  animation: bounceIn 0.5s ease;
}

.results-emoji {
  font-size: 64px;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

.results-title {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Write Question Styles */
.quiz-input-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 10px;
  animation: fadeIn 0.3s ease;
}

#quiz-write-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  color: var(--text);
  font-size: 18px;
  text-align: center;
  transition: var(--transition);
}

#quiz-write-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(88, 204, 2, 0.2);
}

.quiz-submit-btn {
  background: var(--primary);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(88, 204, 2, 0.2);
}

.quiz-submit-btn:hover {
  background: var(--primary-light);
  transform: translateY(-2px);
}

/* Order Question Styles */
.quiz-order-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.order-slots {
  width: 100%;
  min-height: 60px;
  background: var(--bg-elevated);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  transition: var(--transition);
}

.order-slots.highlight {
  border-color: var(--primary);
  background: rgba(88, 204, 2, 0.05);
}

.order-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.order-token {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.order-token:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.order-token.dragging {
  opacity: 0.5;
}

/* Reading Comprehension */
.quiz-reading-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
  animation: fadeIn 0.3s ease;
}
.quiz-reading-passage {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  line-height: 1.6;
  color: var(--text-secondary);
  font-size: 15px;
}
.quiz-reading-subtitle {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
}
.quiz-reading-question-text {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.quiz-reading-options {
  display: grid;
  gap: 10px;
}

/* Sentence Puzzle */
.quiz-puzzle-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  animation: fadeIn 0.3s ease;
}
.quiz-puzzle-instruction {
  font-weight: 600;
  margin-bottom: 8px;
}
.quiz-puzzle-tokens-label,
.quiz-puzzle-answer-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.quiz-puzzle-tokens {
  min-height: 50px;
}
.quiz-puzzle-answer {
  min-height: 56px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.puzzle-token {
  cursor: pointer;
}

/* Analytics Dashboard */
.analytics-content {
  padding: 0 4px;
}
.analytics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
}
.analytics-card-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
}
.analytics-card-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}
.analytics-section {
  margin-top: 24px;
}
.analytics-section-title {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-secondary);
}
.analytics-chart-container {
  min-height: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.analytics-no-data {
  color: var(--text-muted);
  font-size: 14px;
}

/* Teacher Dashboard */
.teacher-dashboard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.teacher-tab {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
}
.teacher-tab:hover {
  border-color: var(--primary);
  color: var(--text);
}
.teacher-tab.active {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
}
.teacher-dashboard-content {
  padding: 16px;
  width: 100%;
}
.teacher-tab-panel {
  display: none;
}
.teacher-tab-panel.active {
  display: block;
  width: 100%;
}
.teacher-code-box,
.teacher-form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}
.teacher-stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
  width: 100%;
}
.teacher-stat-card {
  flex: 1 1 120px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}
.teacher-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}
.teacher-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}
.teacher-alerts {
  margin-top: 16px;
}
.teacher-alert-card {
  background: rgba(255, 75, 75, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-xs);
  padding: 12px;
  margin-bottom: 8px;
}
.teacher-student-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  margin-bottom: 8px;
  cursor: pointer;
}
.teacher-student-row:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}
.teacher-student-name {
  font-weight: 600;
}
.teacher-student-detail {
  padding: 16px;
}
.teacher-comment-section {
  margin-top: 16px;
}
.teacher-comment-section textarea {
  width: 100%;
  min-height: 80px;
  margin: 8px 0;
  padding: 8px;
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.teacher-assignment-row {
  display: flex;
  gap: 16px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.teacher-form-section input {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 8px 0;
  padding: 10px;
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.student-assignment-row {
  align-items: center;
}
.student-assignment-row button.small {
  padding: 8px 12px;
  font-size: 13px;
}
.assignment-overdue {
  color: var(--danger);
  font-size: 12px;
}

/* Matching Question Styles */
.quiz-matching-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
  animation: fadeIn 0.3s ease;
  align-items: start;
}

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

.matching-item {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.matching-item:hover {
  border-color: var(--secondary);
}

.matching-item.selected {
  border-color: var(--primary);
  background: rgba(88, 204, 2, 0.1);
  box-shadow: 0 0 10px rgba(88, 204, 2, 0.3);
}

.matching-item.matched {
  opacity: 0.5;
  cursor: default;
  border-color: var(--success);
  background: rgba(88, 204, 2, 0.05);
}

.results-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

.results-score-circle {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
  animation: scaleIn 0.5s ease 0.2s both;
}

.score-circle {
  width: 140px;
  height: 140px;
  position: relative;
}

.score-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 8;
}

.score-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339;
  stroke-dashoffset: 339;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.score-percent {
  font-size: 32px;
  font-weight: 900;
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  animation: slideUp 0.4s ease 0.3s both;
}

.result-stat {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
}

.result-stat.highlight {
  border-color: var(--primary);
  background: rgba(88, 204, 2, 0.1);
}

.result-stat.highlight .result-stat-value {
  color: var(--primary);
}

.result-stat-icon {
  font-size: 22px;
  display: block;
  margin-bottom: 4px;
}

.result-stat-value {
  font-size: 20px;
  font-weight: 800;
  display: block;
}

.result-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.results-achievements {
  margin-bottom: 16px;
  animation: slideUp 0.4s ease 0.4s both;
}

.results-achievement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  animation: bounceIn 0.5s ease;
}

.results-achievement-icon {
  font-size: 28px;
}

.results-achievement-info h4 {
  font-size: 14px;
  font-weight: 700;
}

.results-achievement-info p {
  font-size: 12px;
  color: var(--text-secondary);
}

.results-unlock {
  text-align: center;
  background: linear-gradient(
    135deg,
    rgba(88, 204, 2, 0.1),
    rgba(28, 176, 246, 0.1)
  );
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  animation: bounceIn 0.5s ease 0.5s both;
}

.unlock-icon {
  font-size: 32px;
  margin-bottom: 4px;
}

.results-buttons {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  animation: slideUp 0.4s ease 0.5s both;
}

.results-btn {
  flex: 1;
  min-width: 140px;
  max-width: 200px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: var(--font);
}

.results-btn.primary {
  background: var(--primary);
  color: #000;
}

.results-btn.primary:hover {
  background: var(--primary-light);
  transform: scale(1.02);
}

.results-btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.results-btn.secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.results-btn.rematch-btn {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: #000;
  margin-bottom: 5px;
}

.results-btn.rematch-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

/* ---------- Achievements Screen ---------- */
.achievements-summary {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-secondary);
}

.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
  animation: slideUp 0.3s ease both;
}

.achievement-card.unlocked {
  border-color: var(--primary);
  background: rgba(88, 204, 2, 0.05);
}

.achievement-card.locked {
  opacity: 0.5;
}

.achievement-icon-large {
  font-size: 36px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.achievement-card.unlocked .achievement-icon-large {
  background: rgba(88, 204, 2, 0.15);
}

.achievement-info {
  flex: 1;
}

.achievement-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 3px;
}

.achievement-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.achievement-status {
  font-size: 20px;
  flex-shrink: 0;
}

/* ---------- Settings Screen ---------- */
.settings-group {
  margin-bottom: 24px;
}

.settings-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.setting-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.setting-item label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.setting-item input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: var(--transition);
}

.setting-item input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88, 204, 2, 0.1);
}

.toggle-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-setting label:first-child {
  margin-bottom: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  margin-bottom: 0 !important;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 28px;
  transition: var(--transition);
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 2px;
  bottom: 2px;
  background: var(--text);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background: #000;
}

.avatar-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.avatar-option {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  font-size: 22px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-option:hover {
  border-color: var(--primary);
  transform: scale(1.1);
}

.avatar-option.selected {
  border-color: var(--primary);
  background: rgba(88, 204, 2, 0.15);
  box-shadow: 0 0 0 3px rgba(88, 204, 2, 0.2);
}

.settings-danger-btn {
  width: 100%;
  padding: 14px;
  background: rgba(255, 75, 75, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.settings-danger-btn:hover {
  background: rgba(255, 75, 75, 0.2);
}

.settings-save-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #000;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.settings-save-btn:hover {
  background: var(--primary-light);
  transform: scale(1.02);
}

/* ---------- Instructions Screen ---------- */
.instructions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.instruction-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  animation: slideUp 0.3s ease both;
}

.instruction-card:nth-child(1) {
  animation-delay: 0s;
}
.instruction-card:nth-child(2) {
  animation-delay: 0.05s;
}
.instruction-card:nth-child(3) {
  animation-delay: 0.1s;
}
.instruction-card:nth-child(4) {
  animation-delay: 0.15s;
}
.instruction-card:nth-child(5) {
  animation-delay: 0.2s;
}
.instruction-card:nth-child(6) {
  animation-delay: 0.25s;
}
.instruction-card:nth-child(7) {
  animation-delay: 0.3s;
}
.instruction-card:nth-child(8) {
  animation-delay: 0.35s;
}

.instruction-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.instruction-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.instruction-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---------- Modals ---------- */
.modal-overlay {
  display: none;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  animation: scaleIn 0.3s ease;
}

.modal-content h3 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-content p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.modal-btn.cancel {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.modal-btn.cancel:hover {
  background: var(--bg-card-hover);
}

.modal-btn.confirm {
  background: var(--primary);
  color: #000;
}

.modal-btn.confirm:hover {
  background: var(--primary-light);
}

/* Name Modal */
.name-modal-content {
  padding: 32px;
}

.name-modal-icon {
  font-size: 56px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.name-modal-content h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.name-modal-content p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.narrative-block {
  margin-bottom: 30px;
  padding: 25px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  position: relative;
}

.story-translate-link {
  display: inline-block;
  margin-top: 15px;
  font-size: 14px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.story-translate-link:hover {
  opacity: 1;
}

.name-input {
  width: 100%;
  padding: 14px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  text-align: center;
  font-family: var(--font);
  font-weight: 600;
  margin-bottom: 16px;
  transition: var(--transition);
}

.name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88, 204, 2, 0.1);
}

.name-confirm-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

/* Level Up Modal */
.levelup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.levelup-overlay.show {
  display: flex;
}

.levelup-content {
  text-align: center;
  animation: bounceIn 0.5s ease;
  position: relative;
  padding: 40px;
}

.levelup-icon {
  font-size: 80px;
  margin-bottom: 16px;
  animation: float 2s ease-in-out infinite;
}

.levelup-content h2 {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 8px;
  color: var(--warning);
}

.levelup-level {
  font-size: 48px;
  font-weight: 900;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.levelup-text {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

.levelup-btn {
  padding: 14px 40px;
  background: var(--primary);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.levelup-btn:hover {
  background: var(--primary-light);
  transform: scale(1.05);
}

/* ---------- Toast / XP Popup ---------- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  box-shadow: var(--shadow);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast-icon {
  font-size: 18px;
}

.toast-text {
  font-size: 14px;
  font-weight: 600;
}

.xp-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  pointer-events: none;
  z-index: 250;
  opacity: 0;
  text-shadow: 0 2px 10px rgba(255, 150, 0, 0.5);
}

.xp-popup.show {
  animation: xpFloat 1.2s ease forwards;
}

@keyframes xpFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -80%) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -150%) scale(0.8);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  #app {
    max-width: 100%;
    margin: 0;
    height: 100vh;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  .screen { height: 100vh !important; overflow-y: auto !important; overflow-x: hidden !important; -webkit-overflow-scrolling: touch; 
    position: fixed;
  }

  .results-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .result-stat-value {
    font-size: 16px;
  }

  .result-stat-label {
    font-size: 10px;
  }

  .results-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .results-btn {
    max-width: none;
  }

  .profile-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Role Selection ---------- */
.role-cards-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 30px 0;
}

.role-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center !important; /* Centrado interno */
  display: flex;
  flex-direction: column;
  align-items: center !important; /* Centrar iconos y texto */
  gap: 4px;
}

.role-card:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.role-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.role-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.role-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.back-btn-float { color: #0a2e5c !important; background: #ffffff !important; border: 1px solid #d1e9ff !important; 
  position: absolute;
  top: 20px;
  left: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  z-index: 10;
}

.student-btn {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  box-shadow: 0 4px 15px rgba(28, 176, 246, 0.3);
}

/* ---------- Teacher Dashboard ---------- */
.teacher-dashboard {
  padding: 20px 0;
}

.code-generator-box {
  background: var(--bg-elevated);
  padding: 24px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-bottom: 20px;
}

.big-code {
  font-family: "Courier New", Courier, monospace;
  font-size: 36px;
  font-weight: 900;
  color: var(--primary);
  margin: 20px 0;
  letter-spacing: 5px;
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
  border: 1px dashed var(--primary);
}

.license-info-box {
  display: flex;
  justify-content: space-around;
  padding: 15px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.mini-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.mini-stat .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.status-badge {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.key-display {
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 4px 8px;
  border-radius: 4px;
}
.whatsapp-contact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(37, 211, 102, 0.1);
  color: #25d366;
  padding: 8px 16px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  margin-top: 10px;
  transition: var(--transition);
  border: 1px solid rgba(37, 211, 102, 0.2);
}

.whatsapp-contact:hover {
  background: rgba(37, 211, 102, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.1);
}

.modal-header-simple {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  position: relative;
}

.close-modal-x {
  position: absolute;
  top: -15px;
  right: -15px;
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 10px;
  transition: var(--transition);
}

.close-modal-x:hover {
  color: var(--text);
  transform: scale(1.1);
}

/* ========== SHOP SYSTEM ========== */
.coins-badge {
  background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(255,170,0,0.08)) !important;
  border-color: rgba(255,215,0,0.3) !important;
}

.shop-category { margin-bottom: 28px; }
.shop-category-title {
  font-size: 18px; font-weight: 800; margin-bottom: 4px;
}
.shop-category-desc {
  font-size: 13px; color: var(--text-muted); margin-bottom: 14px;
}
.shop-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.shop-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
  transition: all 0.25s ease; position: relative; overflow: hidden;
}
.shop-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: 0 8px 25px rgba(0,0,0,0.2); }
.shop-card.owned { border-color: rgba(88,204,2,0.3); }
.shop-card.active-item { border-color: var(--primary); background: rgba(88,204,2,0.06); }
.shop-card.active-item::after {
  content: '✓'; position: absolute; top: 8px; right: 10px;
  font-size: 14px; color: var(--primary); font-weight: 900;
}
.shop-card-icon { font-size: 40px; margin-bottom: 8px; }
.shop-card-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.shop-card-desc { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; min-height: 28px; }
.shop-buy-btn {
  width: 100%; padding: 8px 12px; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, #ffd700, #ffaa00); color: #1a1a2e;
  transition: all 0.2s ease; font-family: var(--font);
}
.shop-buy-btn:hover { transform: scale(1.04); filter: brightness(1.1); }
.shop-buy-btn.disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.5); }
.shop-buy-btn.owned { background: var(--primary); color: #000; }
.shop-buy-btn.active { background: var(--bg-elevated); color: var(--text-muted); cursor: default; }

/* ========== ENHANCED ANALYTICS DASHBOARD ========== */
.stats-hero {
  display: flex; align-items: center; gap: 16px;
  padding: 20px; margin-bottom: 20px;
  background: linear-gradient(135deg, rgba(88,204,2,0.08), rgba(28,176,246,0.05));
  border-radius: var(--radius); border: 1px solid var(--border);
}
.stats-hero-avatar { font-size: 48px; }
.stats-hero-info h2 { font-size: 20px; font-weight: 800; margin-bottom: 2px; }
.stats-hero-info p { font-size: 13px; color: var(--text-muted); }

.analytics-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px;
}
.analytics-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 10px; text-align: center;
  transition: var(--transition);
}
.analytics-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.analytics-card-value { font-size: 20px; font-weight: 800; margin-bottom: 2px; }
.analytics-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Streak fire animations */
.streak-hot { color: #ff6b35 !important; animation: fireGlow 1.5s ease-in-out infinite alternate; }
.streak-legendary { color: #ff4500 !important; animation: fireGlow 0.8s ease-in-out infinite alternate; text-shadow: 0 0 12px rgba(255,69,0,0.5); }
@keyframes fireGlow {
  from { filter: brightness(1); } to { filter: brightness(1.3); }
}

/* Course strength bars */
.course-strength-list { display: flex; flex-direction: column; gap: 10px; }
.strength-bar-row { display: flex; align-items: center; gap: 10px; }
.strength-name { font-size: 13px; font-weight: 600; min-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strength-bar-track {
  flex: 1; height: 10px; background: var(--bg-elevated);
  border-radius: 5px; overflow: hidden;
}
.strength-bar-fill {
  height: 100%; border-radius: 5px;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.strength-bar-fill.strong { background: linear-gradient(90deg, #58CC02, #7ce02a); }
.strength-bar-fill.weak { background: linear-gradient(90deg, #ff6b35, #ff4b4b); }
.strength-pct { font-size: 12px; font-weight: 700; min-width: 36px; text-align: right; }

/* Records grid */
.records-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.record-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; text-align: center;
}
.record-val { display: block; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.record-label { font-size: 11px; color: var(--text-muted); }

.analytics-section { margin-bottom: 20px; }
.analytics-section-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.analytics-chart-container { background: var(--bg-card); border-radius: var(--radius-sm); padding: 12px; border: 1px solid var(--border); }
.analytics-no-data { text-align: center; color: var(--text-muted); font-size: 13px; padding: 20px; }

@media (max-width: 480px) {
  .shop-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .analytics-cards { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .analytics-card-value { font-size: 16px; }
  .strength-name { min-width: 70px; font-size: 11px; }
}

/* --- CONTENT PROTECTION --- */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

/* ============================================
   DESKTOP OPTIMIZATIONS (PC)
   ============================================ */

.desktop-sidebar {
  display: none; /* Oculto en móvil */
}



/* ============================================
   PREMIUM DESKTOP REDESIGN (PC)
   ============================================ */



/* ============================================
   FIXED DESKTOP TRANSFORMATION (PC)
   ============================================ */



/* ============================================
   FIXED DESKTOP ARCHITECTURE (PC)
   ============================================ */



/* ============================================
   MOBILE-PLUS PC EXPERIENCE
   ============================================ */



/* ============================================
   FULL SCREEN PC ADAPTATION
   ============================================ */

@media (min-width: 1024px) {
  /* Expand the app container to use full width */
  #app {
    max-width: none;
    width: 100%;
  }

  /* Widen the home content area */
  .home-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 40px;
  }

  /* Welcome section stretches */
  .welcome-section {
    max-width: none;
  }

  /* Menu becomes a 2-column grid */
  .home-menu {
    max-width: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  /* Buttons fill the space with more breathing room */
  .menu-btn {
    padding: 28px 30px;
  }

  .menu-btn:hover {
    transform: translateY(-3px);
  }

  /* Make "JUGAR" span both columns for emphasis */
  .menu-btn.play-btn {
    grid-column: 1 / -1;
  }

  /* Ensure text never truncates */
  .btn-title {
    white-space: nowrap;
    overflow: visible;
    text-overflow: unset;
  }

  /* Wider screens for other pages too */
  .screen-content {
    max-width: 900px;
    margin: 0 auto;
  }
}

/* ============================================
   SHIO AI CHAT
   ============================================ */

/* Trigger button (Inline in Quiz Builder) */
.shio-trigger-btn {
  background: linear-gradient(135deg, #0a2e5c, #00b4ff) !important;
  color: white !important;
  border: none !important;
  border-radius: 12px !important; /* Redondeado suave, no cuadrado */
  padding: 10px 18px !important;
  font-weight: 700;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.2);
}

.shio-trigger-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 180, 255, 0.35);
}

/* Floating version (Tutor) */
.shio-floating-btn {
  position: fixed !important;
  bottom: 25px !important;
  right: 25px !important;
  width: 60px !important;
  height: 60px !important;
  border-radius: 50% !important;
  z-index: 9998 !important;
  display: flex !important;
  padding: 0 !important;
  font-size: 24px !important;
}

/* Modal overlay */
.shio-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 46, 92, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}
.shio-modal.active {
  opacity: 1;
  pointer-events: auto;
}

/* Chat container */
.shio-container {
  width: 95%;
  max-width: 480px;
  height: 85vh;
  max-height: 750px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  transform: translateY(40px) scale(0.9);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.shio-modal.active .shio-container {
  transform: translateY(0) scale(1);
}

/* Header */
.shio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  background: linear-gradient(135deg, #0a2e5c, #005a99);
  color: white;
  flex-shrink: 0;
}
.shio-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.shio-logo {
  font-size: 28px;
  background: rgba(255,255,255,0.2);
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shio-title {
  font-size: 19px;
  font-weight: 800;
  margin: 0;
}
.shio-subtitle {
  font-size: 11px;
  opacity: 0.8;
}
.shio-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shio-close-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: rotate(90deg);
}

/* Messages area */
.shio-messages, .roleplay-chat-messages, .story-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
}

/* Avatar */
.shio-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0a2e5c, #00b4ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* Base Message Container */
.shio-msg {
  display: flex;
  gap: 12px;
  max-width: 100%;
  width: 100%;
  align-items: flex-end;
}

.shio-msg-bot {
  justify-content: flex-start;
}

.shio-msg-user {
  justify-content: flex-end;
}

/* Bubbles */
.shio-bubble {
  max-width: 75%; /* Ajuste para PC para que no sea excesivo */
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
  word-wrap: break-word;
}

/* En móvil, permitimos más ancho pero sin estirar el layout */
@media (max-width: 600px) {
  .shio-bubble {
    max-width: 90%;
  }
}

.shio-bubble-bot {
  background: white;
  color: var(--text);
  border: 1px solid #edf2f7;
  border-top-left-radius: 4px;
}

.shio-bubble-user {
  background: linear-gradient(135deg, #00b4ff, #0090d0);
  color: white;
  border-top-right-radius: 4px;
}

/* Typing Indicator Animation */
.shio-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px !important;
  align-items: center;
  min-width: 60px;
}

.shio-typing span {
  width: 8px;
  height: 8px;
  background: #cbd5e1;
  border-radius: 50%;
  display: inline-block;
  animation: shio-typing-anim 1.4s infinite ease-in-out both;
}

.shio-typing span:nth-child(1) { animation-delay: -0.32s; }
.shio-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes shio-typing-anim {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* Input bar */
.shio-input-bar {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #edf2f7;
  background: white;
  flex-shrink: 0;
}
.shio-input {
  flex: 1;
  padding: 12px 18px;
  border: 2px solid #edf2f7;
  border-radius: 14px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: #f8fafc;
  transition: all 0.3s ease;
}
.shio-input:focus {
  outline: none;
  border-color: #00b4ff;
  background: white;
}
.shio-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #00b4ff, #0090d0);
  color: white;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.3);
}
.shio-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 15px rgba(0, 180, 255, 0.4);
}

/* ---------- Stories Grid ---------- */
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 20px 0;
  animation: slideUp 0.5s ease;
}

.story-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 220px;
}

.story-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--primary);
  box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.story-card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.story-card-icon {
  font-size: 44px;
  margin-bottom: 12px;
}

.story-card h3 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 8px 0;
  color: var(--text);
}

.story-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 16px;
}

.story-start-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px;
  font-weight: 700;
  font-size: 13px;
  transition: all 0.2s;
}

/* ---------- Story Chat View ---------- */
.story-chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 65px); /* Más espacio sin el nav inferior */
  background: #f8fafc;
}

.story-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
}

.story-msg-bot { align-self: flex-start; }
.story-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.story-avatar {
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.story-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  position: relative;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  word-wrap: break-word;
}

.story-msg-bot .story-bubble {
  background: white;
  color: var(--text);
  border-top-left-radius: 4px;
}

.story-msg-user .story-bubble {
  background: var(--primary);
  color: white;
  border-top-right-radius: 4px;
}

.story-speaker-name {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 4px;
  opacity: 0.7;
}

.story-text {
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- Story Choices ---------- */
.story-choices-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 15px;
  background: white;
  border-top: 1px solid var(--border);
  z-index: 10;
}

.story-choice-btn {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.story-choice-btn:hover {
  background: #f0fdf4;
  border-color: var(--primary);
  transform: translateY(-2px);
}

.choice-number {
  background: var(--primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.choice-text {
  font-size: 12px; /* Texto de opciones más pequeño */
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

/* ---------- Back Button Fix ---------- */
.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  transition: all 0.2s;
  color: var(--text);
  padding: 0;
  margin-right: 10px;
}

.back-btn:hover {
  background: #f1f5f9;
  transform: translateX(-3px);
}

/* ---------- Company Footer ---------- */
.company-footer {
  padding: 20px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.company-footer p {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0;
}

@keyframes animate-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-slide-up { animation: animate-slide-up 0.4s ease; }

/* ── ONBOARDING ── */
.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  pointer-events: auto; /* Block background clicks */
}

.onboarding-spotlight {
  position: fixed;
  z-index: 10001;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  pointer-events: none;
  transition: all 0.3s ease;
  border: 3px solid var(--accent);
}

.onboarding-bubble {
  position: fixed;
  z-index: 10002;
  width: 300px;
  background: var(--bg-card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  display: none;
  flex-direction: column;
  gap: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: auto; /* Allow button clicks */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: onboardingPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.onboarding-shio {
  width: 45px;
  height: 45px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: -5px;
}

.onboarding-shio img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.onboarding-content p {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 15px 0;
}

.onboarding-actions {
  display: flex;
  justify-content: flex-end;
}

.onboarding-actions button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  transition: transform 0.1s;
}

.onboarding-actions button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.15);
}

@keyframes onboardingPop {
  from { opacity: 0; transform: scale(0.8) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
