/* Modern CSS Design System for Cuestionario IM-PROVE */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Color system - Sleek Dark Theme base */
  --bg-app: #0b0f19;
  --bg-card: rgba(22, 28, 45, 0.6);
  --border-card: rgba(255, 255, 255, 0.08);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary-glow: rgba(99, 102, 241, 0.15);
  
  /* Subject Theme Hues */
  --hue-matematicas: 195;  /* Cyan/Teal */
  --hue-lectura: 35;       /* Amber/Orange */
  --hue-ciudadanas: 265;   /* Violet/Indigo */
  --hue-ciencias: 142;     /* Emerald/Green */
  --hue-ingles: 340;       /* Rose/Pink */

  /* UI Colors */
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --radius-lg: 20px;
  --radius-md: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Outfit', sans-serif;
}

/* Base resets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 40%);
}

/* Background Animated Orbs */
.bg-orb {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  filter: blur(100px);
  z-index: 0;
  opacity: 0.3;
  pointer-events: none;
  transition: var(--transition);
}
.orb-1 {
  top: 10%;
  left: 5%;
  background: hsl(var(--subject-hue, 240), 70%, 50%);
}
.orb-2 {
  bottom: 10%;
  right: 5%;
  background: hsl(var(--subject-hue, 160), 60%, 40%);
}

/* Layout container */
#app {
  width: 100%;
  max-width: 900px;
  min-height: 600px;
  margin: 20px;
  padding: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  z-index: 10;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Header styles */
header {
  margin-bottom: 25px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 40%, hsl(var(--subject-hue, 240), 100%, 75%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Subject Badges */
.subject-badge {
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: hsl(var(--subject-hue, 240), 25%, 15%);
  border: 1px solid hsl(var(--subject-hue, 240), 50%, 35%);
  color: hsl(var(--subject-hue, 240), 100%, 75%);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Progress bar container */
.progress-container {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, 
    hsl(var(--subject-hue, 240), 80%, 60%), 
    hsl(var(--subject-hue, 240), 100%, 70%)
  );
  width: 0%;
  border-radius: 50px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px hsl(var(--subject-hue, 240), 80%, 60%);
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
}

/* Active Area CSS Variables set via JavaScript */
.area-matematicas { --subject-hue: var(--hue-matematicas); }
.area-lectura { --subject-hue: var(--hue-lectura); }
.area-ciudadanas { --subject-hue: var(--hue-ciudadanas); }
.area-ciencias { --subject-hue: var(--hue-ciencias); }
.area-ingles { --subject-hue: var(--hue-ingles); }

/* Screens layout */
.screen {
  display: none;
  animation: fadeIn 0.4s ease-out;
  flex-direction: column;
  flex: 1;
}

.screen.active {
  display: flex;
}

/* Welcome/Lobby Screen */
.lobby-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 25px;
}

.subject-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 25px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: hsl(var(--card-hue), 80%, 60%);
  opacity: 0.8;
}

.subject-card:hover {
  transform: translateY(-8px);
  background: rgba(255, 255, 255, 0.05);
  border-color: hsl(var(--card-hue), 50%, 40%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25), 0 0 20px rgba(99, 102, 241, 0.05);
}

.subject-icon {
  font-size: 2.5rem;
  margin-bottom: 5px;
  transition: var(--transition);
}

.subject-card:hover .subject-icon {
  transform: scale(1.2) rotate(5deg);
}

.subject-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.subject-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.subject-progress-pill {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 10px;
  border-radius: 50px;
  margin-top: 10px;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Study / Explanation Screen */
.study-content {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 30px;
  margin-bottom: 25px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.study-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 15px;
  color: hsl(var(--subject-hue, 240), 100%, 75%);
}

.study-intro {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 25px;
}

.topic-item {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.topic-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.topic-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topic-content {
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.6;
  padding-left: 5px;
}

.topic-content code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: hsl(var(--subject-hue, 240), 100%, 80%);
}

.study-tips {
  margin-top: 15px;
  background: hsl(var(--subject-hue, 240), 30%, 10%);
  border: 1px dashed hsl(var(--subject-hue, 240), 40%, 30%);
  padding: 20px;
  border-radius: var(--radius-md);
}

.study-tips h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: hsl(var(--subject-hue, 240), 100%, 75%);
  display: flex;
  align-items: center;
  gap: 8px;
}

.study-tips ul {
  list-style-type: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.study-tips li {
  font-size: 0.9rem;
  position: relative;
  padding-left: 20px;
  line-height: 1.4;
}

.study-tips li::before {
  content: '⚡';
  position: absolute;
  left: 0;
}

/* Quiz screen split panel */
.quiz-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.split-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .split-layout {
    grid-template-columns: 1.1fr 0.9fr;
  }
}

.reading-panel {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 20px;
  max-height: 550px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  scrollbar-width: thin;
}

.question-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.01);
  padding: 10px 5px;
}

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

/* Interactive Option Buttons */
.option-btn {
  width: 100%;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
  outline: none;
}

.option-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  border-color: hsl(var(--subject-hue, 240), 60%, 50%);
  transform: translateX(4px);
}

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

.option-letter {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  transition: var(--transition);
  flex-shrink: 0;
}

.option-btn:hover .option-letter {
  background: hsl(var(--subject-hue, 240), 80%, 60%);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Feedback classes */
.option-btn.correct {
  background: rgba(16, 185, 129, 0.1) !important;
  border-color: var(--color-success) !important;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
  animation: correctPulse 0.5s ease-out;
}

.option-btn.correct .option-letter {
  background: var(--color-success) !important;
  color: #ffffff !important;
}

.option-btn.incorrect {
  background: rgba(239, 68, 68, 0.08) !important;
  border-color: var(--color-error) !important;
  animation: shake 0.5s ease-in-out;
}

.option-btn.incorrect .option-letter {
  background: var(--color-error) !important;
  color: #ffffff !important;
}

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

/* Feedback panel styling */
.feedback-panel {
  background: rgba(22, 28, 45, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 20px 25px;
  margin-top: 10px;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-header {
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.feedback-header.correct {
  color: var(--color-success);
}

.feedback-header.incorrect {
  color: var(--color-error);
}

.feedback-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

/* Footer Navigation Controls */
.quiz-footer {
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  z-index: 20;
}

/* Action Buttons */
.btn {
  padding: 14px 28px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: flex;
  align-items: center;
  gap: 10px;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, 
    hsl(var(--subject-hue, 240), 85%, 60%), 
    hsl(var(--subject-hue, 240), 95%, 65%)
  );
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4), 0 0 15px hsl(var(--subject-hue, 240), 80%, 65%);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Results Screen card */
.results-card {
  text-align: center;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 25px;
}

.trophy-container {
  position: relative;
  font-size: 5rem;
  animation: float 3s ease-in-out infinite;
}

.results-score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 8px solid rgba(255, 255, 255, 0.04);
  border-top-color: hsl(var(--subject-hue, 240), 85%, 60%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.1);
  margin: 10px 0;
}

.results-score {
  font-size: 2.8rem;
  font-weight: 850;
  color: #ffffff;
  line-height: 1;
}

.results-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.results-badge {
  padding: 8px 16px;
  border-radius: 50px;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--color-warning);
  color: var(--color-warning);
}

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

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

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

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

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

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Confetti canvas */
#confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  border-radius: var(--radius-lg);
}
