:root {
  --bg: #0f1c26;
  --panel: rgba(12, 24, 36, 0.88);
  --blue: #2f7fe0;
  --blue-2: #5aa9ff;
  --gold: #ffcf4d;
  --text: #f3f6fa;
  --muted: #9fb3c4;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: min(100vw, calc(100dvh * 0.58));
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(#5ea9d8 0%, #cfe9f5 12%, #cfe9f5 100%);
}

#gl, #cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 8px;
  background: linear-gradient(rgba(0, 0, 0, 0.45), transparent);
}
.hud-level { flex: 1; min-width: 0; }
#hud-name { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.bar { height: 8px; margin-top: 5px; background: rgba(255, 255, 255, 0.2); border-radius: 4px; overflow: hidden; }
#hud-prog { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue-2), var(--gold)); }
.hud-stats { display: flex; gap: 6px; font-weight: 800; font-size: 14px; }
.hud-stats span { background: rgba(0, 0, 0, 0.45); padding: 4px 8px; border-radius: 10px; }
.icon-btn.off { opacity: 0.55; }
.icon-btn {
  pointer-events: auto;
  width: 38px; height: 38px;
  border: 0; border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff; font-weight: 900; font-size: 13px;
  cursor: pointer;
}
#hint {
  position: absolute;
  left: 0; right: 0; bottom: 6%;
  text-align: center;
  font-weight: 900;
  font-size: 20px;
  text-shadow: 0 2px 4px #000;
  animation: pulse 1.2s ease-in-out infinite;
  transition: opacity 0.6s;
}
#hint.fade { opacity: 0; }
@keyframes pulse { 50% { transform: translateY(-4px); } }

/* ---------- telas ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 12, 18, 0.45);
  z-index: 5;
}
.panel {
  width: 100%;
  max-width: 360px;
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 18px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
h1 {
  margin: 0;
  font-size: 44px;
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 4px 0 #1b4f8f;
}
h1 span { color: var(--gold); text-shadow: 0 4px 0 #a5560f; }
h2 { margin: 0 0 12px; font-size: 26px; font-weight: 900; }
.sub { color: var(--muted); font-size: 14px; margin: 12px 0 16px; line-height: 1.4; }

.btn {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 13px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(#4b9bff, var(--blue));
  box-shadow: 0 4px 0 #1b4f8f;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1b4f8f; }
.btn.big { padding: 16px; font-size: 20px; background: linear-gradient(#ffd96b, #f5a623); color: #3a2200; box-shadow: 0 4px 0 #a5560f; }
.btn.big:active { box-shadow: 0 1px 0 #a5560f; }
.btn.ghost { background: rgba(255, 255, 255, 0.08); box-shadow: none; font-weight: 700; }

.levels-title { margin: 20px 0 8px; font-weight: 800; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lvl {
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  background: rgba(47, 127, 224, 0.35);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
}
.lvl b { font-size: 18px; }
.lvl small { font-size: 10px; color: var(--gold); letter-spacing: -1px; }
.lvl small i, .stars i { font-style: normal; color: rgba(255, 255, 255, 0.2); }
.lvl.done { background: rgba(47, 127, 224, 0.6); }
.lvl.locked { background: rgba(255, 255, 255, 0.06); cursor: default; }
.lvl.locked small { visibility: hidden; }

.menu-foot { display: flex; justify-content: space-between; margin-top: 16px; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 4px; }

.stars { font-size: 40px; color: var(--gold); letter-spacing: 4px; }
.help { text-align: left; padding-left: 18px; margin: 0 0 12px; color: #d8e3ec; font-size: 14px; line-height: 1.45; }
.help li { margin-bottom: 8px; }

/* ---------- impacto ---------- */
#combo {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 64px);
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  color: hsl(calc(45deg - var(--h, 0deg)), 100%, 60%);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), 0 0 12px rgba(255, 120, 0, 0.5);
}
#combo b { font-size: 34px; font-weight: 900; }
#combo small { font-size: 11px; font-weight: 900; letter-spacing: 2px; color: #fff; }
#combo.pop b { animation: pop 0.18s ease-out; }
@keyframes pop { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }

