* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  touch-action: manipulation;
  -ms-touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

/* 더블탭 줌 방지 */
html, body {
  touch-action: pan-x pan-y;
  overscroll-behavior: none;
}

:root {
  --pixel-border: 4px;
  --poke-yellow: #FFCB05;
  --poke-blue: #3466AF;
  --poke-red: #EE1515;
  --poke-dark: #1a1a2e;
  --font-pixel: 'Press Start 2P', monospace;
  --font-kr: 'Galmuri11', 'Galmuri9', sans-serif;
  --font-kr-bold: 'Galmuri11 Bold', 'Galmuri11', sans-serif;
  --font-title: 'Galmuri14', 'Galmuri11', sans-serif;
}

body {
  font-family: var(--font-kr);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--poke-dark);
}

/* ===== 픽셀 박스 유틸 ===== */
.pixel-box {
  border: var(--pixel-border) solid #333;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.3),
    inset -2px -2px 0 rgba(0,0,0,0.2),
    6px 6px 0 rgba(0,0,0,0.3);
  border-radius: 4px;
}

/* 화면 관리 */
.screen {
  display: none;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: absolute;
  top: 0; left: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ===== 음악 시작 화면 ===== */
#music-start-screen {
  background: linear-gradient(180deg, #2c3e7a 0%, #1a1a4e 100%);
  cursor: pointer;
  text-align: center;
  border: 8px solid var(--poke-yellow);
}

.music-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.music-pikachu {
  width: 200px; height: 200px;
  filter: drop-shadow(0 0 20px rgba(255,203,5,0.5));
  animation: bounce 1s ease infinite alternate;
}

.music-prompt .press-space {
  font-family: var(--font-kr);
  font-size: 28px;
  color: var(--poke-yellow);
  text-shadow: 2px 2px 0 #000;
}

/* ===== 시작 화면 ===== */
#start-screen {
  background-color: #1a1a4e;
  background-size: cover;
  background-position: center;
  color: white;
  text-align: center;
  gap: 12px;
  overflow: hidden;
  position: relative;
  border: 8px solid var(--poke-yellow);
}

.lightning {
  position: absolute;
  font-size: 80px;
  opacity: 0.12;
  animation: lightningPulse 2s ease-in-out infinite;
  pointer-events: none;
}
.lightning-1 { top: 5%; left: 5%; }
.lightning-2 { top: 10%; right: 8%; animation-delay: 0.5s; font-size: 60px; }
.lightning-3 { bottom: 15%; left: 10%; animation-delay: 1s; font-size: 50px; }
.lightning-4 { bottom: 10%; right: 5%; animation-delay: 1.5s; font-size: 70px; }

.pokemon-logo {
  width: 560px;
  z-index: 2;
  filter: drop-shadow(3px 3px 0 rgba(0,0,0,0.5));
}

#start-screen h1 {
  font-family: var(--font-title);
  font-weight: bold;
  font-size: 56px;
  margin-top: -10px;
  color: var(--poke-yellow);
  text-shadow: 3px 3px 0 #1A3A6E;
  letter-spacing: 6px;
  animation: bounce 1s ease infinite alternate;
  z-index: 2;
}

.start-pikachu img {
  width: 200px; height: 200px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 25px rgba(255,203,5,0.4));
  animation: pikaFloat 2s ease-in-out infinite;
  z-index: 2;
}

/* 세이브 정보 */
#save-info {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--poke-yellow);
  text-shadow: 1px 1px 0 #000;
  margin: 8px 0;
  z-index: 2;
  line-height: 1.6;
}

/* 메뉴 버튼 (픽셀 스타일) */
.menu-buttons {
  display: flex;
  gap: 12px;
  z-index: 2;
  margin-top: 8px;
  width: 80%;
  max-width: 320px;
}

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

.menu-btn {
  font-family: var(--font-kr-bold);
  font-size: 24px;
  padding: 12px 32px;
  border: 4px solid #222;
  border-radius: 2px;
  background: linear-gradient(180deg, #4a90d9 0%, #3466AF 100%);
  color: white;
  cursor: pointer;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.4);
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.3),
    inset -2px -2px 0 rgba(0,0,0,0.2),
    4px 4px 0 rgba(0,0,0,0.4);
  transition: transform 0.1s;
}

.menu-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #5aa0e9 0%, #4476BF 100%);
}

