@import url("https://fonts.googleapis.com/css2?family=Jua&display=swap");

body {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #000;
  font-family: "Jua", sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
  color: #e0e0e0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

canvas {
  background-color: #0c1428;
  cursor: none;
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 상단 통합 정보 패널 */
#top-info-panel {
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  height: 65px;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.8),
    rgba(12, 20, 40, 0.9)
  );
  border-radius: 15px;
  border: 2px solid rgba(0, 240, 255, 0.3);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 15;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* 좌측 플레이어 정보 */
#left-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  color: #00f0ff;
  text-shadow: 0 0 5px #00f0ff;
}

#left-info .info-label {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 2px;
}

#left-info .info-value {
  font-size: 18px;
  font-weight: bold;
}

/* 가운데 게임 제목 */
#center-title {
  text-align: center;
  color: #00f0ff;
  text-shadow: 0 0 10px #00f0ff;
  font-size: 20px;
  font-weight: bold;
  opacity: 0.9;
}

/* 우측 부스트 및 컨트롤 */
#right-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
}

/* 부스트 게이지 컨테이너 */
#boost-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#boost-info .info-label {
  font-size: 11px;
  color: #00f0ff;
  opacity: 0.8;
  margin-bottom: 3px;
}

/* 오디오 컨트롤을 부스트 우측에 배치 */
#audio-controls {
  display: flex;
  gap: 4px;
  flex-direction: row;
}

#audio-controls button {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

#audio-controls button:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: scale(1.1);
}

#audio-controls button:active {
  transform: scale(0.95);
}

#audio-controls button.disabled {
  opacity: 0.5;
  background: rgba(128, 128, 128, 0.8);
}

/* 기존 컨테이너들 숨김 */
#ui-container,
#boost-container {
  display: none;
}

#boost-gauge {
  width: 120px;
  height: 16px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #00f0ff;
}

#boost-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b, #ffd93d, #6bcf7f);
  border-radius: 6px;
  transition: width 0.1s ease;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

#game-over-screen,
#pause-screen {
  position: absolute;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  color: white;
  text-align: center;
  z-index: 20;
}

#game-over-screen h1 {
  font-size: 72px;
  color: #ff4757;
  text-shadow: 0 0 15px #ff4757;
  margin: 0;
}

#game-over-screen p {
  font-size: 28px;
  margin: 20px 0;
}

#restart-button {
  padding: 15px 30px;
  font-size: 24px;
  font-family: "Jua", sans-serif;
  color: #1a1a2e;
  background: linear-gradient(45deg, #00f0ff, #575fcf);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
  /* iOS 터치 이벤트 개선 */
  -webkit-tap-highlight-color: rgba(0, 240, 255, 0.3);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#restart-button:hover {
  transform: scale(1.1);
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.8);
}

#start-screen {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  min-height: 100vh;
  background: linear-gradient(135deg, #0c1428, #1a2332);
  color: white;
  text-align: center;
  z-index: 30;
  padding: 40px 20px;
  box-sizing: border-box;
  overflow-y: auto;
  padding-top: max(40px, 5vh);
  padding-bottom: max(40px, 5vh);
}

#game-title {
  font-size: clamp(32px, 8vw, 48px);
  font-weight: bold;
  color: #00f0ff;
  text-shadow: 0 0 20px #00f0ff;
  margin-bottom: 20px;
  margin-top: 20px;
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    text-shadow: 0 0 20px #00f0ff, 0 0 30px #00f0ff;
  }
  to {
    text-shadow: 0 0 30px #00f0ff, 0 0 40px #00f0ff;
  }
}

#game-description {
  font-size: clamp(14px, 4vw, 18px);
  margin-bottom: 30px;
  max-width: 700px;
  line-height: 1.5;
  color: #e0e0e0;
}

#controls-info {
  background: rgba(255, 255, 255, 0.1);
  padding: 20px clamp(20px, 5vw, 40px);
  border-radius: 12px;
  margin-bottom: 30px;
  margin-top: 0px;
  max-width: 500px;
  width: 90%;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

