@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@600;800;900&family=Vazirmatn:wght@400;600;700;900&display=swap');

:root {
  --bg-primary: #0a0b1e;
  --bg-card: rgba(18, 22, 54, 0.85);
  --cyan-glow: #00f0ff;
  --magenta-glow: #ff0077;
  --gold-glow: #ffd700;
  --green-glow: #00ff88;
  --purple-glow: #8a2be2;
  --text-main: #f0f4ff;
  --text-muted: #8a96bd;
  --border-glow: rgba(0, 240, 255, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Vazirmatn', sans-serif;
  direction: rtl;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

/* Background animated glow */
.bg-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120vw;
  height: 120vh;
  background: radial-gradient(circle at 50% 50%, rgba(30, 20, 70, 0.6) 0%, rgba(10, 11, 30, 0.95) 70%);
  z-index: 0;
  pointer-events: none;
}

/* Header HUD */
.hud-header {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 900px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hud-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.15);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.score-display {
  font-family: 'Vazirmatn', sans-serif;
  color: var(--gold-glow);
  font-size: 1.25rem;
  font-weight: 800;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

.combo-badge {
  color: var(--magenta-glow);
  font-family: 'Vazirmatn', sans-serif;
  font-weight: 900;
  letter-spacing: 0.5px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-pulse {
  transform: scale(1.35);
}

.lives-container {
  display: flex;
  gap: 4px;
  font-size: 1.2rem;
}

/* Question Banner */
.mission-card {
  position: relative;
  z-index: 10;
  width: 92%;
  max-width: 780px;
  background: linear-gradient(135deg, rgba(20, 25, 65, 0.9), rgba(12, 15, 42, 0.95));
  border: 1.5px solid var(--cyan-glow);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.25), inset 0 0 15px rgba(0, 240, 255, 0.1);
  border-radius: 20px;
  padding: 14px 24px;
  text-align: center;
  margin-top: 4px;
  backdrop-filter: blur(10px);
}

.mission-title {
  font-size: 0.85rem;
  color: var(--cyan-glow);
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}

.mission-equation {
  font-size: 1.5rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 1px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  direction: ltr;
}

.pos-badge {
  background: rgba(0, 240, 255, 0.2);
  border: 1.5px solid var(--cyan-glow);
  color: var(--cyan-glow);
  padding: 4px 12px;
  border-radius: 10px;
  font-size: 1.15rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.jump-val {
  color: var(--gold-glow);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Mathematical Horizontal Fraction Notation (صورت، خط کسری افقی، مخرج) */
.math-frac {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  direction: ltr;
  gap: 3px;
  font-family: 'Orbitron', 'Vazirmatn', sans-serif;
  line-height: 1;
}

.math-frac .frac-sign {
  font-weight: 900;
  font-size: 1.05em;
  margin-right: 2px;
}

.math-frac .frac-body {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 2px;
}

.math-frac .frac-num {
  font-size: 0.8em;
  font-weight: 800;
  padding-bottom: 2px;
  border-bottom: 2.5px solid currentColor;
  width: 100%;
  text-align: center;
  display: block;
}

.math-frac .frac-den {
  font-size: 0.8em;
  font-weight: 800;
  padding-top: 2px;
  width: 100%;
  text-align: center;
  display: block;
}

/* Canvas Area */
.canvas-wrapper {
  position: relative;
  z-index: 5;
  width: 100vw;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  max-width: 950px;
  max-height: 480px;
  display: block;
  cursor: pointer;
  touch-action: none;
}

/* Interactive Axis Bottom Guide Bar */
.axis-guide-bar {
  position: relative;
  z-index: 10;
  width: 92%;
  max-width: 600px;
  margin-bottom: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.15);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

.guide-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.cursor-val-badge {
  background: rgba(0, 240, 255, 0.18);
  border: 1px solid var(--cyan-glow);
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Wizard Cards for Step 1 */
.wizard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 16px 0 20px;
}

.wizard-card {
  background: linear-gradient(135deg, rgba(28, 35, 85, 0.85), rgba(15, 18, 50, 0.95));
  border: 2px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  border-radius: 20px;
  padding: 18px 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: right;
}

.wizard-card:hover {
  border-color: var(--cyan-glow);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 30px rgba(0, 240, 255, 0.35);
}

.wizard-card:active {
  transform: scale(0.98);
}

.wizard-card.timed-card:hover {
  border-color: var(--gold-glow);
  box-shadow: 0 10px 30px rgba(255, 215, 0, 0.35);
}

.wizard-icon {
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wizard-title {
  font-weight: 900;
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.wizard-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.wizard-header-pill {
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid var(--border-glow);
  border-radius: 14px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 0.88rem;
}

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

/* Modals & Overlays */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 20, 0.88);
  backdrop-filter: blur(14px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-box {
  background: linear-gradient(145deg, rgba(22, 28, 70, 0.95), rgba(12, 16, 45, 0.98));
  border: 2px solid var(--cyan-glow);
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.3), inset 0 0 20px rgba(0, 240, 255, 0.1);
  border-radius: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 20px;
  text-align: center;
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  margin-bottom: 6px;
  text-shadow: 0 0 15px var(--cyan-glow);
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 18px;
  line-height: 1.5;
}

.modal-section-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--cyan-glow);
  text-align: right;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 12px 16px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover, .mode-btn.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--cyan-glow);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
  transform: scale(1.015);
}

.play-main-btn {
  background: linear-gradient(90deg, #00f0ff 0%, #0077ff 100%);
  border: none;
  color: #050714;
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.25rem;
  font-weight: 900;
  width: 100%;
  padding: 16px;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.5);
  transition: all 0.2s ease;
}

.play-main-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 45px rgba(0, 240, 255, 0.8);
}

/* Stat Grid inside Game Over Modal */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px;
  border-radius: 14px;
}

