:root {
  --cyan: #37f7ff;
  --magenta: #ff5af0;
  --yellow: #ffd23f;
  --green: #7bff5a;
  --bg0: #06040e;
  --bg1: #0a0a1f;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  background: var(--bg0);
  color: #e8ecff;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
}
body { display: flex; flex-direction: column; }

/* ===== Topbar ===== */
#topbar {
  flex: 0 0 auto;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: linear-gradient(180deg, #0c0c22, #08081a);
  border-bottom: 1px solid rgba(55, 247, 255, 0.25);
  box-shadow: 0 0 18px rgba(55, 247, 255, 0.12);
  z-index: 5;
}
#topbar .back { color: #9fb6ff; text-decoration: none; font-size: 14px; font-weight: 600; }
#topbar .back:hover { color: #fff; }
#topbar .brand {
  font-weight: 800; letter-spacing: 0.5px; font-size: 16px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
#topbar .hs { margin-left: auto; font-size: 13px; color: #8ea0d0; }
#topbar .hs b { color: var(--yellow); font-size: 15px; }

/* ===== Stage ===== */
#stage { position: relative; flex: 1 1 auto; overflow: hidden; }
#game { position: absolute; inset: 0; display: block; touch-action: none; }

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

#xpbar {
  position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: rgba(255, 255, 255, 0.06);
}
#xpfill { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--magenta)); box-shadow: 0 0 10px var(--cyan); transition: width 0.15s; }
#xptext { position: absolute; top: 8px; left: 10px; font-size: 12px; color: #aeb8e8; font-weight: 700; }

#topstats {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; pointer-events: auto;
}
.stat {
  background: rgba(10, 12, 30, 0.7); border: 1px solid rgba(120, 150, 255, 0.25);
  padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; color: #dfe6ff;
  min-width: 40px; text-align: center;
}
.stat.combo { color: var(--yellow); }
.iconbtn {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  background: rgba(10, 12, 30, 0.7); border: 1px solid rgba(120, 150, 255, 0.25);
  color: #cfe; font-size: 15px;
}
.iconbtn:hover { background: rgba(40, 50, 90, 0.8); }

#botbar {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(94%, 520px);
}
#hpwrap, #enwrap {
  position: relative; width: 100%; height: 16px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(120, 150, 255, 0.2); overflow: hidden;
}
#enwrap { height: 9px; width: 78%; }
#hpfill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff3b6b, #ff8aa8); box-shadow: 0 0 10px #ff3b6b; transition: width 0.12s; }
#enfill { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), #9bdcff); box-shadow: 0 0 8px var(--cyan); }
#hptext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.enlabel { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 8px; letter-spacing: 2px; color: rgba(255, 255, 255, 0.7); }
#weaponName { font-size: 13px; font-weight: 700; }
#weaponDock { display: flex; gap: 6px; }
.wslot {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; font-size: 15px; border: 1px solid rgba(120, 150, 255, 0.18);
  background: rgba(10, 12, 30, 0.6); opacity: 0.4;
}
.wslot.owned { opacity: 1; }
.wslot.active { border-color: currentColor; box-shadow: 0 0 10px currentColor; background: rgba(255, 255, 255, 0.06); }

#stickHint { position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%); font-size: 11px; color: rgba(180, 200, 255, 0.6); white-space: nowrap; }
#stickHint.hidden { display: none; }

/* ===== Screens / overlays ===== */
.screen {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: 6; padding: 16px;
}
.screen.hidden { display: none; }
.overlayscreen { background: rgba(4, 4, 14, 0.78); backdrop-filter: blur(4px); }
#menuScreen { background: radial-gradient(circle at 50% 30%, #12123a 0%, #06040e 70%); }

