body {
    margin:0; height:100vh;
    background:#111;
    display:flex; justify-content:center; align-items:center;
    overflow:hidden;
  }
  #gameContainer {
    position:relative;
    width:800px; height:600px;
    background:#222;
    box-shadow:0 0 12px rgba(0,0,0,0.6);
    overflow:hidden;
  }
  /* 래퍼: 애니메이션 대상 */
  #canvasWrapper {
    position:absolute; top:0; left:0;
    width:100%; height:100%;
    transform-origin:center center;
    z-index:1;
  }
  /* Idle(떠다니기) */
  @keyframes idleFloat {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(-8px); }
   100%  { transform: translateY(0); }
  }
  #canvasWrapper.idle {
    animation: idleFloat 0s ease-in-out infinite alternate;
  }
  /* Hit(흔들림+붉은 플래시) */

  @keyframes flashRed {
    0%,100% { filter:none; }
    50%     { filter: brightness(1.5) sepia(1) hue-rotate(-20deg); }
  }
  #canvasWrapper.hit {
    animation: linear 1, flashRed 0.3s linear 1;
  }
  /* Dead(축소+페이드아웃) */
  @keyframes fadeOutShrink {
    0%   { opacity:1; transform: scale(1); }
   100% { opacity:0; transform: scale(0.5); }
  }
  #canvasWrapper.dead {
    animation: fadeOutShrink 0.5s forwards;
  }
  #gameCanvas {
    position:absolute; top:0; left:0;
    width:100%; height:100%;
    display:block;
  }
  /* HUD & 팝업 */
  #hud { position:absolute; top:0; left:0; width:100%; height:100%; pointer-events:none; z-index:2; }
  #xpBar {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 16px;
    background: rgba(50, 50, 50, 0.8);
    border: 2px solid #111;
    border-radius: 10px;   /* 둥글게 */
    overflow: hidden;
    box-shadow: 0 0 5px rgba(0,0,0,0.7);
  }
  
  #xpFill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #4CAF50, #2196F3); /* 초록 → 파랑 그라데이션 */
    border-radius: 10px 0 0 10px;
    transition: width 0.5s ease, background 0.5s ease;
  }
  #xpFill{ height:100%; width:0; background:#3498db; }
  #timer {
    position: absolute;
    top: 35px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 24px;
    font-family: 'Press Start 2P', cursive;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
  }
  #skillIcons{ position:absolute; top:60px; left:10px; display:grid; grid-template-columns:repeat(3,32px); grid-auto-rows:32px; gap:6px; }
  .skillIcon{ display:flex; align-items:center; justify-content:center; width:32px; height:32px; background:#888; color:#fff; font-size:14px; border-radius:4px; }
  #level {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #fff;
    font-size: 18px;
    font-family: 'Press Start 2P', cursive;
    letter-spacing: 1px;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
  }
  #pauseBtn {
    position: absolute;
    top: 40px;
    right: 10px;
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    cursor: pointer;
    z-index: 2;
    transition: transform 0.2s ease;
    pointer-events: auto;
  }
  
  #pauseBtn:hover {
    transform: scale(1.1);
    /* ✅ hover 시에도 테두리 생기지 않도록 유지 */
    border-color: transparent;
  }
  
  /* 헤더(제목) */
  .skillHeader {
    font-size: 24px;
    color: #ffd700;
    text-align: center;
    margin-bottom: 16px;
  }
  
  /* 옵션 컨테이너 (세로 리스트) */
  .skillOptions {
    position: relative;
    z-index: 2;
  }
  
  /* 개별 옵션 박스 */
  .skillOption {
    display: flex;
    background: #332211;
    border: 2px solid #886633;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s;
  }
  .skillOption:hover {
    background: #443322;
  }
  
  /* 왼쪽 아이콘 */
  .skillIcon img {
    width: 48px;
    height: 48px;
  }
  
  /* 오른쪽 이름 + 설명 */
  .skillInfo {
    margin-left: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .skillName {
    font-size: 13px;
    font-weight: bold;
    font-family: sans-serif; /* 기본 폰트 */
    color: #ffe680;
    margin: 0;
    line-height: 1.2;
  }
  
  .skillDesc {
    font-size: 11px;
    font-family: sans-serif; /* 기본 폰트 */
    color: #cccccc;
    margin: 0;
    line-height: 1.2;
    word-break: break-word;
    white-space: normal;
  }
  #rankPopup,#adPopup,#startMenu,#gameOverMenu{ position:absolute; top:0; left:0; width:100%; height:100%; display:flex; justify-content:center; align-items:center; pointer-events:auto; z-index:3; }
  .hidden{ display:none!important; }
  .popupContent {
    background: transparent;     /* ✅ 흰 배경 제거 */
    border: none;                /* ✅ 테두리 제거 */
    padding: 0;                  /* ✅ 여백 제거 */
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  #skillChoices{ display:flex; flex-direction:column; gap:10px; }
  #skillChoices button, .popupContent button{ width:150px; padding:8px 12px; font-size:14px; cursor:pointer; align-self:center; }
  #rankList{ list-style:none; text-align:left; max-height:200px; overflow-y:auto; }
  #startMenu .popupContent.titleScreen {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0;
    display: block;
  }
  
  /* ➋ 타이틀 이미지는 화면 전체에 꽉 채우기 */
  #startMenu .popupContent.titleScreen #titleImage {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;   /* 이미지 비율 유지하며 전체 채우기 */
    user-select: none;
    pointer-events: none; /* 클릭 통과 */
  }
  
  /* ➌ 버튼 컨테이너: 하단 중앙, 수직 배열 */
  #startMenu .startButtons {
    position: absolute;
    bottom: 60px;        /* 화면 하단에서 50px 띄움 */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;           /* 버튼 사이 간격 */
    pointer-events: auto;/* 버튼 클릭 가능 */
  }
  
  /* ➍ 버튼 이미지 크기 */
  #startMenu .startButtons img {
    width: 150px;        /* 필요에 따라 조절 */
    height: auto;
    cursor: pointer;
    user-select: none;
  }
