/* ============================================
   CSS 변수 정의
   ============================================ */
:root {
  /* 색상 */
  --color-primary: #f1c40f;
  --color-primary-dark: #e67e22;
  --color-success: #73bf2e;
  --color-success-dark: #558022;
  --color-warning: #e1b801;
  --color-warning-dark: rgb(180, 126, 0);
  --color-info: #3498db;
  --color-info-dark: #2980b9;
  --color-danger: #e74c3c;
  --color-danger-dark: #c0392b;
  --color-danger-darker: #922b21;
  --color-skill: #ff4757;
  --color-text-light: #ecf0f1;
  --color-text-gray: #ccc;
  --color-text-dark: #888;
  --color-bg-dark: rgba(44, 62, 80, 0.95);
  --color-bg-black: #000;
  --color-bg-transparent: rgba(0, 0, 0, 0.8);
  --color-canvas-bg: #ade1e5;
  --color-pipe: #73bf2e;
  --color-building-1: #95c6cc;
  --color-building-2: #a5d6dc;

  /* 크기 */
  --footer-height: 40px;
  --footer-height-mobile: 30px;
  --gauge-width: 120px;
  --gauge-height: 25px;
  --ult-button-size: 65px;

  /* 간격 */
  --spacing-xs: 5px;
  --spacing-sm: 10px;
  --spacing-md: 15px;
  --spacing-lg: 20px;
  --spacing-xl: 30px;

  /* 폰트 */
  --font-primary: "Mogra", sans-serif;
  --font-monospace: "Courier New", Courier, monospace;
  --font-sans: sans-serif;

  /* 테두리 */
  --border-radius: 10px;
  --border-radius-sm: 6px;
  --border-radius-lg: 20px;

  /* 애니메이션 */
  --transition-fast: 0.2s;
  --transition-medium: 0.3s;
}

/* ============================================
   기본 스타일
   ============================================ */
body {
  margin: 0;
  overflow: hidden;
  background: var(--color-bg-black);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  font-family: var(--font-primary);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 4px solid #333;
  background: var(--color-canvas-bg);
  display: block;
  touch-action: none;

  /* 비정수 CSS 스케일 시 nearest-neighbor(pixelated)는 픽셀을 불규칙하게 건너뛰어 흔들림 유발
     브라우저 기본 bilinear 보간으로 서브픽셀 정렬 문제 해소 */
  image-rendering: auto;

  /* GPU 합성 레이어 승격 */
  will-change: contents;
  /* transform: translateZ(0); */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* ============================================
   레이아웃
   ============================================ */
#game-container {
  position: relative;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

/* ============================================
   UI 공통 스타일
   ============================================ */
.full-ui-transparent {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.full-ui-black {
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--color-bg-black);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.hidden {
  display: none !important;
}

/* ============================================
   게임 통계
   ============================================ */
#stats {
  position: absolute;
  top: 40px;
  left: var(--spacing-lg);
  color: white;
  text-shadow: 1px 1px 2px var(--color-bg-black);

  z-index: 10;
  font-size: 20px;
  font-weight: bold;
  line-height: 1.4;
}

#difficulty-display {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--color-primary);
  text-shadow: 2px 2px var(--color-bg-black);
  margin-bottom: var(--spacing-lg);
  z-index: 10;
  font-size: 24px;
  font-weight: bold;
  font-family: var(--font-primary);
  letter-spacing: 2px;
  display: none;
}

#difficulty-display.nightmare {
  color: #c040ff;
  text-shadow: 0 0 8px rgba(192, 64, 255, 0.6);
}

/* ============================================
   게이지 시스템
   ============================================ */
#gauge-container {
  position: absolute;
  top: 70px;
  right: var(--spacing-lg);
  width: var(--gauge-width);
  height: var(--gauge-height);
  border: 2px solid #333;
  background: #555;
  border-radius: var(--spacing-xs);
  overflow: hidden;
}

#gauge-bar {
  width: 0%;
  height: 100%;
  background: var(--color-primary);
  transition:
    width var(--transition-fast),
    background-color var(--transition-medium);
  will-change: transform, opacity;
}

