/*
Theme Name: QuizGame Theme
Theme URI: https://bonshook.com/quizgame
Author: Bonshook
Author URI: https://bonshook.com
Description: Gamified quiz theme for WordQuiz project with RTL Persian support.
Version: 0.1.0
Text Domain: quizgame
*/

/* Persian Font Support */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap');

/* RTL Base Styles */
body { 
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', system-ui, sans-serif; 
  margin: 0; 
  background: #0f1020; 
  color: #fff; 
  transition: all 0.3s ease;
  direction: rtl;
  text-align: right;
}
body.dark-theme { background: #000; }

.quiz-container { 
  max-width: 600px; 
  margin: 0 auto; 
  padding: 1.25rem;
  direction: rtl;
  text-align: right;
}

.btn { 
  background: #6842ff; 
  color: #fff; 
  padding: 0.9rem 1.2rem; 
  border-radius: 12px; 
  display: inline-block; 
  text-decoration: none; 
  font-weight: 600; 
  border: 0; 
  cursor: pointer; 
  transition: .25s;
  direction: rtl;
}
.btn:hover { background: #8568ff; transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.card { 
  background: linear-gradient(145deg, #1d1f33, #121325); 
  padding: 1.25rem 1.5rem; 
  border-radius: 20px; 
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.6);
  direction: rtl;
  text-align: right;
}

.input { 
  width: 100%; 
  padding: 0.85rem 1rem; 
  border-radius: 12px; 
  border: 2px solid #262a45; 
  background: #181a2f; 
  color: #fff; 
  font-size: 1rem; 
  transition: all 0.3s ease;
  direction: rtl;
  text-align: right;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}

/* Settings Bar */
.settings-bar { 
  display: flex; 
  gap: 10px; 
  justify-content: flex-start; /* Changed for RTL */
  margin-bottom: 20px;
  direction: rtl;
}
.settings-btn { 
  background: #262a45; 
  border: none; 
  color: #fff; 
  padding: 8px 12px; 
  border-radius: 8px; 
  cursor: pointer; 
  font-size: 16px; 
  transition: all 0.3s ease;
}
.settings-btn:hover { background: #6842ff; transform: scale(1.1); }

/* Progress Bar Enhanced - RTL */
.progress { 
  height: 12px; 
  background: #262a45; 
  border-radius: 8px; 
  overflow: hidden; 
  margin: 1rem 0 1.25rem; 
  position: relative;
  direction: ltr; /* Keep progress direction left-to-right */
}
.progress span { 
  display: block; 
  height: 100%; 
  background: linear-gradient(90deg, #6842ff, #ff00c8); 
  width: 0; 
  transition: width .4s ease;
}
.progress-text { 
  position: absolute; 
  left: 8px; /* Changed from right for RTL */
  top: -25px; 
  font-size: 12px; 
  color: #a5adcb; 
  font-weight: 600;
  direction: rtl;
}

/* Timer Enhanced - RTL */
/* Overall Quiz Timer - Simple and Small */
.timer { 
  position: fixed;
  top: 15px;
  left: 15px;
  font-weight: 500; 
  letter-spacing: .3px; 
  color: #888; 
  font-size: 13px; 
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: 20px;
  transition: all 0.3s ease;
  direction: rtl;
  z-index: 100;
  backdrop-filter: blur(10px);
}

/* Pulse animation for timer */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Per-Question Timer - Large and Exciting */
.question-timer-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  width: 140px;
  height: 140px;
}

.question-timer-circle {
  position: relative;
  width: 100%;
  height: 100%;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 4px 12px rgba(104, 66, 255, 0.3));
}

.timer-background {
  fill: none;
  stroke: #262a45;
  stroke-width: 8;
}

.timer-progress {
  fill: none;
  stroke: #3ddc97;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 282.743; /* 2 * PI * 45 */
  stroke-dashoffset: 0;
  transition: stroke 0.3s ease, filter 0.3s ease;
  filter: drop-shadow(0 0 8px rgba(61, 220, 151, 0.5));
}

.timer-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  direction: rtl;
}

.timer-value {
  display: block;
  font-size: 36px;
  font-weight: 700;
  color: #3ddc97;
  line-height: 1;
  transition: color 0.3s ease;
}

