* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  font-family: "Arial", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: white;
  padding: 3px;
  overflow-x: hidden;
  overflow-y: auto;
}

.game-container {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
  border: 2px solid rgba(255, 255, 255, 0.2);
  width: 100vw;
  min-height: 500px;
  max-height: none;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  margin: 5px 0;
}

/* 상단 헤더 */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  margin-bottom: 4px;
  height: 35px;
  flex-shrink: 0;
}

.game-title {
  font-size: 14px;
  font-weight: bold;
  color: #feca57;
  flex-shrink: 0;
}

.round-info {
  flex: 1;
  text-align: center;
  padding: 0 10px;
}

.round-text {
  font-size: 12px;
  font-weight: bold;
  color: #48dbfb;
  margin-bottom: 1px;
}

.enemies-status {
  font-size: 10px;
  color: #feca57;
}

.score-display {
  font-size: 12px;
  font-weight: bold;
  color: #feca57;
  flex-shrink: 0;
}

/* 메인 게임 영역 */
.game-main {
  display: flex;
  gap: 6px;
  flex: 1;
  min-height: 450px;
}

/* 왼쪽 사이드바 */
.left-sidebar {
  width: 65px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px;
}

.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 4px;
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  font-size: 10px;
  font-weight: bold;
  text-align: center;
}

.health {
  color: #ff6b6b;
}
.gold {
  color: #feca57;
}
.score {
  color: #54a0ff;
}

.tower-controls {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.tower-btn {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 6px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  touch-action: manipulation;
  position: relative;
}

.tower-icon {
  font-size: 16px;
  line-height: 1;
}

.tower-cost {
  font-size: 8px;
  opacity: 0.9;
  line-height: 1;
}

.basic-tower {
  background: linear-gradient(45deg, #ff6b6b, #ee5a52);
}
.cannon-tower {
  background: linear-gradient(45deg, #ff9f43, #ee8c2e);
}
.laser-tower {
  background: linear-gradient(45deg, #0abde3, #006ba6);
}
.ice-tower {
  background: linear-gradient(45deg, #74b9ff, #0984e3);
}
.poison-tower {
  background: linear-gradient(45deg, #00b894, #00a085);
}

.tower-btn:hover,
.tower-btn:active {
  transform: scale(0.95);
}

.tower-btn:disabled {
  background: #666 !important;
  cursor: not-allowed;
  transform: none;
  opacity: 0.5;
}

.tower-btn.selected {
  border: 2px solid #feca57;
  box-shadow: 0 0 15px rgba(254, 202, 87, 0.5);
}

.start-wave-btn {
  width: 100%;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(45deg, #48dbfb, #0abde3);
  color: white;
  font-weight: bold;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
  margin-top: auto;
  flex-shrink: 0;
}

.start-wave-btn:hover,
.start-wave-btn:active {
  transform: scale(0.95);
}

/* 캔버스 영역 */
.canvas-container {
  flex: 1;
  position: relative;
  background: #2c3e50;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 350px;
}

#gameCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  touch-action: manipulation;
}

.progress-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 10;
}

.progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #48dbfb, #0abde3);
  width: 0%;
  transition: width 0.3s ease;
}

/* 오른쪽 사이드바 */
.right-sidebar {
  width: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
}

.tower-info-content {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.right-sidebar h3 {
  color: #feca57;
  margin-bottom: 6px;
  text-align: center;
  font-size: 12px;
}

.tower-stat {
  display: flex;
  justify-content: space-between;
  margin: 3px 0;
  color: white;
  font-size: 10px;
}

.action-btn {
  width: 100%;
  margin-top: 4px;
  padding: 6px;
  border: none;
  border-radius: 4px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
  font-size: 9px;
}

.upgrade-btn {
  background: linear-gradient(45deg, #48dbfb, #0abde3);
  margin-top: auto;
}

.sell-btn {
  background: linear-gradient(45deg, #e74c3c, #c0392b);
  margin-top: 4px;
}

.action-btn:hover,
.action-btn:active {
  transform: scale(0.95);
}

.action-btn:disabled {
  background: #666 !important;
  cursor: not-allowed;
  transform: none;
  opacity: 0.5;
}

/* 게임 오버 화면 */
.game-over {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.95);
  padding: 30px;
  border-radius: 15px;
  text-align: center;
  display: none;
  backdrop-filter: blur(15px);
  border: 2px solid #ff6b6b;
  min-width: 300px;
  z-index: 2000;
}

.restart-btn {
  margin-top: 10px;
  padding: 12px 25px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(45deg, #48dbfb, #0abde3);
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  touch-action: manipulation;
}

.restart-btn:hover {
  transform: translateY(-2px);
}

.bbbutton{
  padding: 0.75rem 1.5rem 0.75rem 1.5rem;
  background-color: rgb(59 130 246 / var(--tw-bg-opacity, 1));
  border-radius: 0.5rem;
  Color: #ffffff;
  font-weight: 500;
  text-decoration: none;
  margin-top: 30px;
}

/* 타워 정보 숨김 상태 */
.right-sidebar:not(.show) .tower-stat,
.right-sidebar:not(.show) .action-btn {
  opacity: 0.3;
}

.right-sidebar.show {
  border: 2px solid #feca57;
  background: rgba(254, 202, 87, 0.1);
}

/* 반응형 조정 - 매우 작은 가로 화면 */
@media (max-width: 700px) {
  .left-sidebar {
    width: 55px;
  }

  .right-sidebar {
    width: 85px;
  }

  .tower-btn {
    height: 35px;
  }

  .tower-icon {
    font-size: 14px;
  }

  .tower-cost {
    font-size: 7px;
  }

  .stat-item {
    font-size: 9px;
    padding: 3px 1px;
  }

  .start-wave-btn {
    height: 28px;
    font-size: 9px;
  }
}

/* 세로 방향일 때는 경고 메시지 */
@media (orientation: portrait) {
  body::before {
    content: "📱 가로 모드로 회전해주세요";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px;
    border-radius: 10px;
    font-size: 18px;
    z-index: 10000;
    text-align: center;
  }

  .game-container {
    opacity: 0.3;
    pointer-events: none;
  }
}

/* 작은 높이 화면 대응 */
@media (max-height: 500px) {
  body {
    align-items: flex-start;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .game-container {
    margin: 10px 0;
    min-height: auto;
  }

  .game-main {
    min-height: 350px;
  }

  .canvas-container {
    min-height: 280px;
  }
}