#banner {
  position: absolute;
  left: 0; right: 0; top: 30%;
  text-align: center;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffd84d;
  text-shadow: 0 4px 0 #a5560f, 0 0 24px rgba(255, 200, 0, 0.6);
  animation: banner 1.8s ease-out forwards;
}
#banner.boss { color: #ff4d4d; text-shadow: 0 4px 0 #5a0f0f, 0 0 26px rgba(255, 0, 0, 0.6); font-size: 54px; }
@keyframes banner {
  0% { transform: scale(2.2); opacity: 0; }
  15% { transform: scale(1); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.9) translateY(-20px); opacity: 0; }
}

.end-pct { margin: 6px 0 4px; }
.end-pct b { display: block; font-size: 52px; font-weight: 900; color: #ffd84d; line-height: 1.1; }
.end-pct .bar { height: 10px; margin: 8px 12px; }
.end-pct .bar div { height: 100%; background: linear-gradient(90deg, #5aa9ff, #ffcf4d); border-radius: 5px; }
.end-pct small { color: var(--muted); font-size: 13px; }

/* ---------- moedas e loja ---------- */
.coins-pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 207, 77, 0.15);
  color: var(--gold);
  font-weight: 900;
  font-size: 15px;
  margin-bottom: 10px;
}
.shop-btn { position: relative; background: linear-gradient(#3d4a5c, #2b3544); box-shadow: 0 4px 0 #161c25; color: var(--gold); }
.shop-btn:active { box-shadow: 0 1px 0 #161c25; }
.badge {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #ff3b3b; color: #fff; font-size: 13px; line-height: 22px;
  animation: pulse 1s ease-in-out infinite;
}
.end-coins { font-size: 22px; font-weight: 900; color: var(--gold); margin: 4px 0 6px; }
.end-coins small { font-size: 12px; color: var(--muted); }
.end-coins span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }

.shop-panel { max-width: 420px; text-align: left; }
.shop-head { display: flex; align-items: center; justify-content: space-between; }
.shop-head h2 { margin: 0; }
.shop-head .coins-pill { margin: 0; }
.shop-title { margin: 16px 0 8px; font-weight: 800; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.shop-weapons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wcard {
  position: relative;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  display: flex; flex-direction: column; gap: 4px;
}
.wcard.eq { border-color: var(--wc); background: rgba(255, 255, 255, 0.09); }
.wcard b { font-size: 15px; }
.wcard p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.3; min-height: 42px; }
.wtrace { height: 6px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--wc), #fff); box-shadow: 0 0 10px var(--wc); }
.stat { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }
.stat span { width: 52px; }
.stat i { flex: 1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.stat u { display: block; height: 100%; background: var(--wc); }
.btn.small { padding: 8px; font-size: 13px; margin-top: 4px; box-shadow: 0 3px 0 #1b4f8f; }
.btn.small.buy { background: linear-gradient(#ffd96b, #f5a623); color: #3a2200; box-shadow: 0 3px 0 #a5560f; }
.btn:disabled { opacity: 0.45; cursor: default; }
.urow { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); margin-bottom: 6px; }
.uicon { font-size: 26px; width: 36px; text-align: center; }
.uinfo { flex: 1; min-width: 0; }
.uinfo b { font-size: 14px; }
.uinfo b small { color: var(--muted); font-weight: 600; }
.uinfo p { margin: 2px 0 4px; font-size: 11px; color: var(--muted); }
.uinfo em { color: #7dffb0; font-style: normal; }
.pips { display: flex; gap: 3px; }
.pips i { flex: 1; height: 5px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); }
.pips i.on { background: var(--gold); }
.urow .btn.small { width: 92px; margin: 0; }