.menu-btn:active {
  transform: translateY(2px);
  box-shadow:
    inset 2px 2px 0 rgba(0,0,0,0.2),
    inset -2px -2px 0 rgba(255,255,255,0.1),
    2px 2px 0 rgba(0,0,0,0.4);
}

.menu-btn.btn-danger {
  background: linear-gradient(180deg, #ff4444 0%, #cc0000 100%);
}

.menu-btn.btn-danger:hover {
  background: linear-gradient(180deg, #ff5555 0%, #dd1111 100%);
}

.blink { animation: blink 1s ease-in-out infinite; }

/* 세이브 카드 */
.save-card {
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(255,215,0,0.4);
  border-radius: 6px;
  padding: 10px 16px;
  text-align: center;
  min-width: 200px;
}

.save-title {
  font-family: var(--font-kr-bold);
  font-size: 14px;
  color: var(--poke-yellow);
  margin-bottom: 6px;
}

.save-row {
  font-size: 13px;
  color: #ccd;
  margin-bottom: 3px;
}

.save-bar {
  width: 100%;
  height: 8px;
  background: rgba(0,0,0,0.4);
  border-radius: 4px;
  margin-top: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}

.save-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #8BC34A);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* 옵션 */
#options-area {
  z-index: 2;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.option-label {
  font-size: 14px;
  color: #bbd;
  white-space: nowrap;
}

.toggle-buttons {
  display: flex;
  gap: 4px;
}

.diff-btn {
  font-family: var(--font-kr);
  font-size: 13px;
  padding: 4px 12px;
  border: 2px solid #556;
  border-radius: 3px;
  background: rgba(0,0,0,0.3);
  color: #889;
  cursor: pointer;
  transition: all 0.15s;
}

.diff-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.diff-age {
  font-size: 10px;
  color: #889;
}

.diff-btn.active {
  background: linear-gradient(180deg, #4a90d9 0%, #3466AF 100%);
  color: white;
  border-color: #ffd740;
}


/* ===== 확인/일시정지 팝업 (RPG 대화창 스타일) ===== */
#confirm-overlay, #pause-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

#confirm-overlay.active, #pause-overlay.active {
  display: flex;
}

#confirm-box, #pause-box {
  background: linear-gradient(180deg, #3a5aaa 0%, #2a4080 100%);
  border: 4px solid #ffd740;
  border-radius: 3px;
  padding: 30px 40px;
  text-align: center;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.15),
    inset -2px -2px 0 rgba(0,0,0,0.2),
    6px 6px 0 rgba(0,0,0,0.4);
  animation: quizIn 0.3s ease-out;
}

#confirm-msg {
  font-family: var(--font-kr-bold);
  font-size: 20px;
  color: white;
  margin-bottom: 22px;
  line-height: 1.6;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.confirm-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
}

#pause-title {
  font-family: var(--font-kr);
  font-size: 44px;
  color: var(--poke-yellow);
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 12px;
}

#pause-stats {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: #aac;
  margin-bottom: 20px;
  line-height: 2;
}

/* ===== 게임 화면 ===== */
#game-screen { background-color: #111; }
#game-screen.active { justify-content: flex-start; }

/* ===== 상단 메뉴 바 ===== */
#top-bar {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 15;
}

/* ===== 하단 통합 UI ===== */
#bottom-ui {
  width: 100%;
  z-index: 10;
  flex-shrink: 0;
}

#status-bar {
  width: 100%;
  padding: 5px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, #3a6abf 0%, #2a4a8f 100%);
  border-top: 2px solid #4a7acf;
  border-bottom: 2px solid #1a3060;
  color: #fff;
  font-size: 13px;
}

#ball-count {
  font-family: var(--font-kr-bold);
  font-size: 14px;
  font-weight: bold;
}

#catch-count {
  font-family: var(--font-kr-bold);
  font-size: 13px;
  font-weight: bold;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

#sound-btn, #pause-btn {
  padding: 3px 8px;
  border: 2px solid #555;
  background: linear-gradient(180deg, #4a6a9f 0%, #3a5a8f 100%);
  color: white;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.3),
    2px 2px 0 rgba(0,0,0,0.2);
}

.pixel-icon {
  image-rendering: pixelated;
}