#controls-info h3 {
  color: #00f0ff;
  font-size: 22px;
  margin-bottom: 15px;
}

.control-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-right: 10px;
  margin-left: 10px;
  margin-top: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}

.control-key {
  background: #00f0ff;
  color: #1a1a2e;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: bold;
  min-width: 100px;
  font-size: 14px;
}

/* 적 크기 가이드 스타일 */
#enemy-guide {
  margin-top: 20px;
}

#enemy-guide h3 {
  color: #00f0ff;
  margin-bottom: 15px;
  font-size: 18px;
}

.enemy-color-guide {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.color-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  font-size: 14px;
}

.color-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: bold;
  font-size: 12px;
  border: 2px solid black;
}

.color-indicator.green {
  background-color: rgba(34, 197, 94, 0.3);
  color: #22c55e;
}

.color-indicator.red {
  background-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.color-indicator.yellow {
  background-color: rgba(245, 158, 11, 0.3);
  color: #f59e0b;
}

#start-button {
  padding: 15px 35px;
  font-size: clamp(18px, 5vw, 22px);
  font-family: "Jua", sans-serif;
  color: #1a1a2e;
  background: linear-gradient(45deg, #00f0ff, #575fcf);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 25px rgba(0, 255, 255, 0.5);
  font-weight: bold;
  margin-top: 20px;
  margin-bottom: 20px;
  /* iOS 터치 이벤트 개선 */
  -webkit-tap-highlight-color: rgba(0, 240, 255, 0.3);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#start-button:hover {
  transform: scale(1.1);
  box-shadow: 0 0 40px rgba(0, 255, 255, 0.8);
}

.emoji {
  font-size: 24px;
  margin: 0 10px;
}

#mobile-boost-button {
  display: none;
  position: absolute;
  bottom: 30px;
  right: 30px;
  width: 80px;
  height: 80px;
  background: linear-gradient(45deg, #ff6b6b, #ffd93d);
  border: 3px solid #fff;
  border-radius: 50%;
  z-index: 15;
  touch-action: none;
  user-select: none;
  cursor: pointer;
  transition: all 0.1s ease;
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
}

#mobile-boost-button:active {
  transform: scale(0.9);
  box-shadow: 0 0 30px rgba(255, 107, 107, 0.8);
}

#mobile-boost-button.active {
  background: linear-gradient(45deg, #ff4757, #ffa502);
  transform: scale(1.1);
  box-shadow: 0 0 30px rgba(255, 71, 87, 0.8);
}

#mobile-boost-button .boost-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

#loading-screen {
  position: absolute;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background-color: #0c1428;
  z-index: 40;
}

#loading-text {
  color: white;
  font-size: 30px;
  text-align: center;
}

/* 기존 오디오 컨트롤 스타일 숨김 (상단 패널로 이동) */
#audioControls {
  display: none;
}

@media (max-width: 768px) {
  #mobile-boost-button {
    display: block;
  }

  #start-screen ~ #mobile-boost-button,
  #game-over-screen[style*="flex"] ~ #mobile-boost-button {
    display: none;
  }

  #start-screen {
    padding: 20px 15px;
    padding-top: max(20px, 3vh);
    padding-bottom: max(20px, 3vh);
  }

  #controls-info {
    width: 95%;
    padding: 15px 20px;
  }

  .control-item {
    font-size: 12px;
    margin: 8px 5px;
  }

  .control-key {
    font-size: 12px;
    padding: 4px 8px;
    min-width: 80px;
  }

  /* 모바일에서 상단 패널 조정 */
  #top-info-panel {
    left: 10px;
    right: 10px;
    top: 10px;
    height: 55px;
    padding: 0 15px;
  }

  #center-title {
    font-size: 16px;
  }

  #left-info .info-value {
    font-size: 16px;
  }

  #right-info {
    gap: 10px;
  }

  #boost-gauge {
    width: 80px;
    height: 12px;
  }

  #audio-controls {
    gap: 3px;
  }

  #audio-controls button {
    width: 20px;
    height: 20px;
    font-size: 8px;
  }

  #boost-info .info-label {
    font-size: 9px;
  }
}