/* 팝업 전체: 브라우저 중앙 정렬 */
#skillPopup {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    
  }
  #skillPopup:not(.hidden) {
    display: flex;
  }
  
/* ✅ 프레임 컨테이너: 크기 확실히 키움 */
.skillPopupContent {
    position: relative;
    width: 95%;
    max-width: 640px;           /* ✅ ✅ ✅ 크기 키움 */
    aspect-ratio: 5 / 4;        /* 안정적인 가로세로 비율 */
    padding: 40px 32px 32px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
  }
/* 프레임 배경 */
.skillPopupBg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    z-index: 0;
  }
  /* 커스텀 이미지 영역 */
  .skillImage {
    position: relative;
    z-index: 1;
    width: 100%;
    text-align: center;
    margin-bottom: 16px;
  }
/* 타이틀 이미지 */
.skillTitleImg {
    width: 220px;                 /* 제목 이미지도 크기 맞춰서 약간 키움 */
    margin-top: 16px;
    z-index: 2;
    image-rendering: pixelated;
  }
  
  
  /* 타이틀 */
  .skillHeader {
    display: none;
  }
  
  /* 옵션 리스트 */
/* 스킬 옵션 */
.skillOptions {
    width: 92%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: -20px;
    z-index: 2;
    max-height: 280px;           /* ✅ 리스트가 더 많이 보여짐 */
    overflow-y: auto;
  }/* 각 스킬 옵션 박스 */
  .skillOption {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: #3a2b1d;
    border: 2px solid #aa823e;
    border-radius: 6px;
    padding: 6px 10px;
    width: 65%;               /* ✅ 전체의 92%로 줄이기 */
    max-width: 440px;         /* ✅ 큰 화면일 경우 대비 */
    min-height: 48px;
    margin-left: 85px;
    margin-bottom:5px ;
    box-sizing: border-box;
  }
  /* 모든 이미지 버튼에 공통 적용 */
  
img.button-img {
    transition: transform 0.2s ease, filter 0.2s ease;
    cursor: pointer;
    user-select: none;
  }
.skillIcon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
  }
.skillIcon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
  }
/* 텍스트 묶음 */
.skillInfo {
    margin-left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;         /* ✅ 텍스트 수직 정렬 */
    line-height: 1.2;
    width: 100%;
    overflow: hidden;
  }
/* 스킬 이름 */
.skillName {
    font-size: 13px;
    font-weight: bold;
    color: #ffe680;
    margin: 0;
    line-height: 1.2;
  }
/* 스킬 설명 */
.skillDesc {
    font-size: 11px;
    color: #cccccc;
    margin: 0;
    line-height: 1.2;
    word-break: break-word;
    white-space: normal;
  }
  /* hover 시: 확대 */
  img.button-img:hover {
    transform: scale(1.07);
    filter: brightness(1.2);
  }
  
  /* 클릭 시: 눌림 효과 */
  img.button-img:active {
    transform: scale(0.95);
    filter: brightness(0.9);
  }
  #gameOverMenu .popupContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6); /* 어두운 배경 */
    border-radius: 12px;
    max-width: 300px;
  }
  #gameOverMenu .popupContent img.button-img {
    width: 150px;
    height: auto;
    object-fit: contain;
    user-select: none;
    transition: transform 0.2s ease, filter 0.2s ease;
  }
