/* ========== 게임 스테이지 ========== */
.math-stage {
  height: 50vh;
  min-height: 320px;
  max-height: 600px;
  background: linear-gradient(180deg, #1a1a2e 0%, #0f3460 50%, #16213e 100%);
  position: relative;
  overflow: hidden;
}

/* 별 배경 효과 */
.math-stage::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(2px 2px at 20% 30%, white, transparent),
    radial-gradient(2px 2px at 60% 70%, white, transparent),
    radial-gradient(1px 1px at 50% 50%, white, transparent),
    radial-gradient(1px 1px at 80% 10%, white, transparent),
    radial-gradient(2px 2px at 90% 60%, white, transparent),
    radial-gradient(1px 1px at 33% 80%, white, transparent);
  background-size: 200% 200%;
  animation: stars-move 20s linear infinite;
  opacity: 0.6;
}

@keyframes stars-move {
  from { background-position: 0 0; }
  to { background-position: 0 200%; }
}

/* ========== 플레이어 전투기 ========== */
.player-jet {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 48px;
  z-index: 10;
  filter: drop-shadow(0 0 10px rgba(76, 175, 80, 0.8));
  transition: left 0.1s ease, bottom 0.1s ease;
  user-select: none;
}

.player-jet.hit {
  animation: player-hit 400ms ease;
}

@keyframes player-hit {
  0%, 100% { opacity: 1; }
  25%, 75% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* ========== 적 전투기 ========== */
.enemy-jet {
  position: absolute;
  font-size: 42px;
  transform: rotate(180deg);
  filter: drop-shadow(0 0 8px rgba(244, 67, 54, 0.8));
  transition: top 0.1s ease, left 0.1s ease;
  user-select: none;
  z-index: 5;
}

.enemy-jet.explode {
  animation: enemy-explode 500ms ease forwards;
}

@keyframes enemy-explode {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(0); opacity: 0; }
}

/* ========== 미사일 ========== */
.missile {
  position: absolute;
  width: 4px;
  height: 12px;
  background: linear-gradient(180deg, #ffd54f 0%, #ff9800 100%);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255, 152, 0, 0.8);
  z-index: 8;
}

/* 기관총 총알 */
.missile.bullet {
  width: 3px;
  height: 8px;
  background: linear-gradient(180deg, #ffeb3b 0%, #ffc107 100%);
  box-shadow: 0 0 6px rgba(255, 235, 59, 0.9);
}

.missile.enemy {
  background: linear-gradient(180deg, #f44336 0%, #d32f2f 100%);
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.8);
}

/* 유도 미사일 */
.missile.guided {
  background: linear-gradient(180deg, #00bcd4 0%, #0097a7 100%);
  box-shadow: 0 0 10px rgba(0, 188, 212, 1);
}

/* ========== 수학 문제 카드 ========== */
#mathQuestionCard {
  border: 2px solid #4caf50;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

#mathQuestion {
  font-family: 'Courier New', monospace;
  color: #1a1a2e;
  font-weight: 700;
}

.math-option {
  min-height: 56px;
  font-size: 1.3rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.math-option:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.math-option.btn-correct {
  animation: math-correct-flash 600ms ease;
}

@keyframes math-correct-flash {
  0%, 100% { 
    border-color: inherit;
    background-color: transparent;
  }
  50% { 
    border-color: #4caf50;
    background-color: rgba(76, 175, 80, 0.3);
    transform: scale(1.1);
  }
}

.math-option.btn-wrong {
  animation: math-wrong-flash 600ms ease;
}

@keyframes math-wrong-flash {
  0%, 100% { 
    border-color: inherit;
    background-color: transparent;
  }
  50% { 
    border-color: #f44336;
    background-color: rgba(244, 67, 54, 0.3);
    transform: scale(0.9);
  }
}

/* ========== HUD 카드 ========== */
.card {
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  transition: transform 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

/* HP 깜빡임 */
#mathHP.blink-warning {
  animation: hp-blink 500ms ease;
}

@keyframes hp-blink {
  0%, 100% { color: inherit; }
  50% { 
    color: #ff5722; 
    text-shadow: 0 0 10px rgba(255, 87, 34, 0.8);
    transform: scale(1.2);
  }
}

/* 점수 증가 */
#mathScore.score-increase {
  animation: score-pop 400ms ease;
}

@keyframes score-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.4); color: #4caf50; }
}