#gauge-bar.full {
  background: var(--color-skill) !important;
}

#gauge-text {
  position: absolute;
  width: 100%;
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  color: white;
  font-size: 14px;
  text-shadow: 1px 1px 1px var(--color-bg-black);
}

/* ============================================
   스킬 버튼
   ============================================ */
#ult-button {
  position: absolute;
  bottom: 80px;
  left: var(--spacing-xl);
  width: var(--ult-button-size);
  height: var(--ult-button-size);
  background: var(--color-danger);
  border: 4px solid var(--color-danger-dark);
  border-radius: 50%;
  color: white;
  font-weight: bold;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 0 var(--color-danger-darker);
  z-index: 20;
  font-size: 26px;
  will-change: transform, opacity;
}

#ult-button.ready {
  background: var(--color-skill);
  animation: blink 0.5s infinite;
  border-color: #fff;
}

/* ============================================
   버튼 스타일
   ============================================ */
.game-btn {
  padding: 16px var(--spacing-xl);
  min-width: 100px;
  font-size: 18px;
  font-weight: bold;
  color: white;
  background: var(--color-success);
  border: none;
  border-radius: var(--border-radius-sm);
  border-bottom: 4px solid var(--color-success-dark);
  cursor: pointer;
  pointer-events: auto;
  margin-top: var(--spacing-md);
}

.game-btn.orange {
  background: var(--color-warning);
  border-bottom: 4px solid var(--color-warning-dark);
}

.game-btn.green {
  background: var(--color-success);
  border-bottom: 4px solid var(--color-success-dark);
}

.game-btn.share {
  background: var(--color-info) !important;
  border-bottom: 4px solid var(--color-info-dark) !important;
}

.game-btn.blue {
  background: var(--color-info);
  border-bottom: 4px solid var(--color-info-dark);
}

.game-btn img {
  width: var(--spacing-xl);
  object-fit: contain;
  vertical-align: middle;
}

.game-btn.purple {
  background: #9b59b6;
  border-bottom: 4px solid #7d3c98;
}

/* ============================================
   닉네임 모달
   ============================================ */
#nickname-input {
  display: block;
  width: 80%;
  margin: var(--spacing-md) auto;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--color-primary);
  border-radius: var(--border-radius);
  outline: none;
  letter-spacing: 2px;
}

#nickname-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

#nickname-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(241, 196, 15, 0.4);
}

.nickname-buttons {
  display: flex;
  justify-content: center;
  gap: var(--spacing-md);
  margin-top: var(--spacing-md);
}

/* ============================================
   랭킹 화면
   ============================================ */
#ranking-screen {
  z-index: 500;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  touch-action: auto !important;
}

.ranking-title {
  margin-bottom: var(--spacing-sm) !important;
}

.ranking-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: var(--spacing-md);
  flex-shrink: 0;
}

.ranking-tab {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.5);
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius);
  cursor: pointer;
}

.ranking-tab.active {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: rgba(241, 196, 15, 0.1);
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ranking-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius);
  font-size: 14px;
  color: white;
}

.ranking-item.my-score {
  background: rgba(241, 196, 15, 0.15);
  border: 1px solid var(--color-primary);
}

.ranking-rank {
  width: 32px;
  font-weight: bold;
  text-align: center;
  flex-shrink: 0;
}

.ranking-animal {
  width: 28px;
  text-align: center;
  font-size: 18px;
  flex-shrink: 0;
}

.ranking-animal img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: middle;
}

.ranking-name {
  flex: 1;
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-score {
  font-weight: bold;
  color: var(--color-primary);
  margin-left: 8px;
  flex-shrink: 0;
}

.ranking-empty,
.ranking-loading {
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  padding: var(--spacing-xl) 0;
  font-size: 14px;
}

/* ============================================
   캐릭터 선택
   ============================================ */
#char-select {
  pointer-events: auto;
  text-align: center;
  color: white;
  background: rgba(0, 0, 0, 1);
  padding: var(--spacing-md);
  border: 4px solid #fff;
  border-radius: var(--border-radius);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 500px;
  box-sizing: border-box;
}

