/* ============ ICE BUCKET! ============ */
:root {
  --ice-1: #aee6ff;
  --ice-2: #5fb8e8;
  --deep: #0b1e33;
  --accent: #ffd166;
  --danger: #ff5d73;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--deep);
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', sans-serif;
  color: #eaf6ff;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none; /* 당겨서 새로고침 방지 */
}

/* 게임 영역만 브라우저 터치 제스처 차단 (더블탭 줌 등) — 메뉴에선 핀치 줌 허용 */
#game-canvas, #btn-dash, #hud { touch-action: none; }
button, a, input, label { touch-action: manipulation; }

#app { position: fixed; inset: 0; }

#game-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ---------- 상시 오버레이 ---------- */
#frost-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(140, 200, 255, 0.10) 78%, rgba(180, 225, 255, 0.28) 100%);
  mix-blend-mode: screen;
}

#hit-flash {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255,60,80,0.18) 0%, rgba(255,30,60,0.5) 100%);
  opacity: 0;
  transition: opacity 0.08s linear;
}
#hit-flash.on { opacity: 1; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  /* 노치/펀치홀 안전영역 대응 */
  padding: calc(14px + env(safe-area-inset-top, 0px))
           calc(18px + env(safe-area-inset-right, 0px))
           14px
           calc(18px + env(safe-area-inset-left, 0px));
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(5, 20, 40, 0.8);
  z-index: 20; /* 일시정지 오버레이 위에서도 버튼 클릭 가능 */
}
#hud-left, #hud-right { display: flex; flex-direction: column; gap: 8px; min-width: 130px; }
#hud-right { align-items: flex-end; }

#hearts { font-size: 26px; letter-spacing: 3px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
#hearts .lost { opacity: 0.25; filter: grayscale(1); }

#dash-wrap {
  width: 110px; height: 10px; border-radius: 6px;
  background: rgba(10, 30, 55, 0.6);
  border: 1px solid rgba(160, 220, 255, 0.35);
  position: relative; overflow: visible;
}
#dash-bar {
  height: 100%; width: 100%; border-radius: 5px;
  background: linear-gradient(90deg, #6ee7ff, #b3f0ff);
  transition: width 0.05s linear;
  box-shadow: 0 0 8px rgba(110, 231, 255, 0.7);
}
#dash-label {
  position: absolute; top: 12px; left: 0;
  font-size: 10px; color: #9fd4f5; letter-spacing: 1px;
}

#parry-wrap {
  margin-top: 16px;
  width: 110px; height: 10px; border-radius: 6px;
  background: rgba(10, 30, 55, 0.6);
  border: 1px solid rgba(255, 215, 122, 0.4);
  position: relative; overflow: visible;
}
#parry-bar {
  height: 100%; width: 100%; border-radius: 5px;
  background: linear-gradient(90deg, #ffd77a, #ffecb3);
  transition: width 0.05s linear;
  box-shadow: 0 0 8px rgba(255, 215, 122, 0.7);
}
#parry-label {
  position: absolute; top: 12px; left: 0;
  font-size: 10px; color: #f0d9a0; letter-spacing: 1px;
}

#hud-center { text-align: center; }
#score {
  font-size: 40px; font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(120, 210, 255, 0.85), 0 3px 10px rgba(4, 18, 38, 0.9);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
#combo {
  font-size: 16px; font-weight: 800; color: var(--accent);
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.8);
  animation: comboPop 0.25s ease;
}
@keyframes comboPop {
  0% { transform: scale(1.6); } 100% { transform: scale(1); }
}

#wave { font-size: 18px; font-weight: 800; color: #bfe9ff; letter-spacing: 2px; }

.hud-btns { display: flex; gap: 8px; pointer-events: auto; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid rgba(160, 220, 255, 0.4);
  background: rgba(12, 34, 60, 0.55);
  color: #d9f1ff; font-size: 18px; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform 0.1s ease, background 0.15s ease;
}
.icon-btn:hover { background: rgba(30, 70, 110, 0.7); transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- 모바일 대시 버튼 ---------- */
#btn-dash {
  position: absolute;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  width: 74px; height: 74px; border-radius: 50%;
  font-size: 30px; cursor: pointer;
  border: 2px solid rgba(170, 225, 255, 0.55);
  background: rgba(16, 44, 76, 0.6);
  color: #d9f1ff;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  z-index: 20;
  -webkit-tap-highlight-color: transparent;
}
#btn-dash:active { transform: scale(0.92); background: rgba(60, 130, 190, 0.7); }
/* 터치 기기에서만 노출 (JS에서 hidden 해제와 병행) */
@media (hover: hover) and (pointer: fine) {
  #btn-dash { display: none !important; }
}