#pokedex-btn {
  font-family: var(--font-kr);
  padding: 3px 12px;
  font-size: 13px;
  border: 2px solid #c00;
  background: linear-gradient(180deg, #ee3030 0%, #cc1515 100%);
  color: white;
  border-radius: 2px;
  cursor: pointer;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.3),
    2px 2px 0 rgba(0,0,0,0.2);
}

/* 게임 영역 */
#game-area {
  flex: 1;
  min-height: 0;
  position: relative;
  width: 100%;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: none;
  border-bottom: 4px solid #333;
}

#grass-decoration { display: none; }

/* ===== 포켓몬 ===== */
#pokemon-container {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 5;
}

/* 포켓몬 움직임 애니메이션 */
#pokemon-container.anim-float #pokemon-img {
  animation: pokeFloat 2s ease-in-out infinite;
}

#pokemon-container.anim-sway #pokemon-img {
  animation: pokeSway 1.8s ease-in-out infinite;
}

#pokemon-container.anim-bounce #pokemon-img {
  animation: pokeBounce 1.2s ease-in-out infinite;
}

#pokemon-container.anim-spin #pokemon-img {
  animation: pokeSpin 3s linear infinite;
}

#pokemon-container.anim-wiggle #pokemon-img {
  animation: pokeWiggle 0.8s ease-in-out infinite;
}

#pokemon-container.hidden {
  opacity: 0;
  transform: scale(0.3);
  pointer-events: none;
}

#pokemon-glow {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 40%, transparent 70%);
  pointer-events: none;
  z-index: -1;
  animation: glowPulse 1.2s ease-in-out infinite;
}

/* 이름표 */
#pokemon-name-label {
  background: linear-gradient(180deg, #48b860 0%, #38a050 100%);
  color: white;
  padding: 4px 14px;
  border: 2px solid #2a7a3a;
  border-radius: 2px;
  font-family: var(--font-kr-bold);
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 6px;
  white-space: nowrap;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

#pokemon-img {
  image-rendering: pixelated;
  filter:
    drop-shadow(0 0 0 white)
    drop-shadow(0 0 0 white)
    drop-shadow(2px 0 0 white)
    drop-shadow(-2px 0 0 white)
    drop-shadow(0 2px 0 white)
    drop-shadow(0 -2px 0 white)
    drop-shadow(0 0 10px rgba(255,255,255,0.6))
    drop-shadow(3px 3px 6px rgba(0,0,0,0.5));
  transition: transform 0.3s;
}

#pokemon-img.shake {
  animation: shake 0.5s ease;
}

#pokemon-img.sucking {
  animation: suckIn 0.6s ease-in forwards;
}

#catch-indicator {
  position: absolute;
  top: -20px;
  right: -20px;
  font-size: 60px;
  font-weight: bold;
  color: var(--poke-yellow);
  text-shadow: 0 0 15px rgba(255,215,0,0.8), 3px 3px 0 #000;
  display: none;
  animation: pulse 0.4s ease infinite;
}

#catch-indicator.show { display: block; }

/* ===== 몬스터볼 ===== */
#pokeball {
  position: absolute;
  z-index: 6;
  transition: none;
}

.pokeball-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pokeball-top, .pokeball-bottom {
  display: block;
  image-rendering: pixelated;
  transition: transform 0.4s ease;
}

.pokeball-wrap {
  filter: drop-shadow(2px 2px 6px rgba(0,0,0,0.5));
}

#pokeball.throwing .pokeball-wrap {
  animation: spin 0.35s linear infinite;
}

/* 볼 대기 (둥둥) */
#pokeball.ready .pokeball-wrap {
  animation: ballReady 0.8s ease-in-out infinite;
}

@keyframes ballReady {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* 볼 열림 (포획 시도 중) */
#pokeball.ball-open .pokeball-top {
  transform: translateY(-12px) rotate(-20deg);
}

#pokeball.ball-open .pokeball-bottom {
  transform: translateY(6px) rotate(5deg);
}

#pokeball.ball-open .pokeball-wrap {
  animation: none;
  filter: drop-shadow(2px 2px 6px rgba(0,0,0,0.5)) drop-shadow(0 0 15px rgba(255,255,255,0.8));
}

/* 포획 성공 - 볼 닫힌 후 빛 폭발 */
#pokeball.catch-explode .pokeball-top {
  animation: topFlyOff 0.5s ease-out forwards;
}

#pokeball.catch-explode .pokeball-bottom {
  animation: bottomFlyOff 0.5s ease-out forwards;
}

