:root {
  --primary-orange: #f97316;
  --secondary-sky: #0ea5e9;
  --danger-red: #ef4444;
  --success-green: #22c55e;
  --accent-yellow: #facc15;
  --bg-dark: #0f172a;
  --bg-darker: #020617;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-darker);
  color: white;
  user-select: none;
  -webkit-user-select: none;
}

.app-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease-in-out;
}

.view.hidden {
  display: none;
  pointer-events: none;
  opacity: 0;
}

/* Home View Styles */
#home-view {
  background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
}

.home-content {
  text-align: center;
  max-width: 500px;
  width: 90%;
  padding: 2rem;
}

.game-title {
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(to bottom right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  letter-spacing: -0.05em;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
  .game-title {
    font-size: 2.2rem;
    letter-spacing: -0.03em;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 1.9rem;
  }
}

.game-subtitle {
  color: #94a3b8;
  margin-bottom: 2.5rem;
}

.leaderboard-section {
  background: rgba(255, 255, 255, 0.05);
  border: 1px border rgba(255, 255, 255, 0.1);
  border-radius: 1.5rem;
  padding: 1.5rem;
  margin-bottom: 0.5rem;
  text-align: left;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-yellow);
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.5rem;
}

.leaderboard-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

.primary-btn {
  background: white;
  color: black;
  font-size: 1.25rem;
  font-weight: 900;
  padding: 1rem 3rem;
  border-radius: 1rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.primary-btn:hover {
  background: var(--secondary-sky);
  color: white;
  transform: translateY(-2px);
}

/* Game View Styles */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.game-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  pointer-events: none;
}

.ui-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.ui-box {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 1rem;
  padding: 0.75rem 1.25rem;
  min-width: 140px;
}

.label {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

.score-box .label { color: var(--secondary-sky); }
.round-box .label { color: #f472b6; text-align: right; }

.value {
  display: block;
  font-size: 1rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.round-box .value { text-align: right; font-size: 1rem; }

.hp-bar-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  padding: 0.35rem 0.5rem;
  width: 200px;
}

.hp-label {
  font-size: 0.65rem;
  font-weight: 900;
  color: var(--danger-red);
  padding-left: 0.5rem;
}

.hp-track {
  flex: 1;
  height: 0.75rem;
  background: #1e293b;
  border-radius: 9999px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(to right, #dc2626, #f87171);
  transition: width 0.3s ease-out;
}

.progress-bar-track {
  width: 100%;
  max-width: 400px;
  margin: 1rem auto 0;
  height: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #22d3ee, #3b82f6);
  transition: width 0.5s ease-out;
}

.item-dock {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  pointer-events: auto;
}

.item-btn {
  position: relative;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-btn:hover:not(:disabled) {
  transform: scale(1.1);
  border-color: white;
}

.item-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.item-btn .icon { font-size: 1.5rem; }

.badge {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  background: var(--accent-yellow);
  color: black;
  font-size: 0.65rem;
  font-weight: 900;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#item-big-cannon { border-color: var(--accent-yellow); }
#item-big-cannon.active { background: var(--accent-yellow); animation: pulse 1s infinite; }

#item-freeze { border-color: var(--secondary-sky); }
#item-freeze.active { background: var(--secondary-sky); animation: pulse 1s infinite; }

#item-heal { border-color: var(--success-green); }

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Game Over View Styles */
#game-over-view {
  background: rgba(0, 0, 0, 0.9);
  padding: 0.1rem;
  overflow-y: auto;
}

.game-over-content {
  max-width: 480px;
  width: 100%;
  text-align: center;
  background: #1e293b;
  border: 4px solid var(--danger-red);
  border-radius: 2rem;
  padding: 0.6rem 2.5rem 0.6rem 2.5rem; 
  box-shadow: 0 0 50px rgba(239, 68, 68, 0.2);
}

.game-over-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--danger-red);
  font-style: italic;
  letter-spacing: -0.05em;
  margin-bottom: 0.6rem;
}

.final-stats {
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.2em;
}

.stat-value {
  font-size: 2.3rem;
  font-weight: 900;
}

.stat-round {
  color: var(--accent-yellow);
  font-weight: 700;
  font-size: 1.15rem;
}

.submit-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1.25rem;
  padding: 1.5rem;
  margin-bottom: 0.6rem;
}

.submit-section h3 {
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.input-group {
  display: flex;
  gap: 0.1rem;
}

.input-group input {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.75rem;
  padding: 0.7rem 1rem;
  color: white;
  outline: none;
}

.input-group input:focus {
  border-color: var(--accent-yellow);
}

#submit-score-btn {
  background: var(--accent-yellow);
  color: black;
  font-weight: 800;
  border: none;
  padding: 0 1.5rem;
  border-radius: 0.75rem;
  cursor: pointer;
}

#submit-score-btn:disabled {
  background: #475569;
  color: #94a3b8;
  cursor: not-allowed;
}


