:root {
  --bg: #070b18;
  --panel: #101831;
  --panel-border: rgba(116, 174, 255, 0.22);
  --text: #eef4ff;
  --muted: #93a6cc;
  --accent: #3ce6ff;
  --accent-2: #ff4d8d;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, #15224a 0%, var(--bg) 70%);
  color: var(--text);
  font-family: 'Pretendard', 'Noto Sans KR', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1040px;
  margin: 0 auto;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  gap: 8px;
}

/* HUD */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(16, 24, 49, 0.88);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 9px;
  padding: 3px 9px;
  min-width: 58px;
}

.stat-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  line-height: 1.1;
}

.stat-pill strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.lives-pill strong {
  color: #ff6b8b;
  letter-spacing: 1px;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 10px;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(60, 230, 255, 0.16);
}

.icon-btn:active {
  transform: scale(0.94);
}

.install-btn {
  background: linear-gradient(135deg, #25c5ff, #4f7cff);
  border-color: transparent;
  color: #061022;
  font-weight: 700;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

/* 메인 레이아웃 */
.main-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 16px;
}

.board-column {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* 활성 효과 바 */
.effects-bar {
  width: 100%;
  max-width: 520px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.effect-pill {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(16, 24, 49, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}

.effect-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  opacity: 0.28;
  pointer-events: none;
}

.effect-pill span {
  position: relative;
  z-index: 1;
}

/* 캔버스 컨테이너 */
.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#gameCanvas {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 2 / 3;
  background: #090f24;
  border-radius: var(--radius);
  border: 1.5px solid rgba(90, 184, 255, 0.32);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), inset 0 0 24px rgba(56, 178, 255, 0.08);
  touch-action: none;
}

/* 모바일 하단 터치 슬라이더 */
.touch-pad {
  width: 100%;
  max-width: 520px;
  height: 52px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(27, 42, 82, 0.85), rgba(14, 22, 46, 0.95));
  border: 1px solid rgba(90, 184, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: ew-resize;
}

.touch-pad-label {
  font-size: 12px;
  color: #9ec5f8;
  pointer-events: none;
  letter-spacing: 0.02em;
}

/* 오버레이 */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(6, 10, 24, 0.72);
  backdrop-filter: blur(5px);
  border-radius: var(--radius);
  z-index: 5;
}

.overlay-card {
  width: 100%;
  max-width: 340px;
  background: rgba(15, 24, 52, 0.96);
  border: 1px solid rgba(88, 200, 255, 0.35);
  border-radius: 18px;
  padding: 20px 18px;
  text-align: center;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
}

.overlay-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 700;
}

.overlay-title {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.2;
}

.overlay-desc {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
  color: #c8d7f5;
}

.item-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}

.chip {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.chip b {
  margin-right: 3px;
}

.chip-w b { color: #3ce6ff; }
.chip-m b { color: #ffcf4d; }
.chip-l b { color: #ff5b7f; }
.chip-f b { color: #ff8c38; }
.chip-g b { color: #b975ff; }
.chip-s b { color: #54f0a8; }
.chip-h b { color: #ff6b9d; }

.overlay-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #3ce6ff, #4c7dff);
  color: #051126;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-primary:hover, .btn-secondary:hover {
  filter: brightness(1.08);
}

.btn-primary:active, .btn-secondary:active {
  transform: scale(0.97);
}

.controls-hint {
  margin: 12px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

/* PC 사이드 가이드 */
.side-guide {
  width: 280px;
  flex-shrink: 0;
  background: rgba(16, 24, 49, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-guide h2 {
  margin: 0;
  font-size: 16px;
  color: var(--accent);
}

.guide-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-list li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.guide-list strong {
  display: block;
  font-size: 13px;
}

.guide-list p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.badge {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  color: #081124;
}

.badge-w { background: #3ce6ff; }
.badge-m { background: #ffcf4d; }
.badge-l { background: #ff5b7f; color: #fff; }
.badge-f { background: #ff8c38; }
.badge-g { background: #b975ff; color: #fff; }
.badge-s { background: #54f0a8; }
.badge-h { background: #ff6b9d; color: #fff; }

.guide-box {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 10px 12px;
}

.guide-box h3 {
  margin: 0 0 5px;
  font-size: 13px;
  color: #dbe8ff;
}

.guide-box p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* 반응형: 모바일/태블릿에서는 사이드바 숨기고 터치 패드 강조 */
@media (max-width: 860px) {
  .side-guide {
    display: none;
  }

  .stat-pill {
    min-width: 48px;
    padding: 2px 7px;
  }

  .stat-pill strong {
    font-size: 13px;
  }

  .hud {
    padding: 6px 8px;
  }
}

/* PC 넓은 화면에서는 하단 터치 패드 숨기기 (터치 기기가 아닐 때) */
@media (min-width: 861px) and (hover: hover) and (pointer: fine) {
  .touch-pad {
    display: none;
  }
}