#pokeball.catch-explode .pokeball-wrap {
  animation: none;
}

#pokeball.catch-explode {
  animation: ballFadeOut 0.6s ease-out 0.3s forwards;
}

#pokeball.miss-bounce .pokeball-wrap {
  animation: spin 0.6s linear infinite;
}

@keyframes topFlyOff {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(-40px) rotate(-30deg); opacity: 0; }
}

@keyframes bottomFlyOff {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(25px) rotate(10deg); opacity: 0; }
}

@keyframes ballFadeOut {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.5); filter: brightness(3); }
  100% { opacity: 0; transform: scale(2.5); filter: brightness(5); }
}

/* 잔상 */
.ball-trail {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.5), rgba(255,80,80,0.2));
  pointer-events: none;
  z-index: 5;
  animation: trailFade 0.35s ease-out forwards;
}

/* ===== 잡힌 포켓몬 바 ===== */
#caught-bar {
  width: 100%;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: linear-gradient(180deg, #4a3a2a 0%, #3a2a1a 100%);
  border-top: 2px solid #6a5a4a;
  border-bottom: 2px solid #2a1a0a;
  z-index: 10;
  overflow-x: auto;
  min-height: 48px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  touch-action: pan-x;
}

#caught-bar::-webkit-scrollbar { display: none; }
#caught-bar { scrollbar-width: none; }

.caught-thumb {
  min-width: 42px;
  height: 42px;
  animation: thumbPop 0.5s ease-out;
}

.caught-thumb img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.6));
}

.caught-thumb.new {
  animation: thumbFlyIn 0.8s ease-out;
}

/* ===== 메시지 (GBA 대화창) ===== */
#message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-kr-bold);
  font-size: 28px;
  font-weight: bold;
  color: white;
  background: linear-gradient(180deg, #3a5aaa 0%, #2a4080 100%);
  border: 3px solid #ffd740;
  border-radius: 3px;
  padding: 16px 32px;
  text-align: center;
  z-index: 20;
  display: none;
  pointer-events: none;
  line-height: 1.6;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.15),
    inset -2px -2px 0 rgba(0,0,0,0.2),
    4px 4px 0 rgba(0,0,0,0.3);
}

#message.show {
  display: block;
  animation: msgPop 0.3s ease;
}

@keyframes msgPop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* 스페이스바 힌트 */
#spacebar-hint {
  width: 100%;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(180deg, #3a6abf 0%, #2a4a8f 100%);
  border-top: 3px solid #1a3060;
  color: #dde8ff;
  font-size: 16px;
  z-index: 10;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.key-icon {
  font-family: var(--font-pixel);
  background: linear-gradient(180deg, #ffd740 0%, #ffb300 100%);
  color: #333;
  padding: 4px 14px;
  border: 2px solid #c68a00;
  border-radius: 2px;
  font-size: 10px;
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.4),
    2px 2px 0 rgba(0,0,0,0.3);
}

/* ===== 도감 화면 ===== */
#pokedex-screen {
  background: linear-gradient(180deg, #c0392b 0%, #962818 100%);
  color: white;
  text-align: center;
  padding: 20px 15px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 6px solid #222;
  -webkit-overflow-scrolling: touch;
}

#pokedex-screen.active {
  justify-content: flex-start;
  align-items: stretch;
  position: relative;
}

#pokedex-footer {
  position: sticky;
  bottom: 0;
  padding: 10px 12px;
  background: linear-gradient(180deg, transparent, #962818 30%);
  flex-shrink: 0;
}

#pokedex-footer .menu-btn {
  width: 100%;
  display: block;
}

#pokedex-screen h2 {
  font-family: var(--font-title);
  font-weight: bold;
  font-size: 40px;
  color: white;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.4);
  margin-bottom: 16px;
}

#pokedex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 10px;
}

.pokedex-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  border: 3px solid #666;
  border-radius: 2px;
  padding: 8px;
  text-align: center;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.1), 3px 3px 0 rgba(0,0,0,0.3);
}

.pokedex-card.caught {
  background: linear-gradient(180deg, rgba(255,215,0,0.2) 0%, rgba(255,215,0,0.05) 100%);
  border-color: var(--poke-yellow);
}