.stat-val {
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--gold-glow);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 600px) {
  .mission-equation { font-size: 1.2rem; }
  .choice-btn { font-size: 1.15rem; padding: 12px 4px; }
  .hud-pill { padding: 6px 12px; font-size: 0.85rem; }
}

/* Progressive Stage Unlocking Styles */
.mode-btn.stage-locked {
  opacity: 0.42;
  cursor: not-allowed !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  background: rgba(0, 0, 0, 0.25) !important;
  box-shadow: none !important;
}

.mode-btn.stage-locked:hover {
  transform: none !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
}

.mode-btn.stage-passed {
  border-color: rgba(0, 255, 136, 0.45);
  background: rgba(0, 255, 136, 0.07);
}

.wizard-card.locked-card {
  opacity: 0.45;
  cursor: not-allowed !important;
  border-color: rgba(255, 0, 85, 0.25) !important;
  background: rgba(15, 18, 40, 0.6) !important;
  box-shadow: none !important;
}

.wizard-card.locked-card:hover {
  transform: none !important;
  border-color: rgba(255, 0, 85, 0.35) !important;
  box-shadow: none !important;
}

.play-main-btn.btn-disabled,
.play-main-btn:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.8);
  background: #334155 !important;
  box-shadow: none !important;
  transform: none !important;
}

.stage-passed-badge {
  font-size: 0.72rem;
  background: rgba(0, 255, 136, 0.2);
  border: 1px solid #00ff88;
  color: #00ff88;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 800;
}

.stage-locked-badge {
  font-size: 0.72rem;
  background: rgba(255, 0, 85, 0.2);
  border: 1px solid #ff0055;
  color: #ff0055;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 800;
}

.stage-active-badge {
  font-size: 0.72rem;
  background: rgba(0, 240, 255, 0.2);
  border: 1px solid #00f0ff;
  color: #00f0ff;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 800;
}

/* In-App Lock Toast Notification */
#lock-toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 420px;
}

.lock-toast {
  background: linear-gradient(135deg, rgba(35, 15, 45, 0.96), rgba(20, 10, 30, 0.98));
  border: 1.5px solid #ff0055;
  box-shadow: 0 8px 32px rgba(255, 0, 85, 0.4), inset 0 0 15px rgba(255, 0, 85, 0.15);
  border-radius: 18px;
  padding: 12px 20px;
  color: #fff;
  font-family: 'Vazirmatn', sans-serif;
  text-align: center;
  direction: rtl;
  backdrop-filter: blur(12px);
  animation: toastPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: auto;
}

.lock-toast-title {
  color: #ff0055;
  font-weight: 900;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
}

.lock-toast-sub {
  color: #cbd5e1;
  font-size: 0.82rem;
  line-height: 1.5;
}

@keyframes toastPop {
  0% { opacity: 0; transform: translateY(-20px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastFadeOut {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-15px) scale(0.95); }
}

/* Shake Animation for Locked Click */
.shake-anim {
  animation: lockShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes lockShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

