/* ── Access Gate ─────────────────────────────────────── */
.access-gate {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #053775 0%, #1a56a0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.access-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px 36px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.access-logo { height: 64px; object-fit: contain; margin-bottom: 4px; }
.access-title { font-family: 'Poppins', sans-serif; font-size: 1.4rem; font-weight: 700; color: #053775; margin: 0; }
.access-sub { font-size: 0.88rem; color: #64748b; margin: 0; }
.access-input {
  width: 100%; padding: 12px 16px;
  border: 2px solid #cbd5e1; border-radius: 10px;
  font-size: 1rem; font-weight: 600; text-align: center;
  letter-spacing: 0.08em; text-transform: uppercase;
  outline: none; transition: border-color 0.2s; box-sizing: border-box;
}
.access-input:focus { border-color: #3174c4; }
.access-btn {
  width: 100%; background: #053775; color: #fff;
  font-weight: 700; font-size: 1rem; padding: 12px;
  border-radius: 10px; cursor: pointer; transition: background 0.2s;
}
.access-btn:hover { background: #3174c4; }
.access-error { color: #dc2626; font-size: 0.82rem; font-weight: 600; margin: 0; }
.access-gate.hidden { display: none; }
.student-badge {
  display: flex;
  align-items: center;
  background: #e0f2fe;
  color: #053775;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 50px;
  white-space: nowrap;
  border: 1px solid #93c5fd;
}
.logout-btn {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 50px;
  border: 1px solid #fde68a;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.logout-btn:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}
/* ── End Access Gate ─────────────────────────────────── */

:root {
  --primary: #053775;
  --primary-light: #0d4a96;
  --secondary: #f5cc2c;
  --secondary-hover: #ed9011;
  --accent: #3174c4;
  --accent-hover: #265ba1;
  --success: #10b981;
  --danger: #ef4444;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #334155;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 20px;
  --radius-sm: 12px;
}

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

body {
  font-family: "Poppins", "Inter", sans-serif;
  background: linear-gradient(135deg, #053775 0%, #031d3d 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 30px 15px 50px;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s ease;
}

/* ===== CONTAINER ===== */
.container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.05),
    0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 30px 32px 40px;
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
.brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.logo {
  height: 60px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
}

.brand-text {
  text-align: center;
}

.brand-text h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.tagline {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

.header-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.score-board,
.streak-display {
  font-size: 1rem;
  font-weight: 700;
  border-radius: 50px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-board {
  background: #fef3c7; /* Amber 100 */
  color: #b45309; /* Amber 700 */
  border: 1px solid #fde68a;
}

.streak-display {
  background: #fee2e2; /* Red 100 */
  color: #b91c1c; /* Red 700 */
  border: 1px solid #fecaca;
  animation: streakPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.streak-display.hidden,
.hidden {
  display: none !important;
}

/* ===== APP LAYOUT & SIDEBAR ===== */
.app-layout {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 600px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .grade-sidebar {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 10px;
  }
}

.grade-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.grade-tab {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--background);
  color: var(--text);
  border: 1px solid var(--border);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

.grade-tab:hover {
  background: #f1f5f9; /* Slate 100 */
  border-color: #cbd5e1;
}

.grade-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

/* Locked level */
.grade-tab.locked {
  opacity: 0.42;
  cursor: not-allowed;
  background: var(--border);
  color: var(--text-muted);
  border-color: transparent;
  position: relative;
}
.grade-tab.locked::after {
  content: '🔒';
  font-size: 0.75rem;
  margin-left: auto;
}
.grade-tab.locked:hover {
  background: var(--border);
  border-color: transparent;
  transform: none;
}

/* Sidebar unlock progress bar */
.sidebar-progress {
  margin-top: 6px;
  padding: 8px 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}
.up-rule {
  color: #78350f;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 7px;
  padding-bottom: 7px;
  border-bottom: 1px dashed #fde68a;
}
.up-count {
  color: #92400e;
  font-weight: 600;
  margin-bottom: 5px;
}
.up-track {
  height: 6px;
  background: #fde68a;
  border-radius: 50px;
  overflow: hidden;
}
.up-fill {
  height: 100%;
  background: var(--secondary-hover);
  border-radius: 50px;
  transition: width 0.4s ease;
}

/* ===== UNLOCK CELEBRATION MODAL ===== */
.unlock-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 55, 117, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInBg 0.3s ease;
}
.unlock-modal.hidden {
  display: none !important;
}
@keyframes fadeInBg {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.unlock-modal-card {
  background: white;
  border-radius: var(--radius);
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  animation: popIn 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.unlock-stars {
  font-size: 2.5rem;
  margin-bottom: 8px;
  animation: spin 1s ease;
}
@keyframes spin {
  from { transform: rotate(-20deg) scale(0.8); }
  to   { transform: rotate(0deg)   scale(1);   }
}
.unlock-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 10px;
}
.unlock-level-name {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  background: #eff6ff;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 14px;
}
.unlock-sub {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== PICK-TECHNIQUE PROMPT ===== */
.pick-prompt {
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  text-align: center;
  letter-spacing: 0.2px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.technique-selector {
  background: var(--background);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.technique-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tech-bubble {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 50px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.tech-bubble:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tech-bubble.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.explanation-box {
  background: #eff6ff; /* Blue 50 */
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  font-size: 0.95rem;
}

.explanation-box h3 {
  color: var(--accent-hover);
  font-size: 1rem;
  margin-bottom: 6px;
}

.explanation-box ol.e-steps {
  margin: 8px 0 10px 20px;
  padding: 0;
}

.explanation-box ol.e-steps li {
  margin-bottom: 5px;
  font-size: 0.88rem;
  line-height: 1.55;
}

.explanation-box .e-eg {
  background: white;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.85;
  border: 1px solid var(--border);
  margin-top: 6px;
}

/* ===== SESSION TIMER BAR ===== */
.session-timer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
  row-gap: 6px;
}

.session-timer-label {
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0.9;
  white-space: nowrap;
}

.session-time-digits {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 3px;
  color: var(--secondary);
  min-width: 80px;
  text-align: center;
  line-height: 1;
}

.timer-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  overflow: hidden;
  order: 10;
}

.timer-progress-fill {
  height: 100%;
  background: var(--secondary);
  border-radius: 50px;
  transition: width 1s linear;
}

/* ===== CONTROLS ===== */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px;
  background: var(--background);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.mode-selector {
  display: flex;
  gap: 8px;
  background: var(--border);
  padding: 4px;
  border-radius: 50px;
}

.mode-btn {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 50px;
  background: transparent;
  color: var(--text-muted);
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sound-btn {
  background: transparent;
  padding: 6px 10px;
}
.sound-btn.muted {
  opacity: 0.5;
}

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

.start-btn {
  background: var(--secondary);
  color: var(--primary);
  font-weight: 800;
  padding: 10px 24px;
  border-radius: 50px;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(245, 204, 44, 0.35);
}
.start-btn:hover {
  background: var(--secondary-hover);
  transform: translateY(-1px);
}

.stop-btn {
  background: var(--danger);
  color: white;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 50px;
  font-size: 1rem;
}
.stop-btn:hover {
  background: #dc2626;
}

/* ===== PRACTICE AREA ===== */
.practice-area {
  background: #fff;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  transition: all 0.3s ease;
}

.practice-area:focus-within {
  border-color: var(--accent);
  background: #f8fafc;
}

.question {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
  line-height: 1;
}

input[type="number"] {
  font-family: inherit;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
  padding: 12px 20px;
  width: 100%;
  max-width: 280px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--background);
  transition: all 0.2s;
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(49, 116, 196, 0.15);
  background: #fff;
}

.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

#check-btn {
  background: var(--accent);
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 12px 32px;
  border-radius: 50px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}
#check-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.hint-btn {
  background: #fef3c7;
  color: #b45309;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 50px;
}
.hint-btn:hover {
  background: #fde68a;
}

.skip-btn {
  background: var(--border);
  color: var(--text);
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 50px;
}
.skip-btn:hover {
  background: #cbd5e1;
}

/* ===== FEEDBACK ===== */
.feedback {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  text-align: center;
  transform: scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback.correct {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
  transform: scale(1);
  opacity: 1;
}

.feedback.incorrect {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
  transform: scale(1);
  opacity: 1;
}

/* ===== RIDDLE STRIP ===== */
.riddle-strip {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.riddle-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.riddle-strip-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.riddle-btn {
  background: var(--secondary);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 7px 16px;
  border-radius: 50px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(245, 204, 44, 0.35);
  flex-shrink: 0;
}
.riddle-btn:hover {
  background: var(--secondary-hover);
}

.riddle-box {
  margin-top: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.riddle-close-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.riddle-close-btn:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.riddle-question {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.55;
}

.riddle-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.riddle-reveal-btn,
.riddle-next-btn {
  background: var(--accent);
  color: white;
  padding: 7px 16px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.82rem;
}
.riddle-reveal-btn:hover,
.riddle-next-btn:hover {
  background: var(--accent-hover);
}

.riddle-answer {
  font-size: 0.9rem;
  font-weight: 600;
  color: #92400e;
  background: white;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed #fbbf24;
  line-height: 1.5;
}

/* ===== ANIMATIONS ===== */
@keyframes streakPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Session Summary */
.session-summary {
  background: var(--surface);
  border: 2px solid var(--secondary);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  position: relative;
  box-shadow: 0 10px 25px rgba(245, 204, 44, 0.15);
}

.summary-title {
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 20px;
  font-weight: 800;
}
.close-summary {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 1.5rem;
  color: var(--text-muted);
  background: transparent;
}
.close-summary:hover {
  color: var(--danger);
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.stat-value {
  color: var(--primary);
  font-size: 1rem;
}
.stat-grade {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.stat-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 50px;
  overflow: hidden;
  margin-bottom: 16px;
}
.stat-bar-fill {
  height: 100%;
  border-radius: 50px;
  transition: width 1s ease-out;
  background: var(--success);
}
.speed-bar {
  background: var(--secondary);
}

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  animation: confettiFall 1.5s ease-out forwards;
}
@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.3);
    opacity: 0;
  }
}

.score-board.on-fire {
  animation: fireGlow 0.5s infinite alternate;
}
@keyframes fireGlow {
  from {
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
  }
  to {
    box-shadow: 0 0 20px rgba(245, 158, 11, 1);
  }
}

@keyframes wobble {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  50% {
    transform: translateX(8px);
  }
  75% {
    transform: translateX(-8px);
  }
  100% {
    transform: translateX(0);
  }
}
.feedback.incorrect {
  animation: wobble 0.5s;
}
