/* ===================================================================
   QuestWorld Learning — Full Game Styles
   Pixel art arcade aesthetic: dark backgrounds, neon accents
   Child-friendly: large fonts, high contrast, 44px+ touch targets
   =================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Fredoka', sans-serif;
  color: #f0f0f0;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Always-Visible Back Link --- */
#back-to-home {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 99999;
  padding: 8px 16px;
  background: rgba(10, 10, 26, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: #fff;
  font-family: 'Fredoka', sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  backdrop-filter: blur(4px);
  transition: background 0.2s, border-color 0.2s;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
}

#back-to-home:hover, #back-to-home:active {
  background: rgba(255, 100, 100, 0.3);
  border-color: #ff6b6b;
}

/* --- Game Container --- */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

/* --- Loading Screen --- */
#loading-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a3e 0%, #0a0a1a 100%);
  z-index: 1000;
  transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(24px, 6vw, 48px);
  color: #ffd700;
  text-shadow:
    0 0 10px rgba(255, 215, 0, 0.5),
    0 0 30px rgba(255, 215, 0, 0.3),
    3px 3px 0 #c7a200;
  margin-bottom: 24px;
  animation: title-pulse 2s ease-in-out infinite;
}

.loading-subtitle {
  font-family: 'Fredoka', sans-serif;
  font-size: 18px;
  color: #aaa;
  margin-bottom: 20px;
}

.loading-bar-track {
  width: 250px;
  height: 12px;
  background: #222;
  border-radius: 6px;
  overflow: hidden;
  margin: 0 auto;
  border: 2px solid #444;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ff88, #00cc66);
  border-radius: 4px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}

/* --- HUD --- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

#hud > * {
  pointer-events: auto;
}

/* Top bar */
#hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
}

#hud-currency {
  display: flex;
  gap: 12px;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  font-size: 14px;
  font-weight: 600;
  min-height: 36px;
}

.hud-icon {
  font-size: 16px;
}

.hud-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: #ffd700;
  min-width: 24px;
  text-align: right;
}

.currency-pulse {
  animation: currency-pulse 0.6s ease;
}

#hud-quest {
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid rgba(100, 200, 255, 0.3);
  font-size: 13px;
  max-width: 40%;
  text-align: center;
  color: #88ccff;
}

#quest-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bottom bar */
#hud-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
}

.hud-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: rgba(20, 20, 40, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 44px;
  min-height: 44px;
}

.hud-btn:hover, .hud-btn:active {
  background: rgba(40, 40, 80, 0.95);
  border-color: #ffd700;
  transform: scale(1.08);
}

.hud-btn-icon {
  font-size: 22px;
  line-height: 1;
}

.hud-btn-label {
  font-size: 9px;
  font-family: 'Press Start 2P', monospace;
  margin-top: 4px;
  color: #aaa;
}

.hud-btn--exit {
  border-color: rgba(255, 100, 100, 0.4);
}

.hud-btn--exit:hover, .hud-btn--exit:active {
  border-color: #ff6b6b;
  background: rgba(255, 100, 100, 0.2);
}

/* --- Fade Overlay --- */
#fade-overlay {
  position: absolute;
  inset: 0;
  background: #0a0a1a;
  opacity: 0;
  z-index: 100;
  pointer-events: none;
}

/* --- Generic Overlay --- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.overlay-enter {
  animation: overlay-fade-in 0.25s ease;
}

.overlay-exit {
  animation: overlay-fade-out 0.2s ease forwards;
}

/* --- Question Overlay --- */
.question-panel {
  background: linear-gradient(145deg, #1e1e3a, #16162a);
  border: 3px solid #4a4a8a;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 520px;
  width: 90%;
  box-shadow:
    0 0 40px rgba(100, 100, 255, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.5);
}

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

.question-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 6px 12px;
  border-radius: 12px;
  text-transform: uppercase;
}

.badge-math {
  background: #ff6b35;
  color: #fff;
}

.badge-science {
  background: #00cc66;
  color: #fff;
}

.badge-reading {
  background: #3498db;
  color: #fff;
}

.badge-logic {
  background: #9b59b6;
  color: #fff;
}

.badge-general {
  background: #888;
  color: #fff;
}

.question-prompt {
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 600;
  color: #fff;
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.4;
}