/* ========== 토스트 메시지 ========== */
.math-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  min-width: 200px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1.1rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: toast-slide-in 300ms ease;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.toast-hit {
  background: linear-gradient(135deg, #4caf50, #8bc34a);
  color: white;
}

.toast-miss {
  background: linear-gradient(135deg, #f44336, #ff5722);
  color: white;
}

.toast-info {
  background: linear-gradient(135deg, #2196f3, #03a9f4);
  color: white;
}

/* ========== 폭발 이펙트 ========== */
.explosion {
  position: absolute;
  font-size: 48px;
  animation: explosion-anim 600ms ease forwards;
  z-index: 15;
  pointer-events: none;
}

@keyframes explosion-anim {
  0% { 
    opacity: 1;
    transform: scale(0.5) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.5) rotate(180deg);
  }
  100% { 
    opacity: 0;
    transform: scale(2) rotate(360deg);
  }
}

/* ========== 키보드 키 표시 ========== */
kbd {
  background-color: #f8f9fa;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: 0.9rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  color: #212529;  /* ← 이 줄 추가! (검정색) */
}

/* ========== 반응형 ========== */
@media (max-width: 576px) {
  .player-jet {
    font-size: 36px;
    bottom: 30px;
  }
  
  .enemy-jet {
    font-size: 32px;
  }
  
  .math-option {
    min-height: 48px;
    font-size: 1.1rem;
  }
  
  .math-stage {
    min-height: 280px;
  }

  #mathQuestion {
    font-size: 1.3rem;
  }
}

/* ========== 접근성 ========== */
.btn:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.25rem rgba(76, 175, 80, 0.25);
}

/* ========== 로딩 애니메이션 ========== */
.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ========== 모바일 컨트롤러 ========== */
.mobile-controller {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 180px;
  background: rgba(248, 249, 250, 0.95);
  border-top: 2px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  z-index: 1000;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

/* 방향 패드 (왼쪽) */
.dpad {
  position: relative;
  width: 140px;
  height: 140px;
  display: grid;
  grid-template-areas:
    ". up ."
    "left . right";
  gap: 5px;
}

.dpad-btn {
  width: 55px;
  height: 55px;
  background: linear-gradient(145deg, #4E73DF, #3653c7);
  border: 3px solid #2e4db7;
  border-radius: 12px;
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.1s;
}

.dpad-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  background: linear-gradient(145deg, #3653c7, #2e4db7);
}

.dpad-up { grid-area: up; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }

/* 액션 버튼 (오른쪽) */
.action-btns {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.action-btn {
  width: 70px;
  height: 70px;
  border: 3px solid;
  border-radius: 50%;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.1s;
}

.gun-btn {
  background: linear-gradient(145deg, #28a745, #1e8a36);
  border-color: #1e7e34;
  color: white;
}

.bomb-btn {
  background: linear-gradient(145deg, #dc3545, #c82333);
  border-color: #bd2130;
  color: white;
}

.action-btn:active {
  transform: scale(0.9);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 포기 버튼 (모바일) */
.quit-mobile {
  position: absolute;
  bottom: 10px;  /* top → bottom */
  left: 50%;
  transform: translateX(-50%);
}

/* 데스크톱에서는 모바일 컨트롤러 숨김 */
@media (min-width: 768px) {
  .mobile-controller {
    display: none;
  }
}

/* 모바일에서 게임 하단 여백 추가 */
@media (max-width: 767px) {
  body {
    padding-bottom: 200px;
  }
  
  #mathPlayArea {
    margin-bottom: 200px;
  }
}