* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #070912;
  --ink: #e7ecff;
  --cyan: #74e7ff;
  --amber: #ffcf4a;
  --pink: #ff6ad0;
  --green: #9bf08a;
  --red: #ff4a6e;
  --pan: rgba(12,16,30,.94);
}
html, body {
  height: 100%;
  background: radial-gradient(900px 600px at 50% -8%, #14213f 0%, var(--bg) 62%);
  color: var(--ink);
  font-family: 'Trebuchet MS', system-ui, -apple-system, 'Apple SD Gothic Neo', sans-serif;
  overflow: hidden; user-select: none; touch-action: none;
}
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 44px; z-index: 60;
  display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: linear-gradient(180deg, rgba(7,9,18,.96), rgba(7,9,18,.4) 70%, transparent);
}
.topbar .back { color: var(--ink); text-decoration: none; opacity: .82; font-size: 14px; }
.topbar .back:hover { opacity: 1; }
.topbar .brand { font-weight: bold; letter-spacing: .5px; font-size: 16px;
  background: linear-gradient(90deg, #9ffcff, #74e7ff, #c3a0ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar .iconbtn { margin-left: auto; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16);
  color: #fff; width: 30px; height: 30px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.topbar .hs { font-size: 13px; opacity: .9; white-space: nowrap; }
.topbar .hs b { color: var(--amber); }

#stage {
  position: absolute; inset: 0; top: 44px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges;
  background: #060812; border-radius: 8px;
  box-shadow: 0 0 50px rgba(80,140,255,.16), inset 0 0 60px rgba(0,0,0,.6);
  touch-action: none; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 50px; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 12px; pointer-events: none;
}
.hpRow { display: flex; gap: 2px; font-size: 16px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.hpRow .heart { color: var(--red); }
.hpRow .heart.off { color: rgba(255,255,255,.18); }
.chips { display: flex; gap: 5px; margin-top: 5px; }
.chip { background: rgba(10,14,28,.78); border: 1px solid rgba(120,160,255,.22);
  border-radius: 7px; padding: 2px 7px; font-size: 11px; letter-spacing: .3px; }
.chip.bomb { color: var(--amber); }
.chip.coin { color: var(--amber); }
.hudRight { text-align: right; }
.scoreBig { font-size: 22px; font-weight: 900; letter-spacing: .5px; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.multTag { font-size: 14px; font-weight: 800; color: var(--cyan);
  text-shadow: 0 0 8px rgba(116,231,255,.6); }
#grazeBar { position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
  width: 96px; height: 4px; z-index: 20; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
#grazeFill { height: 100%; width: 0; background: linear-gradient(90deg, #74e7ff, #c3a0ff); transition: width .12s; }

/* ---------- 터치 조작 ---------- */
#touchCtrl { position: absolute; right: 12px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 30;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.ctrlBtn { width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,207,74,.16); color: var(--amber); font-size: 24px; font-weight: 900; cursor: pointer;
  backdrop-filter: blur(3px); box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.ctrlBtn:active { transform: scale(.92); }
.ctrlBtn.small { width: 40px; height: 40px; font-size: 14px; color: #cfe0ff; background: rgba(255,255,255,.1); }

/* ---------- 토스트 ---------- */
#toast { position: absolute; left: 50%; top: 34%; transform: translate(-50%,-50%); z-index: 25;
  text-align: center; pointer-events: none; opacity: 0; transition: opacity .25s, transform .25s; }
#toast.show { opacity: 1; transform: translate(-50%,-50%) scale(1.04); }
#toast .tBig { font-size: 34px; font-weight: 900; letter-spacing: 2px;
  background: linear-gradient(90deg, #9ffcff, #ffd24a, #ff6ad0); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 18px rgba(120,200,255,.5); }
#toast .tSub { font-size: 14px; color: #ffd0e6; margin-top: 2px; font-weight: 700; }

/* ---------- 오버레이/패널 ---------- */
.overlay { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(4,6,14,.74); backdrop-filter: blur(5px); }
.overlay.hidden, .hidden { display: none !important; }
.panel { width: 100%; max-width: 360px; max-height: 92%; overflow-y: auto;
  background: var(--pan); border: 1px solid rgba(120,160,255,.2); border-radius: 18px;
  padding: 22px 20px; text-align: center; box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.panel.wide { max-width: 420px; }
.logo { font-size: 50px; line-height: 1; filter: drop-shadow(0 4px 10px rgba(116,231,255,.4)); }
.panel h1 { font-size: 34px; font-weight: 900; letter-spacing: 1px; margin-top: 4px;
  background: linear-gradient(90deg, #9ffcff, #74e7ff, #c3a0ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel h1.dead { background: linear-gradient(90deg, #ff7a8e, #ff4a6e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel h2 { font-size: 21px; font-weight: 800; margin-bottom: 6px; }
.subt { font-size: 15px; letter-spacing: 3px; color: var(--cyan); margin: 0 0 12px; font-weight: 700; }
.sub { font-size: 13px; line-height: 1.6; color: #c4cce6; margin-bottom: 16px; }
.cT { color: var(--cyan); }
.panel b { color: #fff; }
.btn { display: inline-block; width: 100%; padding: 13px 16px; margin-top: 4px; border: 0; border-radius: 12px;
  background: linear-gradient(180deg, #4aa8ff, #2d7be0); color: #fff; font-size: 17px; font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 18px rgba(45,123,224,.4); letter-spacing: 1px; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  box-shadow: none; font-size: 14px; letter-spacing: 0; }
.btnRow { display: flex; gap: 8px; margin-top: 8px; }
.btnRow .btn { margin-top: 0; }
.ctrl { font-size: 11.5px; color: #8c96b6; margin-top: 14px; line-height: 1.6; }

.howBody { text-align: left; font-size: 13px; line-height: 1.6; color: #c8d0ea; }
.howBody p { margin: 7px 0; }
.howBody hr { border: 0; border-top: 1px solid rgba(255,255,255,.12); margin: 10px 0; }
.dotc { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 2px; }

/* ---------- 통계 ---------- */
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.cell { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 10px 6px; }
.cell .k { font-size: 11px; color: #98a2c0; }
.cell .v { font-size: 22px; font-weight: 900; margin-top: 2px; }
.cell .v.gold { color: var(--amber); }
.cell .v.credit { color: var(--cyan); }

/* ---------- 상점 ---------- */
.shopTop { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.goldTag { background: rgba(255,207,74,.14); border: 1px solid rgba(255,207,74,.3); color: var(--amber);
  border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 700; }
.shopGrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 12px 0; }
.shopCard { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 12px;
  padding: 10px 6px 8px; text-align: center; cursor: pointer; transition: transform .1s, border-color .1s;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink); }
.shopCard:hover { transform: translateY(-2px); border-color: rgba(116,231,255,.5); }
.shopCard.noaff { opacity: .55; }
.shopCard.shake { animation: shk .3s; }
@keyframes shk { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
.sIcon { font-size: 22px; line-height: 1; }
.sName { font-size: 12px; font-weight: 800; }
.sDesc { font-size: 10px; color: #9aa4c2; line-height: 1.3; min-height: 26px; }
.sLv { font-size: 10px; color: #74e7ff; }
.sCost { font-size: 12px; font-weight: 800; color: var(--amber); margin-top: 2px; }
.shopBtns { display: flex; gap: 8px; }
.shopBtns .btn { margin-top: 0; }
.shopBtns .ghost { flex: 0 0 auto; width: auto; }

/* ---------- 격납고 ---------- */
.hangarGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.hCard { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 10px; text-align: left; }
.hCard.maxed { border-color: rgba(255,207,74,.4); }
.hName { font-size: 13px; font-weight: 800; }
.hDesc { font-size: 10.5px; color: #9aa4c2; margin: 2px 0 6px; line-height: 1.35; min-height: 28px; }
.hLv { display: flex; gap: 3px; margin-bottom: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.16); }
.dot.on { background: var(--cyan); box-shadow: 0 0 5px rgba(116,231,255,.7); }
.hBuy { width: 100%; border: 0; border-radius: 8px; padding: 7px; font-size: 13px; font-weight: 800;
  background: linear-gradient(180deg,#4aa8ff,#2d7be0); color: #fff; cursor: pointer; }
.hBuy.max { background: rgba(255,207,74,.16); color: var(--amber); text-align: center; }

@media (max-height: 560px) {
  .panel h1 { font-size: 26px; } .logo { font-size: 38px; } .sub { font-size: 12px; margin-bottom: 10px; }
}