/* ---------- 팝업 (아슬아슬! / WAVE) ---------- */
#popup-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.popup {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 900; white-space: nowrap;
  animation: popupFloat 1.1s ease-out forwards;
  text-shadow: 0 2px 10px rgba(4, 18, 38, 0.9);
}
.popup.near { color: var(--accent); font-size: 22px; text-shadow: 0 0 14px rgba(255, 209, 102, 0.9), 0 2px 8px rgba(0,0,0,0.8); }
.popup.wave {
  left: 50% !important; top: 34% !important;
  font-size: 54px; color: #ffffff; letter-spacing: 6px;
  text-shadow: 0 0 30px rgba(110, 220, 255, 1), 0 4px 14px rgba(0,0,0,0.8);
  animation: waveBanner 1.6s ease-out forwards;
}
@keyframes popupFloat {
  0% { opacity: 0; margin-top: 0; transform: translate(-50%, -50%) scale(1.5); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; margin-top: -70px; transform: translate(-50%, -50%) scale(1); }
}
@keyframes waveBanner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

/* ---------- 스크린 공통 ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 18, 34, 0.45);
  backdrop-filter: blur(3px);
  z-index: 10;
}
.panel {
  background: linear-gradient(160deg, rgba(18, 46, 78, 0.92), rgba(9, 26, 48, 0.94));
  border: 1px solid rgba(150, 215, 255, 0.35);
  border-radius: 26px;
  padding: 34px 44px;
  text-align: center;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(200, 235, 255, 0.25);
  max-width: min(92vw, 520px);
  max-height: 92vh; overflow-y: auto;
}
.panel.small { padding: 28px 48px; }

.logo {
  font-size: clamp(30px, 6vw, 46px); font-weight: 900; letter-spacing: 2px;
  background: linear-gradient(180deg, #ffffff 20%, #9fdcff 70%, #6fc2f5);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 14px rgba(110, 200, 255, 0.45));
}
.snow-ico { font-size: 0.75em; }
.subtitle { margin-top: 6px; color: #a8d8f8; font-size: 15px; letter-spacing: 4px; font-weight: 600; }

/* 캐릭터 미리보기 */
#char-preview-wrap { margin: 20px auto 4px; width: 150px; }
#char-preview {
  width: 150px; height: 150px; border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.22), transparent 55%),
    linear-gradient(180deg, rgba(120, 195, 245, 0.35), rgba(30, 80, 130, 0.5));
  border: 3px solid rgba(170, 225, 255, 0.65);
  box-shadow: 0 6px 24px rgba(60, 150, 220, 0.4), inset 0 2px 12px rgba(255,255,255,0.2);
}
#char-name { margin-top: 8px; font-size: 13px; color: #bfe4ff; font-weight: 600; }