.pokedex-card.uncaught { opacity: 1; }
.pokedex-card img { width: 100px; height: 100px; image-rendering: pixelated; }
.pokedex-card.uncaught img { filter: grayscale(1) opacity(0.5); }
.pokedex-card .name {
  margin-top: 6px;
  font-size: 16px;
  font-weight: bold;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.press-space {
  font-size: 20px;
  margin-top: 16px;
}

/* ===== 퀴즈 (RPG 대화창 스타일) ===== */
#quiz-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

#quiz-overlay.active { display: flex; }

#quiz-box {
  background: linear-gradient(180deg, #3a5aaa 0%, #2a4080 100%);
  border: 4px solid #ffd740;
  border-radius: 3px;
  padding: 30px 40px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.1),
    6px 6px 0 rgba(0,0,0,0.3);
  animation: quizIn 0.5s ease-out;
}

#quiz-pokemon-img { margin-bottom: 10px; }
#quiz-pokemon-img img {
  width: 100px; height: 100px;
  filter:
    drop-shadow(2px 0 0 white) drop-shadow(-2px 0 0 white)
    drop-shadow(0 2px 0 white) drop-shadow(0 -2px 0 white)
    drop-shadow(0 0 10px rgba(255,255,255,0.5));
  animation: pikaFloat 2s ease-in-out infinite;
}

#quiz-title {
  font-family: var(--font-kr-bold);
  font-size: 18px;
  color: var(--poke-yellow);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
  margin-bottom: 16px;
  line-height: 1.6;
}

#quiz-question {
  font-family: var(--font-kr-bold);
  font-size: 40px;
  font-weight: bold;
  color: var(--poke-yellow);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

#quiz-input {
  -webkit-user-select: text;
  user-select: text;
  font-family: var(--font-kr-bold);
  font-size: 36px;
  text-align: center;
  padding: 4px 8px;
  border: 3px solid #ffd740;
  border-radius: 2px;
  outline: none;
  width: 80px;
  background: #1a2050;
  color: white;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.3);
}

/* 숫자 입력 스피너 제거 */
#quiz-input::-webkit-outer-spin-button,
#quiz-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#quiz-input[type=number] {
  -moz-appearance: textfield;
}

#quiz-input:focus {
  border-color: white;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.3), 0 0 8px rgba(255,215,64,0.4);
}

/* 숫자 키패드 */
#quiz-numpad {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px auto 0;
  max-width: 240px;
}

.numpad-btn {
  font-family: var(--font-kr-bold);
  font-size: 24px;
  font-weight: bold;
  padding: 12px 0;
  border: 3px solid #555;
  border-radius: 4px;
  background: linear-gradient(180deg, #4a6a9f 0%, #3a5a8f 100%);
  color: white;
  cursor: pointer;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.3),
    2px 2px 0 rgba(0,0,0,0.3);
  -webkit-tap-highlight-color: transparent;
}

.numpad-btn:active {
  transform: translateY(2px);
  box-shadow: inset 1px 1px 0 rgba(0,0,0,0.2);
}

.numpad-ok {
  background: linear-gradient(180deg, #48b860 0%, #38a050 100%);
  border-color: #2a7a3a;
}

.numpad-del {
  background: linear-gradient(180deg, #ee5050 0%, #cc3030 100%);
  border-color: #a02020;
}

#quiz-box.quiz-success #quiz-numpad {
  display: none !important;
}

#quiz-feedback {
  font-family: var(--font-kr-bold);
  font-weight: bold;
  font-size: 20px;
  margin-top: 12px;
  min-height: 28px;
}

/* 성공 시 퀴즈 내용 숨기고 메시지만 크게 */
#quiz-box.quiz-success #quiz-pokemon-img,
#quiz-box.quiz-success #quiz-title,
#quiz-box.quiz-success #quiz-question,
#quiz-box.quiz-success #quiz-input,
#quiz-box.quiz-success #quiz-hint {
  display: none !important;
}

#quiz-box.quiz-success #quiz-feedback {
  font-size: 32px;
  padding: 40px 0;
}

#quiz-box.quiz-success {
  animation: quizIn 0.3s ease-out;
}

#quiz-feedback.correct { color: #6f6; }

.correct-title {
  font-size: 42px;
  color: var(--poke-yellow);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.4);
  margin-bottom: 8px;
}
#quiz-feedback.wrong { color: #f66; }

#quiz-box.quiz-shake {
  animation: quizShake 0.5s ease;
}