.menu-card {
  width: min(520px, 94%); text-align: center;
  background: linear-gradient(180deg, rgba(18, 20, 48, 0.92), rgba(8, 9, 22, 0.92));
  border: 1px solid rgba(55, 247, 255, 0.3); border-radius: 18px;
  padding: 26px 24px 22px; box-shadow: 0 0 40px rgba(55, 247, 255, 0.15), inset 0 0 30px rgba(80, 60, 160, 0.08);
}
.logo { font-size: 52px; filter: drop-shadow(0 0 14px var(--cyan)); animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.menu-card h1 {
  font-size: 30px; font-weight: 900; letter-spacing: 0.5px; margin: 4px 0 2px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--yellow));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.menu-card h1 small { display: block; font-size: 13px; font-weight: 600; color: #8ea0d0; -webkit-text-fill-color: #8ea0d0; margin-top: 2px; letter-spacing: 2px; }
.tag { font-size: 14px; line-height: 1.6; color: #c4cdf0; margin: 12px 0 14px; }
.tag b { color: var(--cyan); }
.feats { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-bottom: 18px; }
.feats span {
  font-size: 12px; padding: 5px 10px; border-radius: 20px;
  background: rgba(55, 247, 255, 0.08); border: 1px solid rgba(55, 247, 255, 0.22); color: #bfe9ff;
}
.hint { font-size: 11.5px; color: #8794be; margin-top: 14px; line-height: 1.6; }
.hint b { color: #cfe; }

.btn {
  display: block; width: 100%; cursor: pointer; border: none; border-radius: 12px;
  padding: 13px 18px; font-size: 16px; font-weight: 800; color: #04121a; margin-top: 10px;
  background: linear-gradient(90deg, var(--cyan), #7df);
  box-shadow: 0 0 22px rgba(55, 247, 255, 0.4); transition: transform 0.1s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 0 30px rgba(55, 247, 255, 0.6); }
.btn:active { transform: translateY(0); }
.btn.big { font-size: 18px; padding: 15px; }
.btn.ghost { background: transparent; color: #aebbe8; border: 1px solid rgba(120, 150, 255, 0.3); box-shadow: none; }
.btn.ghost:hover { background: rgba(120, 150, 255, 0.1); color: #fff; }
.btn.sm { font-size: 13px; padding: 9px; }

/* ===== Level up ===== */
.levelpanel { width: min(720px, 96%); text-align: center; }
.levelpanel h2 {
  font-size: 24px; font-weight: 900; margin-bottom: 16px;
  background: linear-gradient(90deg, var(--yellow), var(--magenta)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.levelcards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.upcard {
  pointer-events: auto; cursor: pointer; width: 190px; min-height: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px;
  padding: 18px 14px; border-radius: 14px; text-align: center;
  background: linear-gradient(180deg, rgba(20, 22, 50, 0.95), rgba(10, 11, 26, 0.95));
  border: 1.5px solid var(--gc); box-shadow: 0 0 18px color-mix(in srgb, var(--gc) 35%, transparent);
  color: #e8ecff; transition: transform 0.12s, box-shadow 0.2s;
}
.upcard:hover { transform: translateY(-4px) scale(1.03); box-shadow: 0 0 30px color-mix(in srgb, var(--gc) 60%, transparent); }
.upcard.weapon { background: linear-gradient(180deg, rgba(40, 24, 56, 0.95), rgba(16, 10, 26, 0.95)); }
.upicon { font-size: 38px; filter: drop-shadow(0 0 10px var(--gc)); color: var(--gc); }
.upname { font-size: 16px; font-weight: 800; color: #fff; }
.updesc { font-size: 12.5px; color: #b9c2e8; line-height: 1.5; flex: 1; }
.uptag { font-size: 10px; letter-spacing: 1px; padding: 3px 8px; border-radius: 10px; background: color-mix(in srgb, var(--gc) 18%, transparent); color: var(--gc); }

/* ===== Pause / over stats ===== */
.pausestats, .overstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.pausestats div, .overstats div {
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(120, 150, 255, 0.18);
  border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px;
}
.pausestats span, .overstats span { font-size: 11px; color: #8ea0d0; }
.pausestats b, .overstats b { font-size: 18px; color: #fff; }
#overScoreWrap { margin: 8px 0 4px; }
#overScoreWrap span { display: block; font-size: 12px; color: #8ea0d0; }
#overScoreWrap b { font-size: 34px; font-weight: 900; color: var(--yellow); text-shadow: 0 0 18px rgba(255, 210, 63, 0.5); }

/* ===== Toast banner ===== */
#toast {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%) translateY(-10px);
  background: rgba(8, 9, 22, 0.9); border: 1px solid rgba(55, 247, 255, 0.4);
  color: #eaf6ff; font-weight: 800; font-size: 15px; padding: 9px 18px; border-radius: 10px;
  box-shadow: 0 0 22px rgba(55, 247, 255, 0.3); z-index: 4; opacity: 0; transition: opacity 0.3s, transform 0.3s;
  pointer-events: none; white-space: nowrap;
}
#toast.hidden { display: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .menu-card h1 { font-size: 25px; }
  .upcard { width: 150px; min-height: 160px; }
  .levelpanel h2 { font-size: 20px; }
}