/* 캐릭터 선택 그리드 */
#char-grid {
  display: grid;
  grid-template-columns: repeat(4, 64px);
  gap: 10px;
  justify-content: center;
  margin: 14px auto 4px;
}
.char-slot {
  width: 64px; height: 64px;
  border-radius: 16px;
  border: 2px solid rgba(150, 210, 250, 0.35);
  background: rgba(14, 38, 66, 0.7);
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease, border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.char-slot canvas { width: 56px; height: 56px; }
.char-slot:hover { transform: translateY(-2px); border-color: rgba(180, 230, 255, 0.7); }
.char-slot.selected {
  border-color: #ffd166;
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.55), inset 0 0 8px rgba(255, 209, 102, 0.2);
}
.char-slot.empty {
  color: #7fb8dc; font-size: 30px; font-weight: 300;
  border-style: dashed;
  background: rgba(10, 28, 50, 0.5);
}
.char-slot.empty:hover { color: #cfeaff; }

.title-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; align-items: center; }
.big-btn {
  min-width: 240px; padding: 14px 30px;
  font-size: 18px; font-weight: 800; font-family: inherit;
  border-radius: 16px; cursor: pointer;
  border: 1px solid rgba(180, 230, 255, 0.5);
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s;
}
.big-btn.primary {
  background: linear-gradient(180deg, #7fd8ff, #3ba4e0);
  color: #06263f;
  box-shadow: 0 8px 24px rgba(70, 170, 240, 0.5), inset 0 1px 0 rgba(255,255,255,0.6);
}
.big-btn.secondary {
  background: rgba(20, 52, 88, 0.85);
  color: #d6efff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.big-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.big-btn:active { transform: translateY(1px) scale(0.98); }

#whitekey-label {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 14px; font-size: 13px; color: #9fcbe8; cursor: pointer;
}
#whitekey-label input { accent-color: #5fb8e8; width: 15px; height: 15px; }

.help {
  margin-top: 20px; font-size: 13.5px; color: #a9d3ef; line-height: 1.9;
  border-top: 1px dashed rgba(150, 210, 250, 0.3); padding-top: 14px;
}
.help b { color: #e8f7ff; }
.help .tip { color: #7fb8dc; font-size: 12px; }

.best { margin-top: 14px; font-size: 15px; color: var(--accent); font-weight: 700; }

.home-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 13px;
  color: #8fc4e6;
  text-decoration: none;
  border-bottom: 1px solid rgba(143, 196, 230, 0.3);
  padding-bottom: 2px;
  transition: color 0.15s, border-color 0.15s;
}
.home-link:hover { color: #d9f1ff; border-color: rgba(217, 241, 255, 0.7); }

/* ---------- 진입 팝업 ---------- */
#screen-intro { z-index: 30; }
.intro-panel {
  max-width: min(92vw, 460px);
  animation: introIn 0.45s cubic-bezier(.2, .8, .3, 1);
}
@keyframes introIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.intro-ico {
  font-size: 46px;
  filter: drop-shadow(0 4px 14px rgba(120, 210, 255, 0.5));
}
.intro-title {
  margin-top: 10px;
  font-size: clamp(19px, 5vw, 24px);
  font-weight: 700;
  line-height: 1.5;
  color: #eaf6ff;
}
.intro-title b {
  color: var(--ice-1);
  text-shadow: 0 0 18px rgba(174, 230, 255, 0.5);
}
.intro-text {
  margin-top: 14px;
  font-size: 13.5px;
  line-height: 1.85;
  color: #a9d3ef;
  text-align: left;
}
.intro-text b { color: #e8f7ff; }
.intro-panel .als-links { margin-top: 20px; }
.intro-panel .big-btn { margin-top: 14px; width: 100%; }

/* ---------- 루게릭병(ALS) 안내 카드 ---------- */
.als-card--top { margin-top: 0; margin-bottom: 20px; }

.als-card {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(38, 82, 128, 0.45), rgba(20, 48, 82, 0.55));
  border: 1px solid rgba(140, 205, 250, 0.3);
  text-align: left;
}
.als-title {
  font-size: 14px; font-weight: 800; color: #cfeaff; margin-bottom: 8px;
}
.als-text {
  font-size: 12.5px; line-height: 1.75; color: #a9d3ef; margin: 0 0 12px;
}
.als-text b { color: #e8f7ff; }
.als-links { display: flex; gap: 8px; flex-wrap: wrap; }
.als-btn {
  flex: 1 1 auto;
  display: inline-block; text-align: center;
  padding: 9px 12px; border-radius: 12px;
  font-size: 13px; font-weight: 800; text-decoration: none;
  color: #06263f;
  background: linear-gradient(180deg, #a5e3ff, #5fb8e8);
  border: 1px solid rgba(200, 240, 255, 0.6);
  box-shadow: 0 4px 14px rgba(70, 170, 240, 0.35), inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform 0.12s ease, filter 0.15s;
}
.als-btn:hover { transform: translateY(-2px); filter: brightness(1.07); }
.als-btn:active { transform: translateY(1px) scale(0.98); }

/* ---------- 게임오버 ---------- */
.gameover-title {
  font-size: clamp(30px, 6vw, 44px); font-weight: 900; letter-spacing: 3px;
  color: #ff8fa0;
  text-shadow: 0 0 26px rgba(255, 93, 115, 0.6), 0 4px 14px rgba(0,0,0,0.7);
}
.final-score {
  margin-top: 16px; font-size: 58px; font-weight: 900; color: #ffffff;
  text-shadow: 0 0 24px rgba(120, 210, 255, 0.9);
  font-variant-numeric: tabular-nums;
}
.final-detail { margin-top: 6px; color: #a8d8f8; font-size: 14px; line-height: 1.7; }

/* ---------- 드롭 힌트 ---------- */
#drop-hint {
  position: absolute; inset: 14px; z-index: 50; pointer-events: none;
  border: 3px dashed rgba(160, 225, 255, 0.85); border-radius: 22px;
  background: rgba(20, 60, 100, 0.45);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 900; color: #d9f2ff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
}

/* 모바일 */
@media (max-width: 560px) {
  .panel { padding: 24px 20px; border-radius: 20px; }
  .big-btn { min-width: 200px; font-size: 16px; }
  #score { font-size: 30px; }
  #hearts { font-size: 21px; }
  #hud-left, #hud-right { min-width: 90px; }
  .popup.wave { font-size: 36px; }
}
