@media (max-width: 1024px) {
  .menu-left {
    padding: 30px 20px 30px 30px;
  }

  .menu-right {
    flex: 0.8;
  }

  .menu-dragon {
    width: clamp(150px, 30vw, 300px);
  }

  .menu-buttons {
    max-width: 260px;
  }

  .quiz-main {
    padding: 8px 12px;
    gap: 10px;
  }

  .quiz-sidebar {
    width: 140px;
  }

  .question-card {
    padding: 20px;
  }

  .timer-container {
    width: 100px;
    height: 100px;
  }

  .distance-bar {
    height: 120px;
  }
}

@media (max-width: 768px) {
  .menu-overlay {
    flex-direction: column;
  }

  .menu-left {
    padding: 20px;
    align-items: center;
    text-align: center;
    flex: none;
  }

  .menu-logo {
    text-align: center;
  }

  .logo-line {
    width: 100%;
  }

  .logo-line-top { width: 80%; margin: 0 auto 8px; }
  .logo-line-bottom { width: 80%; margin: 8px auto 0; }

  .menu-buttons {
    max-width: 100%;
    width: 100%;
  }

  .menu-btn {
    padding: 10px 18px;
    font-size: clamp(12px, 3vw, 16px);
  }

  .menu-right {
    display: none;
  }

  .quiz-hud {
    padding: 8px 12px;
    min-height: 50px;
    flex-wrap: wrap;
    gap: 5px;
  }

  .hud-center {
    order: 3;
    width: 100%;
    text-align: center;
  }

  .quiz-main {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }

  .quiz-sidebar {
    width: 100%;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    justify-content: center;
  }

  .timer-container {
    width: 80px;
    height: 80px;
  }

  .dragon-distance {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    flex: 1;
  }

  .distance-title {
    display: none;
  }

  .distance-bar-container {
    flex-direction: row;
    gap: 6px;
  }

  .distance-dragon-icon {
    width: 35px;
    height: 35px;
  }

  .distance-bar {
    width: 100px;
    height: 16px;
  }

  .distance-segment {
    width: 25%;
    height: 100%;
    top: 0 !important;
    left: auto;
  }

  .distance-s1 { left: 0; }
  .distance-s2 { left: 25%; }
  .distance-s3 { left: 50%; }
  .distance-s4 { left: 75%; }

  .distance-fill {
    width: 100%;
    height: 100%;
    bottom: auto;
    background: linear-gradient(to right, #4A8F16, #79C528, #E86A17, #C91E2E);
  }

  .distance-player-icon {
    width: 25px;
    height: 25px;
  }

  .distance-status {
    font-size: 10px;
    min-height: auto;
  }

  .quiz-footer {
    flex-wrap: wrap;
    gap: 10px;
    padding: 6px 12px;
    min-height: 50px;
  }

  .dragon-preview, .door-preview {
    width: 45px;
    height: 45px;
  }

  .question-card {
    padding: 15px;
  }

  .option-btn {
    padding: 12px 16px;
    font-size: clamp(12px, 2.5vw, 15px);
  }

  .option-letter {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .result-panel, .gameover-panel, .victory-panel, .intro-scroll {
    padding: 25px 20px;
    width: 95%;
  }

  .paused-panel {
    padding: 25px;
    min-width: auto;
    width: 90%;
  }
}

@media (max-width: 480px) {
  .quiz-hud {
    min-height: 44px;
  }

  .hud-progress {
    font-size: 12px;
  }

  .hud-title {
    font-size: 12px;
  }

  .hud-right {
    gap: 8px;
  }

  .hud-currency, .hud-score {
    font-size: 12px;
  }

  .hud-pause-btn {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .question-text {
    font-size: 14px;
  }

  .option-btn {
    padding: 10px 12px;
  }

  .gameover-dragon-container {
    width: 80px;
    height: 80px;
  }

  .victory-crown {
    font-size: 42px;
  }
}

@media (orientation: portrait) and (max-width: 768px) {
  #quiz-screen {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }

  #quiz-screen .quiz-hud {
    flex-wrap: wrap;
    padding: 6px 10px;
    min-height: 44px;
    gap: 4px;
  }

  .hud-left {
    flex-direction: row;
    gap: 8px;
    align-items: center;
  }

  .hud-center {
    order: -1;
    width: 100%;
    text-align: center;
    flex: none;
  }

  .hud-title {
    font-size: 11px;
  }

  .hud-progress {
    font-size: 12px;
  }

  .hud-difficulty {
    font-size: 10px;
  }

  .hud-right {
    gap: 8px;
  }

  .hud-currency, .hud-score {
    font-size: 13px;
  }

  .hud-pause-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  #quiz-screen .quiz-main {
    flex-direction: column;
    flex: 1;
    padding: 6px 8px;
    gap: 6px;
    min-height: 0;
  }

  .quiz-question-area {
    flex: none;
  }

  .question-card {
    padding: 12px 14px;
    border-radius: 14px;
  }

  .question-category {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .question-text {
    font-size: 15px;
    margin-bottom: 12px;
    line-height: 1.3;
  }

  .question-options {
    gap: 8px;
  }

  .option-btn {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    gap: 10px;
  }

  .option-letter {
    width: 26px;
    height: 26px;
    font-size: 12px;
    border-width: 1px;
  }

  #quiz-screen .quiz-sidebar {
    width: 100%;
    flex-direction: row;
    flex: none;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
  }

  .timer-container {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
  }

  .timer-number {
    font-size: 20px;
  }

  .timer-label {
    font-size: 7px;
  }

  .dragon-distance {
    flex: 1;
    padding: 6px 10px;
    flex-direction: row;
    gap: 8px;
    align-items: center;
  }

  .distance-title {
    display: none;
  }

  .distance-bar-container {
    flex-direction: row;
    gap: 4px;
  }

  .distance-dragon-icon {
    width: 28px;
    height: 28px;
  }

  .distance-bar {
    width: 80px;
    height: 12px;
  }

  .distance-segment {
    width: 25%;
    height: 100%;
    top: 0 !important;
  }

  .distance-fill {
    width: 100%;
    height: 100%;
    bottom: auto;
    background: linear-gradient(to right, #4A8F16, #79C528, #E86A17, #C91E2E);
  }

  .distance-player-icon {
    width: 20px;
    height: 20px;
  }

  .player-icon-shield {
    font-size: 14px;
  }

  .distance-status {
    font-size: 9px;
    min-height: auto;
  }

  #quiz-screen .quiz-footer {
    flex-wrap: nowrap;
    gap: 12px;
    padding: 4px 10px;
    min-height: 44px;
    justify-content: center;
  }

  .dragon-preview, .door-preview {
    width: 36px;
    height: 36px;
  }

  .streak-display {
    font-size: 14px;
  }

  .streak-label {
    font-size: 9px;
  }

  .result-panel {
    padding: 20px 16px;
    width: 92%;
    border-radius: 16px;
  }

  .result-title {
    font-size: clamp(22px, 5vw, 30px);
    margin-bottom: 6px;
  }

  .result-message {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .result-explanation {
    padding: 10px;
    margin: 10px 0;
    font-size: 12px;
  }

  .result-btn {
    padding: 10px 30px;
    font-size: 16px;
    border-radius: 10px;
  }

  .gameover-panel, .victory-panel, .intro-scroll {
    padding: 20px 16px;
    width: 92%;
    border-radius: 16px;
  }

  .gameover-title {
    font-size: clamp(22px, 6vw, 32px);
  }

  .victory-title {
    font-size: clamp(22px, 6vw, 32px);
  }

  .victory-crown {
    font-size: 42px;
  }

  .intro-title {
    font-size: clamp(18px, 5vw, 24px);
  }

  .intro-text {
    font-size: 13px;
  }

  .intro-start-btn {
    padding: 12px 30px;
    font-size: 16px;
  }

  .paused-panel {
    padding: 25px 20px;
    min-width: auto;
    width: 85%;
  }

  .howtoplay-panel {
    max-width: 100%;
    width: 92%;
  }

  .htp-step {
    padding: 10px 12px;
    gap: 10px;
  }

  .htp-icon {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .htp-text {
    font-size: 12px;
  }

  .howtoplay-dragon-stages {
    gap: 6px;
  }

  .htp-stage img {
    width: 40px;
    height: 40px;
  }

  .htp-stage span {
    font-size: 8px;
  }
}

@media (orientation: landscape) {
  #quiz-screen::after {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.setting-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 6px;
  background: #2A1E3C;
  border-radius: 3px;
  outline: none;
}

.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(145deg, #9B4DDA, #6F2DA8);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #F4A900;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle-switch input {
  display: none;
}

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #2A1E3C;
  border-radius: 12px;
  border: 2px solid #4B4358;
  transition: all 0.3s ease;
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #D8D1E4;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: #6F2DA8;
  border-color: #9B4DDA;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #FFFFFF;
}

#settings-screen, #howtoplay-screen, #ranking-screen, #credits-screen {
  z-index: 100;
  background: rgba(10,8,19,0.95);
}

.settings-overlay, .howtoplay-overlay, .ranking-overlay, .credits-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.settings-panel, .ranking-panel, .credits-panel {
  background: linear-gradient(145deg, #1B1428, #12101C);
  border: 2px solid #6F2DA8;
  border-radius: 20px;
  padding: 30px 35px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 0 50px rgba(111,45,168,0.4);
  animation: scaleIn 0.4s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.settings-panel h1, .ranking-panel h1, .howtoplay-panel h1, .credits-panel h1 {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(24px, 4vw, 36px);
  color: #F4A900;
  text-shadow: 2px 2px 0 #4C1D78;
  margin-bottom: 20px;
  text-align: center;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  background: rgba(42,30,60,0.5);
  border: 1px solid #4B4358;
  border-radius: 12px;
}

.setting-label {
  font-size: clamp(13px, 1.5vw, 16px);
  color: #D8D1E4;
  font-weight: 500;
}

.setting-btn {
  padding: 8px 20px;
  background: linear-gradient(145deg, #2A1E3C, #1B1428);
  border: 2px solid #6F2DA8;
  border-radius: 10px;
  color: #FFFFFF;
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(12px, 1.3vw, 16px);
  transition: all 0.3s ease;
}

.setting-btn:hover {
  background: linear-gradient(145deg, #3A1E5C, #2A1E3C);
  border-color: #9B4DDA;
}

.settings-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-save-btn {
  padding: 12px 30px;
  background: linear-gradient(145deg, #6F2DA8, #4C1D78);
  border: 2px solid #9B4DDA;
  border-radius: 14px;
  color: #FFFFFF;
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(14px, 1.8vw, 18px);
  transition: all 0.3s ease;
}

.settings-save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(111,45,168,0.4);
}

.settings-reset-btn {
  padding: 10px 20px;
  background: transparent;
  border: 2px solid #C91E2E;
  border-radius: 14px;
  color: #FF344D;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(12px, 1.3vw, 14px);
  transition: all 0.3s ease;
}

.settings-reset-btn:hover {
  background: rgba(201,30,46,0.1);
  box-shadow: 0 0 20px rgba(201,30,46,0.2);
}

.settings-back-btn {
  padding: 10px 20px;
  background: transparent;
  border: 2px solid #4B4358;
  border-radius: 14px;
  color: #D8D1E4;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(12px, 1.3vw, 14px);
  transition: all 0.3s ease;
}

.settings-back-btn:hover {
  border-color: #9B4DDA;
  color: #FFFFFF;
}

.howtoplay-panel {
  max-width: 600px;
}

.howtoplay-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.htp-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(42,30,60,0.5);
  border: 1px solid #4B4358;
  border-radius: 12px;
}

.htp-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 2px solid;
}

.htp-icon-green { background: #2A5A15; border-color: #79C528; color: #79C528; }
.htp-icon-red { background: #5A1A18; border-color: #FF344D; color: #FF344D; }
.htp-icon-purple { background: #2A1E3C; border-color: #9B4DDA; color: #9B4DDA; }
.htp-icon-gold { background: #4C3A10; border-color: #F4A900; color: #F4A900; }

.htp-text {
  font-size: clamp(12px, 1.5vw, 15px);
  color: #D8D1E4;
  line-height: 1.5;
  padding-top: 6px;
}

.howtoplay-dragon-stages {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.htp-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 60px;
}

.htp-stage img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.htp-stage span {
  font-size: 9px;
  color: #9B4DDA;
  text-align: center;
}

.howtoplay-btn {
  display: block;
  margin: 0 auto;
  padding: 12px 40px;
  background: linear-gradient(145deg, #6F2DA8, #4C1D78);
  border: 2px solid #9B4DDA;
  border-radius: 14px;
  color: #FFFFFF;
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(16px, 2vw, 20px);
  transition: all 0.3s ease;
}

.howtoplay-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(111,45,168,0.4);
}

.ranking-list {
  margin-bottom: 20px;
  max-height: 300px;
  overflow-y: auto;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  background: rgba(42,30,60,0.5);
  border: 1px solid #4B4358;
  border-radius: 10px;
  margin-bottom: 6px;
}

.ranking-pos {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(18px, 2.5vw, 24px);
  color: #F4A900;
  min-width: 30px;
}

.ranking-name {
  flex: 1;
  font-size: clamp(13px, 1.5vw, 16px);
  color: #FFFFFF;
}

.ranking-score {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(14px, 1.8vw, 18px);
  color: #9B4DDA;
}

.ranking-empty {
  text-align: center;
  color: #4B4358;
  font-size: clamp(13px, 1.5vw, 16px);
  padding: 30px;
}

.ranking-btn {
  display: block;
  margin: 0 auto;
  padding: 10px 30px;
  background: transparent;
  border: 2px solid #4B4358;
  border-radius: 14px;
  color: #D8D1E4;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(12px, 1.3vw, 14px);
  transition: all 0.3s ease;
}

.ranking-btn:hover {
  border-color: #9B4DDA;
  color: #FFFFFF;
}

.credits-content {
  text-align: center;
  margin-bottom: 20px;
}

.credits-game {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(18px, 2.5vw, 24px);
  color: #F4A900;
  margin-bottom: 5px;
}

.credits-sub {
  font-size: clamp(12px, 1.3vw, 15px);
  color: #9B4DDA;
  margin-bottom: 15px;
}

.credits-divider {
  height: 2px;
  background: linear-gradient(90deg, transparent, #6F2DA8, transparent);
  margin: 15px 0;
}

.credits-role {
  font-size: clamp(11px, 1.2vw, 14px);
  color: #4B4358;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.credits-name {
  font-size: clamp(14px, 1.5vw, 18px);
  color: #D8D1E4;
  margin-bottom: 15px;
}

.credits-thanks {
  font-size: clamp(12px, 1.3vw, 15px);
  color: #D8D1E4;
  font-style: italic;
  margin: 10px 0;
}

.credits-year {
  font-size: clamp(14px, 1.8vw, 18px);
  color: #F4A900;
  font-family: 'Luckiest Guy', cursive;
}

.credits-btn {
  display: block;
  margin: 0 auto;
  padding: 10px 30px;
  background: transparent;
  border: 2px solid #4B4358;
  border-radius: 14px;
  color: #D8D1E4;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(12px, 1.3vw, 14px);
  transition: all 0.3s ease;
}

.credits-btn:hover {
  border-color: #9B4DDA;
  color: #FFFFFF;
}

#answers-review-screen {
  z-index: 200;
  background: rgba(10,8,19,0.95);
}

.answers-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.answers-panel {
  background: linear-gradient(145deg, #1B1428, #12101C);
  border: 2px solid #6F2DA8;
  border-radius: 20px;
  padding: 30px 35px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(111,45,168,0.4);
}

.answers-panel h1 {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(24px, 4vw, 36px);
  color: #F4A900;
  text-shadow: 2px 2px 0 #4C1D78;
  margin-bottom: 20px;
  text-align: center;
}

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

.answer-review-item {
  padding: 10px 15px;
  border-radius: 10px;
  border: 1px solid #4B4358;
  background: rgba(42,30,60,0.3);
}

.answer-review-item .aq { font-size: clamp(12px, 1.3vw, 15px); color: #FFFFFF; margin-bottom: 4px; }
.answer-review-item .ay { font-size: clamp(11px, 1.2vw, 13px); }
.answer-review-item .ay.correct { color: #79C528; }
.answer-review-item .ay.incorrect { color: #FF344D; }

.answers-btn {
  display: block;
  margin: 0 auto;
  padding: 10px 30px;
  background: transparent;
  border: 2px solid #4B4358;
  border-radius: 14px;
  color: #D8D1E4;
  font-size: clamp(12px, 1.3vw, 14px);
  transition: all 0.3s ease;
}

.answers-btn:hover {
  border-color: #9B4DDA;
  color: #FFFFFF;
}