.timer-label {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: #888;
  margin-top: 4px;
}

/* Warning State (≤10 seconds) */
.question-timer-container.warning .timer-progress {
  stroke: #ffb347;
  filter: drop-shadow(0 0 8px rgba(255, 179, 71, 0.6));
}

.question-timer-container.warning .timer-value {
  color: #ffb347;
}

/* Critical State (≤5 seconds) */
.question-timer-container.critical .timer-progress {
  stroke: #ff3860;
  filter: drop-shadow(0 0 12px rgba(255, 56, 96, 0.8));
  animation: pulse-stroke 0.5s infinite;
}

.question-timer-container.critical .timer-value {
  color: #ff3860;
  animation: pulse-text 0.5s infinite;
}

.question-timer-container.critical {
  animation: shake 0.5s infinite;
}

/* Animations for critical state */
@keyframes pulse-stroke {
  0%, 100% { stroke-width: 8; }
  50% { stroke-width: 10; }
}

@keyframes pulse-text {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Responsive - Smaller on mobile */
@media (max-width: 600px) {
  .question-timer-container {
    width: 100px;
    height: 100px;
  }
  
  .timer-value {
    font-size: 28px;
  }
  
  .timer-label {
    font-size: 10px;
  }
  
  .timer { 
    top: 10px;
    left: 10px;
    font-size: 11px;
    padding: 5px 10px;
  }
}

/* Question Animations */
.question-stage { opacity: 0; transform: translateY(20px); transition: all 0.5s ease; }
.question-stage.question-enter { opacity: 1; transform: translateY(0); }

.question-header { margin-bottom: 20px; }
.milestone-message { background: linear-gradient(45deg, #6842ff, #ff00c8); padding: 12px; border-radius: 12px; text-align: center; font-weight: 600; margin-top: 10px; animation: celebrate 0.6s ease; }

@keyframes celebrate {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* User Stats */
.user-stats { display: flex; justify-content: space-between; align-items: center; margin: 15px 0; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 10px; }
.streak-counter, .score-counter { font-size: 14px; font-weight: 600; }
.streak-counter.hot-streak { color: #ff6b35; animation: fire 0.5s ease infinite alternate; }

@keyframes fire {
  from { text-shadow: 0 0 5px #ff6b35; }
  to { text-shadow: 0 0 10px #ff6b35, 0 0 15px #ff3860; }
}

/* Options Enhanced */
.option { background:#23263b; border:2px solid #2d3254; padding:.85rem 1rem; border-radius:14px; margin:.65rem 0; cursor:pointer; position:relative; font-weight:500; display: flex; align-items: center; gap: 12px; opacity: 0; transform: translateX(-20px); transition: all 0.3s ease; }
.option.option-enter { opacity: 1; transform: translateX(0); }
.option:hover { background: #2a2f4a; border-color: #6842ff; transform: translateX(5px); }
.option.correct { border-color:#3ddc97; background:#1d3a2f; animation: correctPulse 0.6s ease; }
.option.wrong { border-color:#ff3860; background:#3a1d28; animation: wrongShake 0.6s ease; }
.option.correct-answer { border-color:#3ddc97; background:#1d3a2f; }

.option-letter { background: #6842ff; color: white; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; }
.option-text { flex: 1; }

/* Image Choice Options */
.image-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.option-image { flex-direction: column; align-items: stretch; padding: 12px; min-height: 180px; }
.option-image .option-img { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
.option-image .option-label { text-align: center; font-size: 14px; font-weight: 600; }
.option-image .option-letter { align-self: center; margin-bottom: 8px; }
.option-image:hover { transform: translateY(-5px) scale(1.02); }

@media (max-width: 768px) {
  .image-options { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .option-image { min-height: 150px; padding: 10px; }
  .option-image .option-img { height: 120px; }
}

/* Essay and Fill Blank Input Styles */
.essay-input, .fill-blank-input {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 10px 0;
}

.essay-textarea {
  width: 100%;
  padding: 1rem;
  border-radius: 12px;
  border: 2px solid #2d3254;
  background: #23263b;
  color: #fff;
  font-size: 15px;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
  direction: rtl;
  text-align: right;
  resize: vertical;
  min-height: 150px;
  transition: all 0.3s ease;
  line-height: 1.6;
}

.essay-textarea:focus {
  outline: none;
  border-color: #6842ff;
  background: #2a2f4a;
  box-shadow: 0 0 0 3px rgba(104, 66, 255, 0.1);
}

.fill-blank-field {
  width: 100%;
  padding: 1rem 1.2rem;
  border-radius: 12px;
  border: 2px solid #2d3254;
  background: #23263b;
  color: #fff;
  font-size: 16px;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
  direction: rtl;
  text-align: right;
  transition: all 0.3s ease;
}

.fill-blank-field:focus {
  outline: none;
  border-color: #6842ff;
  background: #2a2f4a;
  box-shadow: 0 0 0 3px rgba(104, 66, 255, 0.1);
}

.char-counter {
  text-align: left;
  color: #888;
  font-size: 13px;
  margin-top: -10px;
  direction: ltr;
}

.submit-essay-btn, .submit-blank-btn {
  background: #6842ff;
  color: #fff;
  padding: 0.9rem 1.5rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
  transition: all 0.3s ease;
  align-self: center;
  min-width: 150px;
}

.submit-essay-btn:hover, .submit-blank-btn:hover {
  background: #8568ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(104, 66, 255, 0.4);
}

.submit-essay-btn:active, .submit-blank-btn:active {
  transform: translateY(0);
}

.submit-essay-btn:disabled, .submit-blank-btn:disabled {
  background: #555;
  cursor: not-allowed;
  opacity: 0.6;
}

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Celebration Effects */
.celebration-particle { position: absolute; width: 6px; height: 6px; background: #6842ff; border-radius: 50%; animation: confetti 1s ease-out forwards; pointer-events: none; }

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-50px) rotate(720deg); opacity: 0; }
}

/* Floating Messages */
.floating-message { position: fixed; top: 20%; left: 50%; transform: translateX(-50%); background: linear-gradient(45deg, #6842ff, #ff00c8); color: white; padding: 12px 20px; border-radius: 25px; font-weight: 600; z-index: 1000; opacity: 0; transition: all 0.5s ease; }
.floating-message.show { opacity: 1; transform: translateX(-50%) translateY(-10px); }
.floating-message.hide { opacity: 0; transform: translateX(-50%) translateY(-30px); }

/* Encouraging Message */
.encouraging-message { display: flex; align-items: center; justify-content: center; min-height: 200px; opacity: 0; transform: scale(0.8); transition: all 0.5s ease; }
.encouraging-message.show { opacity: 1; transform: scale(1); }
.message-content { text-align: center; background: linear-gradient(45deg, #6842ff, #ff00c8); padding: 30px; border-radius: 20px; }
.message-text { font-size: 24px; font-weight: 700; color: white; }

/* Results Enhanced */
.results { opacity: 0; transform: translateY(30px); transition: all 0.5s ease; }
.results.results-enter { opacity: 1; transform: translateY(0); }

.results-hero { width:100%; aspect-ratio:9/16; background:radial-gradient(circle at 50% 30%, #6842ff, #181a2f 70%); border-radius:32px; padding:2rem; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; }
.performance-emoji { font-size: 4rem; margin-bottom: 1rem; animation: bounce 2s infinite; }

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

.results-hero h2 { font-size:2.75rem; margin:0 0 .5rem; background:linear-gradient(90deg,#fff,#c3b9ff); -webkit-background-clip:text; background-clip:text; color:transparent; }
.results-hero .score { font-size:3rem; font-weight:700; margin: 10px 0; }
.performance-level { font-size: 1.5rem; font-weight: 600; color: #3ddc97; margin: 10px 0; }
.performance-message { font-size: 1.1rem; margin: 15px 0; line-height: 1.4; }

.detailed-stats { display: flex; gap: 30px; margin: 20px 0; }
.stat-item { text-align: center; }
.stat-label { display: block; font-size: 0.9rem; color: #a5adcb; margin-bottom: 5px; }
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; color: #6842ff; }

.share-bar { margin-top:1.5rem; display:flex; gap:.75rem; flex-wrap:wrap; justify-content:center; }
.share-bar a { background:#262a45; padding:.7rem 1rem; border-radius:10px; color:#fff; font-size:.85rem; text-decoration:none; transition: all 0.3s ease; }
.share-bar a:hover { background: #6842ff; transform: translateY(-2px); }

/* Ad Spaces */
.ad-space { margin: 20px 0; padding: 15px; background: rgba(255,255,255,0.05); border-radius: 12px; border: 1px dashed #6842ff; }
.ad-label { display: block; font-size: 10px; color: #a5adcb; text-transform: uppercase; margin-bottom: 8px; text-align: center; }
.ad-content { text-align: center; }
.demo-ad { background: linear-gradient(45deg, #262a45, #1d1f33); padding: 20px; border-radius: 8px; color: #a5adcb; font-style: italic; min-height: 60px; display: flex; align-items: center; justify-content: center; }

.ad-results { margin-top: 30px; }
.ad-interstitial { border-color: #ff00c8; }
.ad-landing { margin-top: 20px; border-color: #3ddc97; }

/* Phase 2: Advanced Features Styles */

/* Power-ups Bar - RTL */
.power-ups-bar { 
  display: flex; 
  gap: 8px; 
  margin: 15px 0; 
  justify-content: center; 
  flex-wrap: wrap;
  direction: rtl;
}
.power-up { 
  background: linear-gradient(45deg, #6842ff, #8568ff); 
  border: none; 
  color: white; 
  padding: 8px 12px; 
  border-radius: 20px; 
  cursor: pointer; 
  font-size: 12px; 
  font-weight: 600; 
  display: flex; 
  align-items: center; 
  gap: 4px; 
  transition: all 0.3s ease; 
  min-width: 80px;
  direction: rtl;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}
.power-up:hover:not(.used) { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(104, 66, 255, 0.4); }
.power-up.used { background: #666; cursor: not-allowed; opacity: 0.6; }
.power-up-icon { font-size: 14px; }
.power-up-name { flex: 1; text-align: center; }
.power-up-count { background: rgba(255,255,255,0.2); padding: 2px 6px; border-radius: 10px; font-size: 10px; }

/* Difficulty Indicator - RTL */
.difficulty-indicator { 
  display: inline-block; 
  padding: 4px 12px; 
  border-radius: 15px; 
  font-size: 12px; 
  font-weight: 600; 
  margin-bottom: 10px;
  direction: rtl;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}
.difficulty-easy { background: #10b981; color: white; }
.difficulty-medium { background: #f59e0b; color: white; }
.difficulty-hard { background: #ef4444; color: white; animation: pulse 2s infinite; }

/* Speed Bonus - RTL */
.bonus-counter { transition: all 0.3s ease; direction: rtl; }
.bonus-counter.active { color: #f59e0b; animation: flash 0.5s ease; }
.speed-bonus { 
  position: absolute; 
  top: -30px; 
  left: 10px; /* Changed from right for RTL */
  background: #f59e0b; 
  color: white; 
  padding: 4px 8px; 
  border-radius: 12px; 
  font-size: 12px; 
  font-weight: 600; 
  opacity: 0; 
  transform: translateY(10px);
  direction: rtl;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}
.speed-bonus.animate-bonus { opacity: 1; transform: translateY(-10px); animation: speedBonusFloat 2s ease forwards; }

@keyframes flash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes speedBonusFloat {
  0% { opacity: 1; transform: translateY(-10px); }
  100% { opacity: 0; transform: translateY(-40px); }
}

/* Disabled Options (50/50 power-up) */
.disabled-option { opacity: 0.3 !important; pointer-events: none !important; }

/* Achievement Notifications - RTL */
.achievement-notification { 
  position: fixed; 
  top: 20px; 
  left: 20px; /* Changed from right for RTL */
  background: linear-gradient(45deg, #10b981, #3ddc97); 
  border-radius: 12px; 
  padding: 15px; 
  color: white; 
  z-index: 1000; 
  max-width: 300px; 
  opacity: 0; 
  transform: translateX(-100%); /* Changed direction for RTL */
  transition: all 0.5s ease;
  direction: rtl;
  text-align: right;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}
.achievement-notification.show { opacity: 1; transform: translateX(0); }
.achievement-notification.hide { opacity: 0; transform: translateX(-100%); /* Changed direction for RTL */ }
.achievement-content { display: flex; align-items: center; gap: 12px; direction: rtl; }
.achievement-icon { font-size: 32px; }
.achievement-title { font-size: 12px; text-transform: uppercase; opacity: 0.8; margin-bottom: 2px; }
.achievement-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.achievement-desc { font-size: 12px; opacity: 0.9; }

/* Results Enhancements - RTL */
.score-breakdown { margin: 15px 0; direction: rtl; text-align: center; }
.base-score { font-size: 2.5rem; font-weight: 700; }
.bonus-score { font-size: 1.2rem; color: #f59e0b; font-weight: 600; margin: 5px 0; }
.final-score { font-size: 1.8rem; font-weight: 700; color: #3ddc97; padding: 10px; background: rgba(61, 220, 151, 0.1); border-radius: 10px; margin-top: 10px; }

.achievements-earned { margin: 20px 0; direction: rtl; text-align: center; }
.achievements-earned h3 { font-size: 1.2rem; margin-bottom: 10px; }
.achievement-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; direction: rtl; }
.achievement-badge { 
  background: rgba(255,255,255,0.1); 
  padding: 6px 12px; 
  border-radius: 20px; 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  font-size: 12px;
  direction: rtl;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}

.enhanced-share-bar { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.enhanced-share-bar a { background: #262a45; padding: 8px 16px; border-radius: 10px; color: #fff; font-size: 14px; text-decoration: none; transition: all 0.3s ease; }
.enhanced-share-bar a:hover { background: #6842ff; transform: translateY(-2px); }

/* Leaderboard */
.leaderboard-section { margin-top: 30px; padding: 20px; background: rgba(255,255,255,0.05); border-radius: 12px; }
.leaderboard-section h3 { text-align: center; margin-bottom: 15px; color: #6842ff; }
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }
.leaderboard-entry { display: grid; grid-template-columns: 40px 1fr 80px 60px; gap: 10px; align-items: center; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 8px; }
.leaderboard-entry.rank-1 { background: linear-gradient(45deg, #ffd700, #ffed4e); color: #000; font-weight: bold; }
.leaderboard-entry.rank-2 { background: linear-gradient(45deg, #c0c0c0, #e5e5e5); color: #000; font-weight: bold; }
.leaderboard-entry.rank-3 { background: linear-gradient(45deg, #cd7f32, #deb887); color: #000; font-weight: bold; }
.rank { font-weight: bold; text-align: center; }
.player-name { font-weight: 600; }
.player-score { text-align: center; font-weight: bold; }
.player-accuracy { text-align: center; font-size: 12px; opacity: 0.8; }

/* Challenge Section */
.challenge-section { margin-top: 30px; padding: 20px; background: rgba(104, 66, 255, 0.1); border-radius: 12px; border: 1px solid #6842ff; }
.challenge-section h3 { text-align: center; margin-bottom: 15px; color: #6842ff; }
.challenge-link { display: flex; gap: 10px; margin: 15px 0; }
.challenge-link input { flex: 1; padding: 8px 12px; border: 1px solid #6842ff; border-radius: 6px; background: #1a1a2e; color: white; }
.challenge-link button { background: #6842ff; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.challenge-link button:hover { background: #8568ff; }
.challenge-message { text-align: center; padding: 15px; background: rgba(255,255,255,0.05); border-radius: 8px; font-size: 16px; }

/* Mobile Responsive for Phase 2 */
@media (max-width:600px){
  .results-hero h2 { font-size:2.1rem; }
  .performance-emoji { font-size: 3rem; }
  .detailed-stats { flex-direction: column; gap: 15px; }
  .hero-emoji { font-size: 3rem; }
  .power-ups-bar { justify-content: space-between; }
  .power-up { min-width: 70px; font-size: 11px; padding: 6px 10px; }
  .leaderboard-entry { grid-template-columns: 30px 1fr 60px 50px; padding: 8px; }
  .challenge-link { flex-direction: column; }
  .achievement-notification { right: 10px; left: 10px; max-width: none; }
}

/* Material-like spacing and layout improvements */
:root{
  --qg-space-1: 4px;
  --qg-space-2: 8px;
  --qg-space-3: 12px;
  --qg-space-4: 16px;
  --qg-space-5: 20px;
  --qg-space-6: 24px;
  --qg-radius: 12px;
}

/* Ensure inputs fit containers and have consistent rhythm */
.input{
  box-sizing: border-box;
  height: 44px;
  line-height: 1.2;
}
.input:focus{
  outline: none;
  border-color:#7a5fff;
  box-shadow:0 0 0 2px rgba(122,95,255,.25);
}

/* Quiz start form spacing */
.quiz-start form{
  display:flex;
  flex-direction:column;
  gap: var(--qg-space-3);
  margin-top: var(--qg-space-4);
}
.quiz-start h2, .quiz-start p{ margin: 0 0 var(--qg-space-3) 0; }
.quiz-start .btn{
  align-self: flex-start;
  margin-top: var(--qg-space-3);
}

/* Override inline styles for challenge wrap with a stronger rule */
#challenge-wrap{
  margin: var(--qg-space-3) 0 !important;
  font-size: .95rem !important;
  color:#b7b7c9 !important;
}

/* Buttons: better alignment and touch targets */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: var(--qg-space-2);
  min-height: 44px;
  letter-spacing:.2px;
}
.btn:active{ transform: translateY(1px); }

/* Referral form layout (homepage) */
#referral-form{
  display:flex;
  flex-wrap: wrap;
  gap: var(--qg-space-3);
  align-items: center;
  margin-top: var(--qg-space-4);
}
#referral-form input[type="text"],
#referral-form input[type="tel"],
#referral-form input[type="search"],
#referral-form .input{
  flex: 1 1 260px;
  max-width: 420px;
  direction: rtl;
  text-align: right;
}
#referral-form .btn{ flex: 0 0 auto; }

/* Quiz screen container spacing */
#quiz-screen h2{ margin: 0 0 var(--qg-space-3) 0; direction: rtl; text-align: right; }
#quiz-screen .media{ margin: var(--qg-space-3) 0 var(--qg-space-4); }
.question-stage{ padding-bottom: var(--qg-space-4); direction: rtl; text-align: right; }

/* Cards and general spacing adjustments */
.card + .card{ margin-top: var(--qg-space-4); }

/* Additional RTL Support */
.quiz-options { direction: rtl; text-align: right; }
.quiz-options label { direction: rtl; text-align: right; }
.option { direction: rtl; text-align: right; padding: 12px 15px; }
.question-text { direction: rtl; text-align: right; line-height: 1.6; }

/* Form elements RTL */
input[type="text"], input[type="email"], input[type="tel"], textarea, select {
  direction: rtl;
  text-align: right;
  font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}

/* Challenge section RTL */
.challenge-section { direction: rtl; text-align: right; }
.challenge-link { direction: rtl; }
.challenge-link input { direction: rtl; text-align: right; }
.challenge-message { direction: rtl; text-align: center; }

/* Floating messages RTL */
.floating-message { direction: rtl; text-align: center; }
.milestone-message { direction: rtl; text-align: center; }

/* Ad spaces RTL */
.ad-space { direction: rtl; text-align: center; }
.ad-label { direction: rtl; }
.demo-ad { direction: rtl; text-align: center; }

/* Mobile RTL adjustments */
@media (max-width: 600px) {
  .achievement-notification { left: 10px; right: 10px; max-width: none; }
  .power-ups-bar { justify-content: space-between; }
  .quiz-container { direction: rtl; }
  .settings-bar { justify-content: flex-start; }
}
.card{
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow:
    0 2px 6px rgba(0,0,0,.24),
    0 12px 32px -10px rgba(0,0,0,.45);
}

/* Helper and error text styles below inputs */
.helper{ margin-top: var(--qg-space-1); color:#a5adcb; font-size:.875rem; }
.error{ margin-top: var(--qg-space-1); color:#ff6b6b; font-size:.875rem; }
.input.is-error{ border-color:#ff6b6b; box-shadow:0 0 0 2px rgba(255,107,107,.15); }
.input:invalid{ border-color:#ff6b6b; }

/* Mobile full-width buttons for easier tapping */
@media (max-width:480px){
  .quiz-start .btn, #referral-form .btn{ width:100%; }
}

/* RTL tweaks */
body.rtl #referral-form{ flex-direction: row-reverse; }
/* Keep logical order on small screens so input stays above button */
@media (min-width:481px){
  body.rtl #referral-form .btn{ order: -1; }
}
body.rtl .quiz-start .btn{ align-self: flex-end; }
