/* CSS Variables for design system */
:root {
  --primary: #1e1b4b; /* Deep Navy */
  --primary-light: #312e81;
  --secondary: #4f46e5; /* Indigo */
  --secondary-light: #6366f1;
  --accent: #fbbf24; /* Vibrant Gold */
  --accent-hover: #f59e0b;
  --success: #10b981; /* Mint Green */
  --danger: #ef4444; /* Alert Red */
  --bg: #faf5ff; /* Light purple tint bg */
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header & Navigation */
header.app-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.01);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
}

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

.nav-links {
  display: flex;
  list-style: none;
  gap: 25px;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-light);
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  padding: 6px 12px;
  border-radius: 8px;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--secondary);
  background: #f1f5f9;
}

.btn-register {
  background: linear-gradient(135deg, var(--secondary), var(--primary-light));
  color: white !important;
  font-weight: 600 !important;
  padding: 10px 20px !important;
  border-radius: 50px !important;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.btn-register:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(79, 70, 229, 0.4);
}

/* App Main Content */
main.app-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Views Section */
.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

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

/* Redesigned Homepage Hero */
.hero-section {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
  background: linear-gradient(135deg, #1e1b4b, #3b0764);
  color: white;
  border-radius: 24px;
  padding: 60px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 50px;
  position: relative;
  overflow: hidden;
}

.hero-bg-accent {
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 60%);
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
}

.hero-tagline {
  background: rgba(251, 191, 36, 0.2);
  color: var(--accent);
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hero-content h1 {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 20px;
}

.hero-content h1 span {
  color: var(--accent);
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}

.hero-content p {
  font-size: 1.15rem;
  color: #cbd5e1;
  margin-bottom: 30px;
  max-width: 500px;
}

.hero-buttons {
  display: flex;
  gap: 15px;
}

.btn-primary {
  background: var(--accent);
  color: var(--primary);
  font-weight: 700;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(251, 191, 36, 0.4);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(251, 191, 36, 0.5);
}

.btn-secondary {
  background: transparent;
  color: white;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  font-weight: 600;
  padding: 14px 28px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: white;
  background: rgba(255,255,255,0.05);
}

.hero-graphic {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
}

.badge-float {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: float 4s ease-in-out infinite;
}

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

.badge-float img {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.badge-float span {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

/* Home Section Layouts */
.section-title {
  text-align: center;
  font-size: 2rem;
  color: var(--primary);
  font-weight: 800;
  margin-bottom: 40px;
}

.homepage-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 25px;
  margin-bottom: 60px;
}

.step-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform 0.2s ease;
}

.step-card:hover {
  transform: translateY(-5px);
}

.step-num {
  width: 45px;
  height: 45px;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 auto 20px auto;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.step-card h3 {
  font-size: 1.15rem;
  color: var(--primary);
  margin-bottom: 10px;
}

.step-card p {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* General Layout Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}

/* Practice Game Styles */
.game-portal {
  display: grid;
  grid-template-columns: 2.8fr 1.2fr;
  gap: 30px;
}

.grade-selector {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 25px;
}

.grade-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.grade-btn:hover {
  border-color: var(--secondary-light);
}

.grade-btn.active {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.game-header-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 30px;
}

.game-tab-btn {
  background: none;
  border: none;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.game-tab-btn:hover {
  color: var(--secondary);
}

.game-tab-btn.active {
  color: var(--secondary);
}

.game-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--secondary);
  border-radius: 3px 3px 0 0;
}

/* Sound Controller Buttons */
.controls-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 20px;
}

.ctrl-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-light);
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.ctrl-btn:hover {
  color: var(--secondary);
  border-color: var(--secondary-light);
}

.ctrl-btn.active {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

/* Game Playing Screens */
.game-play-area {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 40px;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
}

.game-card-view {
  width: 100%;
  max-width: 500px;
}

.riddle-question {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 25px;
}

.game-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  width: 100%;
  margin-bottom: 20px;
}

.game-opt-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}

.game-opt-btn:hover {
  background: #f8fafc;
  border-color: var(--secondary-light);
  transform: scale(1.02);
}

.game-opt-btn.correct {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.game-opt-btn.wrong {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.photo-display {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  background: white;
}

/* Game Score Results Overlay */
.game-results {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
}

.results-icon {
  font-size: 4rem;
  color: var(--accent);
  animation: popScale 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popScale {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.results-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  margin: 15px 0 10px 0;
}

.results-score {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--secondary);
  margin-bottom: 20px;
}

.rank-alert {
  background: #d1fae5;
  color: var(--success);
  border-radius: 50px;
  padding: 6px 18px;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 30px;
  animation: pulse 2s infinite;
}

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

/* Leaderboard Sidebar styling */
.leaderboard-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px 20px;
  box-shadow: var(--shadow);
  align-self: start;
}

.leaderboard-panel h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #f1f5f9;
}