@keyframes quizShake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-12px) rotate(-1deg); }
  20% { transform: translateX(12px) rotate(1deg); }
  30% { transform: translateX(-10px) rotate(-1deg); }
  40% { transform: translateX(10px) rotate(1deg); }
  50% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  70% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

#quiz-hint {
  font-size: 12px;
  color: #889;
  margin-top: 10px;
}

/* ===== 등장 집중선 ===== */
.impact-line {
  position: absolute;
  width: 6px;
  background: linear-gradient(to bottom, transparent 0%, var(--poke-yellow) 20%, white 50%, var(--poke-yellow) 80%, transparent 100%);
  pointer-events: none;
  z-index: 8;
  opacity: 0;
  border-radius: 3px;
  box-shadow: 0 0 8px var(--poke-yellow), 0 0 16px rgba(255,203,5,0.4);
}

.impact-line.fire {
  animation: impactShoot 0.7s ease-out forwards;
}

@keyframes impactShoot {
  0% {
    opacity: 1;
    transform: translate(var(--sx), var(--sy)) rotate(var(--angle)) scaleY(2.5);
  }
  40% {
    opacity: 1;
    transform: translate(0, 0) rotate(var(--angle)) scaleY(1.2);
  }
  60% {
    opacity: 1;
    transform: translate(0, 0) rotate(var(--angle)) scaleY(1);
  }
  85% {
    opacity: 0.7;
    transform: translate(0, 0) rotate(var(--angle)) scaleY(0.6);
  }
  100% {
    opacity: 0;
    transform: translate(0, 0) rotate(var(--angle)) scaleY(0);
  }
}

/* 등장 시 화면 번쩍 */
.spawn-flash {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: white;
  z-index: 7;
  pointer-events: none;
  animation: spawnFlashAnim 0.5s ease-out forwards;
}

@keyframes spawnFlashAnim {
  0% { opacity: 0.7; }
  100% { opacity: 0; }
}

/* ===== 이펙트 ===== */
.catch-success-flash {
  /* 사각 플래시 제거, catch-burst가 대체 */
}

.catch-burst {
  position: fixed;
  z-index: 15;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,215,0,0.5) 30%, transparent 70%);
  animation: burstExpand 1.2s ease-out forwards;
}

.star-particle {
  position: absolute;
  font-size: 28px;
  pointer-events: none;
  z-index: 25;
  animation: starFloat 1s ease-out forwards;
}

/* ===== 애니메이션 ===== */
@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-12px); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

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

@keyframes glowPulse {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px) rotate(-4deg); }
  40% { transform: translateX(12px) rotate(4deg); }
  60% { transform: translateX(-8px) rotate(-2deg); }
  80% { transform: translateX(8px) rotate(2deg); }
}

@keyframes suckIn {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  50% { transform: scale(0.5); opacity: 0.8; filter: brightness(2); }
  100% { transform: scale(0); opacity: 0; filter: brightness(3); }
}

@keyframes messageIn {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes flashBg {
  0% { background-color: transparent; }
  30% { background-color: rgba(255,255,255,0.4); }
  60% { background-color: rgba(255,215,0,0.2); }
  100% { background-color: transparent; }
}

@keyframes burstExpand {
  0% { opacity: 1; width: 0; height: 0; }
  50% { opacity: 0.8; width: 200vmax; height: 200vmax; }
  100% { opacity: 0; width: 250vmax; height: 250vmax; }
}

/* ballExplode는 catch-explode로 대체됨 */

@keyframes trailFade {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.2); }
}

@keyframes thumbPop {
  0% { transform: scale(0); }
  70% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes thumbFlyIn {
  0% { transform: scale(0) translateY(-80px); opacity: 0; }
  60% { transform: scale(1.2) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes starFloat {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}

/* 포켓몬 움직임들 */
@keyframes pokeFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes pokeSway {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-8px) rotate(-3deg); }
  75% { transform: translateX(8px) rotate(3deg); }
}

@keyframes pokeBounce {
  0%, 100% { transform: translateY(0) scaleY(1); }
  30% { transform: translateY(-15px) scaleY(1.05); }
  50% { transform: translateY(0) scaleY(0.93); }
  65% { transform: translateY(-6px) scaleY(1.02); }
}

@keyframes pokeSpin {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

@keyframes pokeWiggle {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-5deg); }
  40% { transform: rotate(5deg); }
  60% { transform: rotate(-3deg); }
  80% { transform: rotate(3deg); }
}

@keyframes pikaFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

