/* ===== 소리구미 서바이버 — 네온 다크 테마 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-deep: #0b0b1e;
  --bg-card: rgba(22, 33, 62, 0.92);
  --neon-cyan: #4dd9ff;
  --neon-pink: #ff6bcb;
  --neon-purple: #b388ff;
  --neon-gold: #ffd700;
  --danger: #ff4d6d;
  --hp-green: #4ade80;
  --text: #eef2ff;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: 'Segoe UI', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  color: var(--text);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

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

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

/* 피격 시 빨간 플래시 */
#flash {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 40, 70, 0.55) 100%);
  opacity: 0; transition: opacity 0.4s ease-out; z-index: 5;
}
#flash.on { opacity: 1; transition: opacity 0.05s; }

.hidden { display: none !important; }

/* ===== HUD ===== */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

#xpbar {
  position: absolute; top: 0; left: 0; right: 0; height: 7px;
  background: rgba(255,255,255,0.08);
}
#xpfill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
  box-shadow: 0 0 12px var(--neon-cyan);
  transition: width 0.15s ease-out;
}

#hud-top {
  position: absolute; top: 13px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: flex-start;
}

#hud-left { display: flex; align-items: center; gap: 8px; }

#level-badge {
  background: linear-gradient(135deg, var(--neon-purple), #7c4dff);
  border-radius: 999px; padding: 4px 12px;
  font-weight: 800; font-size: 14px;
  box-shadow: 0 0 14px rgba(179, 136, 255, 0.6);
  white-space: nowrap;
}

#hpbar {
  position: relative; width: min(170px, 32vw); height: 18px;
  background: rgba(0,0,0,0.5); border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2); overflow: hidden;
}
#hpfill {
  height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, var(--hp-green));
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.7);
  transition: width 0.2s ease-out, background 0.3s;
}
#hpfill.low { background: linear-gradient(90deg, #dc2626, var(--danger)); }
#hptext {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

#hud-center { text-align: center; }
#time {
  font-size: 26px; font-weight: 900; letter-spacing: 2px;
  text-shadow: 0 0 16px rgba(77, 217, 255, 0.8);
  font-variant-numeric: tabular-nums;
}
#score {
  font-size: 15px; font-weight: 700; color: var(--neon-gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
  font-variant-numeric: tabular-nums;
}

#hud-right { display: flex; gap: 8px; }
#hud-right button {
  pointer-events: auto;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(22, 33, 62, 0.75);
  color: var(--text); font-size: 18px; cursor: pointer;
  backdrop-filter: blur(4px);
}
#hud-right button:active { transform: scale(0.92); }

#combo {
  position: absolute; top: 86px; left: 50%; transform: translateX(-50%);
  font-size: 22px; font-weight: 900; font-style: italic;
  background: linear-gradient(90deg, var(--neon-gold), #ff8c00);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 8px rgba(255, 180, 0, 0.8));
  animation: comboPop 0.25s ease-out;
}
@keyframes comboPop {
  0% { transform: translateX(-50%) scale(1.6); }
  100% { transform: translateX(-50%) scale(1); }
}

#bossbar {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  width: min(420px, 80vw); display: flex; align-items: center; gap: 8px;
}
.boss-label {
  font-size: 13px; font-weight: 900; color: var(--danger);
  text-shadow: 0 0 8px rgba(255, 77, 109, 0.8); white-space: nowrap;
}
.boss-track {
  flex: 1; height: 12px; background: rgba(0,0,0,0.55);
  border-radius: 999px; border: 1px solid rgba(255, 77, 109, 0.5); overflow: hidden;
}
#bossfill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #ff4d6d, #ff9e00);
  box-shadow: 0 0 12px rgba(255, 77, 109, 0.8);
  transition: width 0.15s;
}

/* ===== 가상 조이스틱 ===== */
#joystick { position: absolute; z-index: 20; pointer-events: none; }
#joy-base {
  width: 110px; height: 110px; border-radius: 50%;
  border: 2px solid rgba(77, 217, 255, 0.4);
  background: rgba(77, 217, 255, 0.08);
  position: relative;
}
#joy-stick {
  width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.9), var(--neon-cyan));
  box-shadow: 0 0 16px rgba(77, 217, 255, 0.8);
  position: absolute; left: 31px; top: 31px;
}

/* ===== 풀스크린 화면들 ===== */
.screen {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(8, 8, 24, 0.78);
  backdrop-filter: blur(6px);
  padding: 20px;
}