.select-title {
  margin: 0;
  padding: 0;
  width: 100%;
  text-align: center;
  color: var(--color-primary);
  font-size: 24px;
  text-shadow: 2px 2px 0 var(--color-bg-black);
  letter-spacing: 2px;
}

#char-name {
  margin: var(--spacing-lg) 0 0 0;
  font-family: var(--font-monospace);
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 1px;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 70px);
  grid-template-rows: repeat(2, 70px);
  gap: var(--spacing-md);
  flex-basis: 160px;
  flex-shrink: 0;
  margin-bottom: var(--spacing-lg);
  width: 245px;
  height: 160px;
}

.char-item {
  width: 70px;
  height: 70px;
  font-size: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border: 3px solid transparent;
  background: rgba(255, 255, 255, 0.12);
  box-sizing: border-box;
}

.char-item img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

/* Character size normalization — source images vary in size */
[data-animal="penguin"] img {
  scale: 1.1;
}
[data-animal="bird"] img {
  scale: 1.1;
}
[data-animal="bee"] img {
  scale: 1.2;
}
[data-animal="rabbit"] img {
  scale: 1.2;
}
[data-animal="horse"] img {
  scale: 1.3;
}

.char-item.selected {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.05);
}

/* ============================================
   스킬 미리보기
   ============================================ */
.selection-layout {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xl);
  width: 100%;
  max-width: 400px;
  min-height: 260px;
}

#ult-preview-box {
  position: relative;
  width: 140px;
  height: 130px;
  font-size: 35px;
  /* margin: 0 auto var(--spacing-sm) auto; */
  display: flex;
  justify-content: center;
  align-items: center;
}

#ult-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: #222;
  border-radius: 12px;
}

#ult-visual video,
#ult-preview-box video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
}

#ult-details {
  font-family: var(--font-monospace);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-height: 50px;
  width: 100%;
  padding: var(--spacing-sm);
  box-sizing: border-box;
}

#skill-summary {
  display: block;
  font-size: 14px;
  font-weight: bold;
  color: #ff4500;
}

/* ============================================
   인트로 화면
   ============================================ */
.intro-animate {
  animation: spawn-grow 0.6s cubic-bezier(0.17, 0.67, 0.83, 0.67) forwards;
}

.game-title {
  font-size: 72px;
  color: var(--color-primary);
  text-shadow: 4px 4px 0px var(--color-primary-dark);
  margin-bottom: var(--spacing-lg);
}

.intro-chars-container {
  display: flex;
  gap: var(--spacing-md);
  margin: var(--spacing-xl) 0;
  justify-content: center;
}

.intro-char {
  font-size: 40px;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
  animation: float 2s infinite ease-in-out;
}

.intro-char img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.intro-char:nth-child(2) {
  animation-delay: 0.2s;
}

.intro-char:nth-child(3) {
  animation-delay: 0.4s;
}

.intro-char:nth-child(4) {
  animation-delay: 0.6s;
}

.intro-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
}

.intro-content .game-btn {
  width: 200px;
  margin: 0;
  padding: 12px var(--spacing-xl);
}

/* ============================================
   모달
   ============================================ */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-bg-transparent);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal-content {
  background: black;
  color: white;
  padding: var(--spacing-xl);
  border: 2px solid white;
  text-align: center;
  border-radius: var(--border-radius);
}

.tutorial-item {
  margin: var(--spacing-md) 0;
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-xl);
}

.tutorial-item .key {
  color: var(--color-primary);
  font-family: var(--font-monospace);
  font-weight: bold;
  background: #333;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 4px;
  border: 1px solid #555;
}

.tutorial-item .desc {
  font-weight: bold;
  padding: var(--spacing-xs) var(--spacing-sm);
}

/* ============================================
   가이드 화면
   ============================================ */
#game-guide-screen {
  z-index: 500;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  touch-action: auto !important;
}

.guide-container {
  background: var(--color-bg-dark);
  border: 4px solid #fff;
  border-radius: var(--border-radius-lg);
  width: 90%;
  max-width: 360px;
  height: 65vh;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-lg);
  box-sizing: border-box;
}