@keyframes lightningPulse {
  0%, 100% { opacity: 0.08; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.1); }
}

/* 볼 카운트 파티클 */
.ball-particle {
  position: fixed;
  font-family: var(--font-kr-bold);
  font-size: 16px;
  font-weight: bold;
  pointer-events: none;
  z-index: 50;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
  animation: ballParticleFly 0.7s ease-out forwards;
}

@keyframes ballParticleFly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0.5); }
}

#ball-count.ball-bump {
  animation: ballBump 0.15s ease;
}

@keyframes ballBump {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

@keyframes quizIn {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ===== 모바일/PC 표시 제어 ===== */
.mobile-only { display: none !important; }
.desktop-only { display: inline-block; }

@media (hover: none) and (pointer: coarse) {
  .mobile-only { display: flex !important; }
  .desktop-only { display: none !important; }
}

/* ===== 포켓몬 카드 팝업 ===== */
#card-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

#card-overlay.active { display: flex; }

#pokemon-card {
  width: 280px;
  background: linear-gradient(180deg, #f8e838 0%, #e8d020 50%, #d8c018 100%);
  border: 6px solid #c8a808;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.4),
    8px 8px 0 rgba(0,0,0,0.4);
  animation: cardFlipIn 0.5s ease-out;
}

#card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#card-name {
  font-family: var(--font-kr-bold);
  font-size: 20px;
  font-weight: bold;
  color: #333;
}

#card-id {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: #666;
}

#card-image-frame {
  background: linear-gradient(180deg, #c8e8f8 0%, #a8d8a8 100%);
  border: 3px solid #888;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.3);
}

#card-img {
  width: 150px;
  height: 150px;
  image-rendering: pixelated;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
}

#card-image-frame.caught-frame {
  background: linear-gradient(180deg, #fff8c0 0%, #ffe060 100%);
  box-shadow: inset 0 0 20px rgba(255,200,0,0.4);
}

#card-image-frame.caught-frame #card-img {
  animation: cardFloat 2s ease-in-out infinite;
}

@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

#card-type-badge {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 10px;
  font-family: var(--font-kr-bold);
  font-size: 13px;
  font-weight: bold;
  color: white;
  margin-bottom: 10px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

#card-type-badge.type-grass { background: #4CAF50; }
#card-type-badge.type-water { background: #2196F3; }
#card-type-badge.type-fire { background: #F44336; }

#card-evo-chain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.evo-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.evo-item img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  filter: grayscale(1) opacity(0.4);
  transition: filter 0.2s;
}

.evo-item.current img {
  filter: none;
  width: 56px;
  height: 56px;
}

.evo-item.current.is-caught img {
  animation: evoBlink 0.8s ease-in-out infinite;
}

@keyframes evoBlink {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.15) drop-shadow(0 0 4px rgba(255,255,255,0.5)); }
}

.evo-item .evo-name {
  font-size: 10px;
  color: #666;
  margin-top: 2px;
}

.evo-item.current .evo-name {
  color: #333;
  font-weight: bold;
}

.evo-arrow {
  font-size: 16px;
  color: #999;
  margin: 0 2px;
}

#card-info {
  font-size: 13px;
  color: #444;
  line-height: 1.6;
  background: rgba(255,255,255,0.4);
  border: 2px solid #bba030;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 8px;
  text-align: left;
}

#card-status {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: #888;
}

@keyframes cardFlipIn {
  0% { transform: perspective(600px) rotateY(90deg) scale(0.5); opacity: 0; }
  100% { transform: perspective(600px) rotateY(0) scale(1); opacity: 1; }
}

/* ===== 놓아주기 팝업 ===== */
#release-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

#release-overlay.active { display: flex; }

#release-box {
  background: linear-gradient(180deg, #3a5aaa 0%, #2a4080 100%);
  border: 4px solid #ffd740;
  border-radius: 3px;
  padding: 25px 35px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.15),
    6px 6px 0 rgba(0,0,0,0.4);
  animation: quizIn 0.4s ease-out;
}

#release-title {
  font-family: var(--font-kr-bold);
  font-size: 22px;
  color: var(--poke-yellow);
  margin-bottom: 8px;
}

#release-msg {
  font-size: 14px;
  color: #bbd;
  margin-bottom: 16px;
}

#release-pokemon-list {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.release-pokemon {
  width: 60px;
  height: 60px;
  position: relative;
}