.question-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.choice-btn {
  padding: 16px 12px;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 600;
  color: #fff;
  background: linear-gradient(145deg, #2a2a5a, #20204a);
  border: 3px solid #4a4a8a;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 56px;
  text-align: center;
}

.choice-btn:hover:not(:disabled) {
  background: linear-gradient(145deg, #3a3a7a, #2a2a6a);
  border-color: #7a7aff;
  transform: scale(1.03);
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.choice-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.choice-correct {
  background: linear-gradient(145deg, #1a6b1a, #0d4d0d) !important;
  border-color: #00ff88 !important;
  animation: correct-flash 0.5s ease;
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.choice-wrong {
  background: linear-gradient(145deg, #6b2a1a, #4d1a0d) !important;
  border-color: #ff6b35 !important;
  animation: wrong-shake 0.4s ease;
}

.question-hint {
  background: rgba(255, 215, 0, 0.1);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 15px;
  color: #ffd700;
  text-align: center;
}

.question-feedback {
  text-align: center;
  padding: 12px 16px;
  margin-top: 12px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
}

.feedback-correct {
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.15), rgba(72, 255, 180, 0.1));
  border: 2px solid rgba(0, 255, 136, 0.5);
  color: #00ff88;
  font-size: 20px;
  font-weight: 700;
  padding: 16px 20px;
  animation: feedback-correct-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-correct::before {
  content: '\2B50 ';
}

.feedback-wrong {
  background: rgba(255, 107, 53, 0.1);
  border: 2px solid rgba(255, 107, 53, 0.3);
  color: #ff8c5a;
  animation: feedback-wrong-slide 0.4s ease;
}

@keyframes feedback-correct-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes feedback-wrong-slide {
  0% { transform: translateY(-10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* --- Confetti Canvas --- */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10001;
}

/* --- Celebration Big Text --- */
.celebration-text {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-family: 'Press Start 2P', monospace;
  font-size: 36px;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3), 3px 3px 0 #b8860b;
  z-index: 10002;
  pointer-events: none;
  animation: celebration-pop 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  white-space: nowrap;
}

@keyframes celebration-pop {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.3) rotate(3deg); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  70% { transform: translate(-50%, -50%) scale(1.05); }
  85% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
}

/* --- Star burst particles around correct answer --- */
.star-particle {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 10000;
  animation: star-fly 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.star-particle::before {
  content: '\2B50';
  font-size: 16px;
}

@keyframes star-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--sx), var(--sy)) scale(0.3); opacity: 0; }
}

/* --- Coin fly animation for correct answers --- */
.coin-fly {
  position: fixed;
  font-size: 24px;
  pointer-events: none;
  z-index: 10003;
  animation: coin-fly-up 1s ease-out forwards;
}

@keyframes coin-fly-up {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  50% { transform: translateY(-40px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-80px) scale(0.8); opacity: 0; }
}

/* --- Explanation Panel (wrong answer teaching) --- */
.question-explanation {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.12), rgba(147, 130, 255, 0.08));
  border: 2px solid rgba(96, 165, 250, 0.4);
  border-radius: 14px;
  padding: 18px 20px;
  margin-top: 14px;
  animation: explanation-appear 0.5s ease;
}

@keyframes explanation-appear {
  0% { transform: translateY(10px); opacity: 0; max-height: 0; }
  100% { transform: translateY(0); opacity: 1; max-height: 300px; }
}

.explanation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.explanation-icon {
  font-size: 24px;
}

.explanation-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: #93c5fd;
}