.guide-title {
  color: var(--color-primary);
  text-align: center;
  margin-top: 0;
  font-size: 28px;
  text-shadow: 2px 2px var(--color-bg-black);
}

.guide-scroll-area {
  flex: 1;
  overflow-y: auto !important;
  margin-bottom: var(--spacing-lg);
  padding-right: var(--spacing-sm);
  text-align: left;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y !important;
}

.guide-scroll-area p,
.guide-item {
  font-family: var(--font-sans);
  font-size: 14px;
}

.guide-scroll-area::-webkit-scrollbar {
  width: 6px;
}

.guide-scroll-area::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: var(--border-radius);
}

.guide-section {
  margin-bottom: 25px;
}

.guide-section h3 {
  border-left: 5px solid var(--color-primary-dark);
  padding-left: var(--spacing-sm);
  color: #f6ee0c;
  margin-bottom: var(--spacing-sm);
}

.guide-section p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-light);
  margin: var(--spacing-xs) 0;
}

.guide-item {
  color: white;
  background: rgba(0, 0, 0, 0.3);
  padding: var(--spacing-sm);
  border-radius: 8px;
  margin-bottom: var(--spacing-sm);
}

.guide-item img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: middle;
}

.control-item strong,
.guide-item strong {
  color: var(--color-info);
}

/* ============================================
   설정 화면 - 커스텀 셀렉트박스
   ============================================ */
.custom-select {
  position: relative;
  width: 100%;
  margin-top: 12px;
  user-select: none;
}

.custom-select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 16px;
  font-weight: bold;
  font-family: var(--font-primary);
  color: white;
}

.custom-select-trigger:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--color-primary);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(241, 196, 15, 0.2);
}

.custom-select-arrow {
  font-size: 12px;
  transition: transform var(--transition-fast);
  color: var(--color-primary);
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #2c3e50;
  border: 2px solid var(--color-primary);
  border-radius: var(--border-radius-sm);
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.custom-select.open .custom-select-options {
  display: block;
}

.custom-select-options li {
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 16px;
  font-weight: bold;
  font-family: var(--font-primary);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.custom-select-options li:last-child {
  border-bottom: none;
}

.custom-select-options li:hover {
  background: rgba(241, 196, 15, 0.2);
  color: var(--color-primary);
}

.custom-select-options li.selected {
  background: rgba(241, 196, 15, 0.15);
  color: var(--color-primary);
}

.custom-select-options::-webkit-scrollbar {
  width: 6px;
}

.custom-select-options::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

#settings-screen {
  z-index: 500;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  touch-action: auto !important;
}

/* ============================================
   프라이버시 & About 화면
   ============================================ */
#privacy-screen,
#about-screen {
  z-index: 2000;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

#privacy-screen .guide-section p {
  font-family: var(--font-sans);
  color: var(--color-text-gray);
  font-size: 13px;
}

/* ============================================
   게임 오버
   ============================================ */
/* 게임오버 버튼 컨테이너 레이아웃 */
.game-over-buttons-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px; /* 메인과 서브 사이 간격 */
  margin-top: 20px;
}

#game-over-screen {
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.game-over-title {
  font-size: 94px;
  color: #fff;
  text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}

.game-over-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 30px;
}

.game-over-score {
  font-size: 32px;
  color: var(--color-primary);
  text-shadow: 2px 2px var(--color-bg-black);
  font-weight: bold;
}

.game-over-buttons {
  display: flex;
  flex-wrap: wrap; /* 영역이 부족하면 다음 줄로 넘김 */
  justify-content: center; /* (선택사항) 줄바꿈 시 버튼들을 가운데 정렬 */
  align-items: center;
  gap: var(--spacing-sm);
}

/* 메인 RETRY 버튼: 강조 */
.retry-btn {
  width: 160px !important; /* 크기 키움 */
  height: 70px !important;
  font-size: 24px !important;
  background-color: var(--color-success) !important; /* 초록색 */
  /* box-shadow: 0 6px 0 var(--color-success-dark) !important; */
}