/* 전체 팝업 */
/* 전체 랭킹 팝업 */
#rankPopup {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
  }
  #rankPopup:not(.hidden) {
    display: flex;
  }
  
  /* 프레임 컨테이너 */
  .rankPopupContent {
    position: relative;
    width: 90%;
    max-width: 360px;
    aspect-ratio: 4 / 3;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 32px 20px 20px;
    box-sizing: border-box;
  }
  
  /* 프레임 배경 이미지 */
  .popupBg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    z-index: 0;
  }
  
  /* 타이틀 이미지 */
  .rankTitle {
    width: 160px;
    margin-top: 120px;      /* ✅ 아래로 더 내리기 */
    margin-bottom: 16px;
    z-index: 2;
  }
  
/* 랭킹 리스트 */
.rankListWrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 2;
    margin-top: 10px;        /* ✅ 이미지와 리스트 사이 간격 */
    margin-bottom: 8px;
  }
  .rankList {
    width: 88%;
    max-height: 120px;
    overflow-y: auto;
    font-size: 14px;
    color: #fff;
    list-style: none;
    padding: 0;
    margin: 0;
    line-height: 1.4;
  }
  
/* Close 버튼 */
.closeBtn {
    width: 80px;
    height: auto;
    cursor: pointer;
    z-index: 2;
    margin-top: 16px;       /* ✅ 리스트 아래 간격 */
    margin-bottom: 12px;    /* ✅ 프레임 하단에서 띄우기 */
    transition: transform 0.2s ease;
  }
.closeBtn:hover {
    transform: scale(1.05);
  }
.skillTitleImg {
    width: 180px;              /* ✅ 원하는 크기로 조정 */
    margin-top: 24px;          /* ✅ 프레임 위에서 약간 띄우기 */
    margin-bottom: 12px;       /* ✅ 아래 리스트와 간격 */
    z-index: 2;
    image-rendering: pixelated;
    object-fit: contain;
  }
  @keyframes firework-blink {
    0%,100% { opacity: 0; }
    50%     { opacity: 1; }
  }
  /* 폭죽 이미지 스타일 */
.firework {
  position: absolute;   /* 절대 위치 */
  pointer-events: none;
  z-index: 1;           /* 옵션 위에 나오려면 2 이상으로 조절하세요 */
  animation: firework-blink 1s infinite ease-in-out;
}
#volumeControls {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.7);
  padding: 20px;
  border-radius: 10px;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  display: flex;
  visibility: hidden;
  z-index: 5; /* 🔥 추가: 반드시 다른 HUD 위로 올라오게 함 */
}
#volumeControls.hidden {
  visibility: hidden;
}
#volumeControls:not(.hidden) {
  visibility: visible;
}
#volumeControls label {
  color: #fff;
  font-family: 'Press Start 2P', cursive;
  font-size: 14px;
}
#volumeControls input[type="range"] {
  width: 200px;
}
.skillLevelBadge {
  position: absolute;
  bottom: 0;
  right: 0;
  background: black;
  color: white;
  font-size: 10px;
  padding: 1px 3px;
  border-radius: 4px;
}
#killCounter {
  position: absolute;
  top: 90px;        /* 일시정지 버튼(40px) + 추가 여유 */
  right: 10px;      /* 오른쪽 정렬 */
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Press Start 2P', cursive;
  font-size: 16px;
  color: white;
  z-index: 2;
}
#killCounter img {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

#nameInputPopup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  color: white;
  z-index: 9999;
}
#nameInputPopup input {
  width: 80%;                   /* 입력창 너비 조절 */
  max-width: 250px;             /* 최대 너비 제한 */
  margin: 10px auto;            /* 위아래 10px, 좌우 자동 마진(가로 중앙) */
  display: block;               /* margin:auto 가로 중앙 적용을 위해 block */
  text-align: center;           /* 입력된 텍스트도 가운데 정렬 */
}
#nameInputPopup button {
  margin: 5px;
  padding: 5px 10px;
  font-size: 14px;
}
.hidden {
  display: none;
}

#joystickWrapper {
  position: absolute;
  bottom: 30px;
  left: 30px;
  width: 150px;
  height: 150px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: none; /* 처음엔 숨김 */
  justify-content: center;
  align-items: center;
}

#joystickButton {
  width: 60px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  position: absolute;
}