.leaderboard-row.active {
  background: #f5f3ff;
  border-color: #ddd6fe;
}

.leaderboard-row.top3:nth-child(1) { background: #fffbeb; border-color: #fef3c7; }
.leaderboard-row.top3:nth-child(2) { background: #f8fafc; border-color: #e2e8f0; }
.leaderboard-row.top3:nth-child(3) { background: #fff7ed; border-color: #ffedd5; }

.leaderboard-rank {
  width: 25px;
  font-weight: 700;
  color: var(--text-light);
}
.leaderboard-row.top3:nth-child(1) .leaderboard-rank { color: #d97706; }

.leaderboard-name {
  flex-1;
  font-weight: 600;
  font-size: 0.9rem;
}

.leaderboard-points {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--secondary);
}

/* Portal Student Login/Dash */
.portal-container {
  max-width: 800px;
  margin: 0 auto;
}

.portal-login-card {
  max-width: 400px;
  margin: 40px auto;
  text-align: center;
}

.portal-login-card h2 {
  font-size: 1.8rem;
  margin-bottom: 25px;
  color: var(--primary);
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input, .form-group select {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  outline: none;
}

.form-group input:focus {
  border-color: var(--secondary-light);
}

.btn-block {
  width: 100%;
  display: block;
}

/* Student Dashboard View */
.student-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 30px;
}

.student-info h2 {
  font-size: 1.5rem;
  color: var(--primary);
}

.rounds-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.round-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 25px;
  background: white;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 240px;
  position: relative;
}

.round-card.locked {
  background: #f8fafc;
  opacity: 0.7;
}

.round-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.round-status {
  margin-bottom: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.round-status.passed { color: var(--success); }
.round-status.locked { color: var(--text-light); }
.round-status.active { color: var(--secondary-light); }
.round-status.waiting { color: var(--accent-hover); }

.round-btn {
  background: var(--secondary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

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

.round-btn:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}

/* Timed Quiz Interface layout */
.quiz-container {
  max-width: 700px;
  margin: 0 auto;
}

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

.timer-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fee2e2;
  color: var(--danger);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 0.95rem;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 10px;
  margin-bottom: 30px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--success);
  width: 0%;
  transition: width 0.3s ease;
}

/* Certificate Area layout */
.cert-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
  border: 1px solid #d1fae5;
  border-radius: 16px;
  padding: 40px;
  margin-top: 30px;
  text-align: center;
}

.cert-card-view {
  max-width: 480px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}

/* Admin Dashboard layout */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.metric-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.metric-num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 5px;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 500;
}

.admin-tables-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.table-header h3 {
  font-size: 1.2rem;
  color: var(--primary);
}

.datatable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.datatable th, .datatable td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}

.datatable th {
  background: #f8fafc;
  font-weight: 600;
}

.datatable tr:last-child td {
  border-bottom: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Scheduler block layout */
.scheduler-panel {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  background: #f8fafc;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Cheating Warn popups */
.cheat-warning-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.cheat-warning-overlay.active {
  display: flex;
}

.cheat-warning-card {
  background: white;
  border-radius: 16px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border-top: 6px solid var(--danger);
}

.cheat-warning-card h3 {
  color: var(--danger);
  margin-bottom: 10px;
}

/* Confetti styling */
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--accent);
  opacity: 0.8;
  animation: confettiFall 2.5s ease-out infinite;
}

@keyframes confettiFall {
  0% { transform: translateY(-50px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(400px) rotate(360deg); opacity: 0; }
}

/* Responsive queries */
@media (max-width: 992px) {
  .hero-section {
    grid-template-columns: 1fr;
    padding: 40px;
  }
  .homepage-steps {
    grid-template-columns: repeat(2, 1fr);
  }
  .game-portal {
    grid-template-columns: 1fr;
  }
  .rounds-grid {
    grid-template-columns: 1fr;
  }
  .metrics-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 576px) {
  .homepage-steps {
    grid-template-columns: 1fr;
  }
  .metrics-row {
    grid-template-columns: 1fr;
  }
  .game-options-grid {
    grid-template-columns: 1fr;
  }
}