/* 보조 버튼 그룹: 가로 정렬 */
.sub-actions {
  display: flex;
  justify-content: center;
  gap: 12px; /* 버튼 사이 간격 */
}

.sub-btn {
  width: 60px !important;
  height: 60px !important;
  font-size: 24px !important;
  padding: 0 !important;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 트로피 버튼 전용 보라색 (기존 변수 활용) */
.ranking-theme {
  background-color: #9b59b6 !important;
  /* box-shadow: 0 6px 0 #8e44ad !important; */
  border-bottom: 4px solid #7d3c98;
}

/* ============================================
   푸터
   ============================================ */
#game-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--footer-height);
  background: rgba(0, 0, 0, 0.6);
  color: #aaa;
  font-family: var(--font-sans);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: auto;
}

.footer-content {
  display: flex;
  gap: var(--spacing-lg);
  align-items: center;
}

.footer-links {
  display: flex;
  gap: var(--spacing-lg);
  font-weight: bold;
}

.footer-links a {
  color: #fff;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--color-primary);
}

/* ============================================
   애니메이션
   ============================================ */
@keyframes blink {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}

@keyframes ult-ready-blink {
  0% {
    filter: brightness(1);
    box-shadow: 0 0 5px #fff;
  }
  50% {
    filter: brightness(1.8);
    box-shadow:
      0 0 20px #ff0,
      0 0 40px #ff4500;
  }
  100% {
    filter: brightness(1);
    box-shadow: 0 0 5px #fff;
  }
}

.ult-ready-animation {
  animation: ult-ready-blink 0.6s infinite alternate;
}

@keyframes spawn-grow {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

@keyframes loading-blink {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0.3;
  }
}

/* ============================================
   로딩 화면
   ============================================ */
body.loading-active #intro-screen,
body.loading-active #char-select,
body.loading-active #game-over-screen,
body.loading-active #stats,
body.loading-active #gauge-container,
body.loading-active #ult-button {
  display: none !important;
}

#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-bg-black);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
  font-family: var(--font-sans);
}

.loading-text {
  color: #fff;
  font-family: var(--font-monospace);
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 5px;
  animation: loading-blink 0.5s infinite alternate;
}
/* ============================================
   오디오 컨트롤
   ============================================ */
.audio-control {
  position: absolute;
  top: 35px;
  right: 20px;
  z-index: 100; /* UI보다 위에 위치 */
}

.audio-btn {
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 24px;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease;
}

.audio-btn:active {
  transform: scale(0.9);
}

/* ============================================
   반응형 디자인
   ============================================ */
@media (max-width: 600px) {
  .game-title {
    font-size: 52px;
    letter-spacing: 2px;
    color: var(--color-primary);
    text-shadow: 4px 4px 0px var(--color-primary-dark);
    margin-bottom: var(--spacing-lg);
  }

  #char-select {
    width: 95%;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .selection-layout {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    min-height: 330px;
    margin-top: 12px;
  }

  .char-grid {
    display: grid;
    grid-template-columns: repeat(3, 75px);
    grid-template-rows: repeat(2, 75px);
    gap: var(--spacing-sm);
    flex-basis: 160px;
    flex-shrink: 0;
    margin-bottom: var(--spacing-lg);
    width: 245px;
    height: 160px;
  }

  .char-item {
    width: 75px;
    height: 75px;
    font-size: 35px;
    box-sizing: border-box;
    border: 3px solid transparent;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .char-item img {
    width: 45px;
    height: 45px;
  }

  .char-item.selected {
    border-color: var(--color-primary);
    background: rgba(241, 196, 15, 0.2);
    transform: none;
  }

  #ult-preview-box {
    width: 120px;
    height: 100px;
    font-size: 35px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  #ult-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #222;
    border-radius: 12px;
  }

  #ult-details {
    font-family: var(--font-monospace);
    text-align: center;
    width: 100%;
  }

  .game-over-title {
    font-size: 64px;
    color: #fff;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
  }

  #game-footer {
    height: var(--footer-height-mobile);
    font-size: 10px;
  }

  .copyright {
    display: none;
  }
}