.explanation-answer {
  background: rgba(0, 255, 136, 0.1);
  border: 2px solid rgba(0, 255, 136, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 17px;
  font-weight: 600;
  color: #4ade80;
}

.explanation-answer::before {
  content: '\2705 The answer is: ';
  color: #86efac;
  font-weight: 500;
}

.explanation-text {
  font-size: 15px;
  line-height: 1.6;
  color: #c4b5fd;
}

/* --- Correct answer highlight glow --- */
.choice-correct {
  background: linear-gradient(145deg, #1a6b1a, #0d4d0d) !important;
  border-color: #00ff88 !important;
  animation: correct-glow 0.6s ease;
  box-shadow: 0 0 25px rgba(0, 255, 136, 0.5), 0 0 50px rgba(0, 255, 136, 0.2);
  transform: scale(1.05);
  transition: transform 0.3s ease;
}

@keyframes correct-glow {
  0% { box-shadow: 0 0 0 rgba(0, 255, 136, 0); transform: scale(1); }
  50% { box-shadow: 0 0 40px rgba(0, 255, 136, 0.6); transform: scale(1.08); }
  100% { box-shadow: 0 0 25px rgba(0, 255, 136, 0.5); transform: scale(1.05); }
}

/* Show correct answer when revealing after wrong */
.choice-reveal-correct {
  background: linear-gradient(145deg, #1a5b3a, #0d3d2d) !important;
  border-color: #4ade80 !important;
  box-shadow: 0 0 15px rgba(74, 222, 128, 0.3);
  animation: reveal-pulse 0.6s ease;
}

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

.question-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #ffd700;
}

/* --- Buttons --- */
.btn-primary {
  padding: 14px 28px;
  font-family: 'Fredoka', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(145deg, #ffd700, #ffaa00);
  border: 3px solid #cc8800;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 48px;
  min-width: 44px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.btn-primary:active {
  transform: scale(0.95);
}

.btn-secondary {
  padding: 12px 24px;
  font-family: 'Fredoka', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  min-width: 44px;
}

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

/* --- Dialog Overlay --- */
.dialog-panel {
  background: linear-gradient(145deg, #1e1e3a, #16162a);
  border: 3px solid #4a4a8a;
  border-radius: 20px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow:
    0 0 30px rgba(100, 100, 255, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.5);
}

.dialog-speaker {
  margin-bottom: 8px;
}

#dialog-speaker-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #ffd700;
  text-transform: uppercase;
}

.dialog-text {
  font-size: 18px;
  line-height: 1.6;
  color: #e0e0f0;
  margin-bottom: 20px;
}

.dialog-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialog-choice-btn {
  padding: 14px 20px;
  font-family: 'Fredoka', sans-serif;
  font-size: 17px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(145deg, #2a2a5a, #20204a);
  border: 2px solid #4a4a8a;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 48px;
  text-align: left;
}

.dialog-choice-btn:hover {
  background: linear-gradient(145deg, #3a3a7a, #2a2a6a);
  border-color: #ffd700;
  padding-left: 28px;
}

/* --- Speech Bubble --- */
#speech-bubble {
  position: absolute;
  z-index: 80;
  background: #fff;
  color: #222;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  max-width: 200px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transform: translateX(-50%);
  pointer-events: none;
  animation: bubble-pop 0.3s ease;
}

.speech-bubble-tail {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid #fff;
}

/* --- Toast Notifications --- */
#toast-container {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-20px) scale(0.9);
  transition: all 0.3s ease;
  white-space: nowrap;
  pointer-events: auto;
}

.toast-enter {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-exit {
  opacity: 0;
  transform: translateY(-10px) scale(0.9);
}

.toast-success {
  background: linear-gradient(145deg, #1a6b1a, #0d4d0d);
  border: 2px solid #00ff88;
  color: #00ff88;
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.2);
}

.toast-info {
  background: linear-gradient(145deg, #1a3a6b, #0d2a4d);
  border: 2px solid #4a9fff;
  color: #88ccff;
  box-shadow: 0 0 15px rgba(74, 159, 255, 0.2);
}

.toast-warning {
  background: linear-gradient(145deg, #6b4a1a, #4d350d);
  border: 2px solid #ffaa00;
  color: #ffd700;
  box-shadow: 0 0 15px rgba(255, 170, 0, 0.2);
}

.toast-reward {
  background: linear-gradient(145deg, #3a2a6b, #2a1a5a);
  border: 2px solid #ffd700;
  color: #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
  animation: reward-glow 1s ease infinite;
}

/* --- Modal --- */
.modal-panel {
  background: linear-gradient(145deg, #1e1e3a, #16162a);
  border: 3px solid #4a4a8a;
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 420px;
  width: 85%;
  text-align: center;
  box-shadow:
    0 0 40px rgba(100, 100, 255, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #ffd700;
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-message {
  font-size: 17px;
  color: #ccc;
  margin-bottom: 24px;
  line-height: 1.5;
}

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

/* --- Menu Overlay --- */
.menu-panel {
  background: linear-gradient(145deg, #1e1e3a, #16162a);
  border: 3px solid #4a4a8a;
  border-radius: 20px;
  padding: 24px;
  max-width: 380px;
  width: 85%;
  box-shadow:
    0 0 30px rgba(100, 100, 255, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.5);
}

.menu-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #ffd700;
  text-align: center;
  margin-bottom: 20px;
}

#menu-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.menu-item-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #e0e0f0;
  font-family: 'Fredoka', sans-serif;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 48px;
}

.menu-item-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 215, 0, 0.3);
}

.menu-item-icon {
  font-size: 20px;
}

/* --- Shake Animation --- */
.shake {
  animation: wrong-shake 0.4s ease;
}

/* === ANIMATIONS === */

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

@keyframes currency-pulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes overlay-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes overlay-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes correct-flash {
  0% { transform: scale(1); }
  20% { transform: scale(1.1); }
  40% { transform: scale(0.95); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}

@keyframes bubble-pop {
  0% { transform: translateX(-50%) scale(0); opacity: 0; }
  60% { transform: translateX(-50%) scale(1.1); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes reward-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.3); }
  50% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.6); }
}

@keyframes star-burst {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.2) rotate(180deg); opacity: 0.8; }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

@keyframes coin-fly {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-60px) scale(0.5); opacity: 0; }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive adjustments --- */
@media (max-width: 480px) {
  #hud-currency {
    gap: 6px;
  }

  .hud-item {
    padding: 4px 8px;
    font-size: 12px;
  }

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

  #hud-quest {
    padding: 6px 10px;
    font-size: 11px;
    max-width: 35%;
  }

  .hud-btn {
    width: 54px;
    height: 54px;
  }

  .hud-btn-icon {
    font-size: 18px;
  }

  .hud-btn-label {
    font-size: 7px;
  }

  .question-panel {
    padding: 20px 16px;
  }

  .question-choices {
    grid-template-columns: 1fr;
  }

  .choice-btn {
    min-height: 48px;
  }
}

@media (max-width: 360px) {
  #hud-top {
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
  }

  #hud-currency {
    justify-content: center;
  }

  #hud-quest {
    max-width: 100%;
    text-align: center;
  }
}

/* --- Safe area insets for notched devices --- */
@supports (padding: env(safe-area-inset-top)) {
  #hud-top {
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  #hud-bottom {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