.panel {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  background: var(--bg-card);
  border: 1px solid rgba(120, 140, 255, 0.25);
  border-radius: 24px;
  padding: 36px 42px;
  box-shadow: 0 10px 60px rgba(0,0,0,0.6), 0 0 40px rgba(77, 217, 255, 0.12);
  max-width: min(440px, 92vw);
  animation: panelIn 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes panelIn {
  from { transform: translateY(24px) scale(0.94); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.title {
  font-size: clamp(40px, 9vw, 60px); font-weight: 900; line-height: 1.12;
  text-align: center; letter-spacing: 2px;
  background: linear-gradient(135deg, var(--neon-cyan) 10%, var(--neon-purple) 50%, var(--neon-pink) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(124, 100, 255, 0.55));
  animation: titleFloat 3s ease-in-out infinite;
}
@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.subtitle { font-size: 14px; letter-spacing: 5px; color: var(--neon-cyan); opacity: 0.85; }

#char-row { display: flex; gap: 6px; align-items: flex-end; height: 56px; }
#char-row img {
  width: 48px; height: 48px; object-fit: contain;
  animation: charBounce 1.4s ease-in-out infinite;
}
#char-row img:nth-child(2n) { animation-delay: 0.2s; }
#char-row img:nth-child(3n) { animation-delay: 0.4s; }
#char-row img.player-char { width: 60px; height: 60px; filter: drop-shadow(0 0 10px rgba(255, 107, 203, 0.9)); }
@keyframes charBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.info {
  display: flex; flex-direction: column; gap: 8px;
  font-size: 14px; color: #c7d2fe; line-height: 1.5;
}
.info b { color: var(--text); }

.best {
  font-size: 15px; font-weight: 700; color: var(--neon-gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.btn-big {
  font-family: inherit;
  font-size: 20px; font-weight: 900; color: #fff;
  padding: 15px 52px; border: none; border-radius: 999px; cursor: pointer;
  background: linear-gradient(135deg, var(--neon-pink), #7c4dff);
  box-shadow: 0 6px 26px rgba(255, 107, 203, 0.45);
  transition: transform 0.12s, box-shadow 0.2s;
  letter-spacing: 1px;
}
.btn-big:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 10px 34px rgba(255, 107, 203, 0.65); }
.btn-big:active { transform: scale(0.96); }

.btn-sub {
  font-family: inherit;
  font-size: 14px; font-weight: 600; color: #aab4e8;
  padding: 10px 28px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid rgba(170, 180, 232, 0.35);
  transition: background 0.15s;
}
.btn-sub:hover { background: rgba(170, 180, 232, 0.12); }

/* ===== 레벨업 ===== */
.levelup-title {
  font-size: clamp(30px, 7vw, 44px); font-weight: 900;
  background: linear-gradient(90deg, var(--neon-gold), #ff8c00, var(--neon-gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 200, 0, 0.7));
  animation: levelupPulse 0.8s ease-in-out infinite alternate;
}
@keyframes levelupPulse { from { transform: scale(1); } to { transform: scale(1.05); } }

.levelup-sub { margin: 8px 0 24px; color: #c7d2fe; font-size: 15px; }

#cards {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  max-width: 760px;
}

.card {
  width: min(200px, 28vw); min-width: 150px;
  background: linear-gradient(160deg, rgba(35, 48, 92, 0.95), rgba(18, 26, 54, 0.95));
  border: 2px solid rgba(120, 140, 255, 0.35);
  border-radius: 20px; padding: 22px 14px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; text-align: center;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  animation: cardIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
}
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.16s; }
@keyframes cardIn {
  from { transform: translateY(30px) scale(0.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.card:hover, .card:active {
  transform: translateY(-6px) scale(1.04);
  border-color: var(--neon-gold);
  box-shadow: 0 8px 32px rgba(255, 200, 0, 0.35);
}
.card.evo {
  border-color: var(--neon-gold);
  background: linear-gradient(160deg, rgba(80, 60, 20, 0.95), rgba(40, 28, 10, 0.95));
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.25);
}
.card .icon { font-size: 42px; filter: drop-shadow(0 0 10px rgba(255,255,255,0.35)); }
.card .name { font-size: 17px; font-weight: 800; }
.card .desc { font-size: 13px; color: #aab4e8; line-height: 1.4; }
.card .dots { font-size: 11px; letter-spacing: 2px; color: var(--neon-gold); }

/* ===== 일시정지 / 게임오버 ===== */
.pause-title { font-size: 32px; font-weight: 900; letter-spacing: 4px; }

.over-title {
  font-size: clamp(36px, 8vw, 52px); font-weight: 900; letter-spacing: 3px;
  background: linear-gradient(135deg, var(--danger), #ff9e00);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 77, 109, 0.6));
}

.newbest {
  font-size: 17px; font-weight: 900; color: var(--neon-gold);
  text-shadow: 0 0 14px rgba(255, 215, 0, 0.8);
  animation: levelupPulse 0.6s ease-in-out infinite alternate;
}

#stats {
  display: grid; grid-template-columns: auto auto; gap: 7px 22px;
  font-size: 15px; color: #c7d2fe;
}
#stats .v { text-align: right; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
#stats .highlight { color: var(--neon-gold); }

/* ===== 업적 ===== */
#achv-toast {
  position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: 999px; padding: 10px 22px;
  font-size: 14px; font-weight: 700; color: var(--neon-gold);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.3);
  z-index: 40; pointer-events: none; white-space: nowrap;
  animation: toastIn 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

#achv-stats { font-size: 13px; color: #aab4e8; }
#achv-list {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; max-height: min(380px, 48vh); overflow-y: auto;
}
.achv-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,0.25); border: 1px solid transparent;
  border-radius: 14px; padding: 9px 14px;
  opacity: 0.45; filter: grayscale(0.8);
}
.achv-item.on { opacity: 1; filter: none; border-color: rgba(255, 215, 0, 0.35); }
.achv-item .a-icon { font-size: 24px; }
.achv-item .a-body { display: flex; flex-direction: column; flex: 1; text-align: left; }
.achv-item .a-body b { font-size: 14px; }
.achv-item .a-body small { font-size: 12px; color: #aab4e8; }
.achv-item .a-state { font-size: 14px; color: var(--neon-gold); }