.action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.secondary-btn, .share-btn {
  padding: 0.6rem 1rem;
  border-radius: 1rem;
  border: none;
  font-weight: 900;
  font-size: 1.125rem;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn { background: white; color: black; }
.secondary-btn:hover { background: var(--secondary-sky); color: white; }

.share-btn { background: var(--secondary-sky); color: white; }
.share-btn:hover { background: #0284c7; }

.mini-leaderboard {
  text-align: left;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.8rem;
  border-radius: 1rem;
}

.mini-title {
  font-size: 0.875rem;
  color: var(--danger-red);
  margin-bottom: 0.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.15rem;
}

.leaderboard-item.top-rank {
  color: var(--accent-yellow);
  font-weight: 700;
}

.participants-text {
  color: var(--secondary-sky); /* 하늘색 포인트 */
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  background: rgba(14, 165, 233, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  display: inline-block;
  border: 1px solid rgba(14, 165, 233, 0.2);
  /* 처음엔 투명하게 */
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.5s ease-out;
}

.participants-text.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- 모바일 반응형 최적화 (기존 미디어 쿼리 수정 및 추가) --- */

@media (max-width: 768px) {
  /* 결과창 박스 너비를 더 넓게 사용 */
  .game-over-content {
    width: 97%; 
    max-width: none;
    padding: 0.8rem; /* 안쪽 여백을 줄여 내부 공간 확보 */
    border-width: 3px; /* 테두리 두께 살짝 조절 */
  }

  .game-over-title {
    font-size: 1.7rem;
  }

  .stat-value {
    font-size: 2.1rem;
  }
}

@media (max-width: 480px) {
  /* 닉네임 입력 섹션 최적화 */
  .submit-section {
    padding: 1rem 1rem;
  }

  .input-group {
    flex-direction: column; /* 입력창과 버튼을 세로로 배치 */
    gap: 0.75rem;
  }

  .input-group input {
    width: 100%;
    height: 3.5rem; /* 터치하기 편하게 높이 조절 */
    font-size: 1rem;
    text-align: center;
    padding: 0; /* 중앙 정렬을 위해 패딩 조정 */
  }

  #submit-score-btn {
    width: 100%;
    height: 2rem;
    font-size: 1rem;
    padding: 0;
  }

  /* 하단 액션 버튼(다시하기, 공유하기) 크기 조정 */
  .action-btns {
    gap: 0.75rem;
  }

  .secondary-btn, .share-btn {
    padding: 0.6rem;
    font-size: 0.8rem;
  }


/* 모바일용 미세 조정 (화면 너비 480px 이하일 때) */
@media (max-width: 480px) {
  .item-dock {
    right: 0.8rem;   /* 모바일에서는 우측 여백을 조금 줄임 */
    gap: 0.8rem;     /* 버튼 사이 간격을 좁힘 */
  }

  .item-btn {
    width: 3.2rem;   /* 모바일 화면을 가리지 않도록 버튼 크기를 살짝 축소 */
    height: 3.1rem;
    border-radius: 1rem;
  }
  
  .item-btn .icon {
    font-size: 1.1rem; /* 아이콘 크기 조절 */
  }
  
  .badge {
    width: 1.1rem;   /* 아이템 개수 뱃지 크기 조절 */
    height: 1.1rem;
    font-size: 0.6rem;
  }
}

/* 모바일에서 wpDiscuz 댓글창 좌우 여백 추가 */
@media screen and (max-width: 768px) {
    #wpdcom {
        padding-left: 20px !important;
        padding-right: 20px !important;
        box-sizing: border-box !important;
    }
}