.release-pokemon img {
  width: 60px;
  height: 60px;
  image-rendering: pixelated;
  filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.5));
}

.release-pokemon.flying {
  animation: releaseFly 0.8s ease-in forwards;
}

@keyframes releaseFly {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(1.2); opacity: 1; }
  100% { transform: translate(var(--fx), var(--fy)) scale(0.2) rotate(var(--fr)); opacity: 0; }
}

/* ===== 모바일 일시정지 버튼 ===== */
#mobile-pause-btn {
  position: fixed;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid #555;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 18px;
  z-index: 30;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 퀴즈 확인 버튼 ===== */
#quiz-submit-btn {
  font-family: var(--font-kr-bold);
  font-size: 20px;
  font-weight: bold;
  margin: 12px auto 0;
  display: block;
  padding: 10px 40px;
  border: 3px solid #ffd740;
  border-radius: 3px;
  background: linear-gradient(180deg, #48b860 0%, #38a050 100%);
  color: white;
  cursor: pointer;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.3),
    3px 3px 0 rgba(0,0,0,0.3);
}

#quiz-submit-btn:active {
  transform: translateY(2px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

#quiz-box.quiz-success #quiz-submit-btn,
#quiz-box.quiz-success #quiz-numpad {
  display: none !important;
}

/* 키패드 있으면 모바일 확인 버튼 숨김 */
#quiz-numpad[style*="grid"] ~ #quiz-submit-btn {
  display: none !important;
}

/* ===== 모바일 반응형 ===== */
@media (max-width: 768px) {
  .pokemon-logo { width: 320px; }
  #start-screen h1 {
    font-size: 32px;
    letter-spacing: 3px;
  }

  .menu-buttons {
    flex-direction: column;
    gap: 10px;
  }

  .menu-btn {
    font-size: 18px;
    padding: 10px 24px;
  }

  #save-info {
    font-size: 9px;
  }

  #score-bar {
    padding: 4px 10px;
    font-size: 11px;
  }

  #catch-count {
    font-size: 11px;
  }

  #spacebar-hint {
    font-size: 14px;
    padding: 6px;
  }

  #message {
    font-size: 20px;
    padding: 12px 20px;
  }

  #caught-bar {
    min-height: 42px;
  }

  .caught-thumb { min-width: 34px; height: 34px; }
  .caught-thumb img { width: 34px; height: 34px; }

  #pokedex-screen { padding: 10px 6px; }
  #pokedex-screen h2 { font-size: 24px; margin-bottom: 8px; }
  #pokedex-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .pokedex-card { padding: 6px; }
  .pokedex-card img { width: 70px; height: 70px; }
  .pokedex-card .name { font-size: 15px; }
  #pokedex-screen .menu-btn { font-size: 16px; padding: 8px 20px; }

  #quiz-box {
    padding: 20px 25px;
  }
  #quiz-title { font-size: 14px; }
  #quiz-question { font-size: 28px; }
  #quiz-input { font-size: 22px; width: 160px; }
  #quiz-pokemon-img img { width: 70px; height: 70px; }

  #confirm-box, #pause-box {
    padding: 20px 30px;
  }
  #confirm-msg { font-size: 16px; }

  .correct-title { font-size: 28px; }
  #quiz-box.quiz-success #quiz-feedback { font-size: 20px; padding: 25px 0; }

  .lightning { font-size: 50px; }
}

@media (max-width: 400px) {
  .pokemon-logo { width: 260px; }
  #start-screen h1 { font-size: 24px; }
  .menu-btn { font-size: 16px; padding: 8px 20px; }
  #message { font-size: 16px; }
  #quiz-question { font-size: 24px; }

  #pokedex-screen h2 { font-size: 20px; }
  #pokedex-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
  .pokedex-card img { width: 60px; height: 60px; }
  .pokedex-card .name { font-size: 14px; }
}


/* 캡쳐볼 선택 */
.ball-select {
  gap: 6px !important;
}

.ball-btn {
  padding: 4px !important;
  background: rgba(0,0,0,0.3) !important;
  border: 2px solid #556 !important;
  border-radius: 4px !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.ball-btn svg {
  image-rendering: pixelated;
}

.ball-btn.active {
  border-color: #ffd740 !important;
  background: rgba(255,215,64,0.2) !important;
  box-shadow: 0 0 8px rgba(255,215,64,0.3);
}
