:root {
  --bg-top: #1a2350;
  --bg-bot: #0e1430;
  --bar: #232c5c;
  --bar-edge: #2e3a78;
  --txt: #eef2ff;
  --pill: #2b3670;
  --accent: #ffb020;
  --ad: #ff7a1a;
  --btn: #3a4790;
  --btn-hi: #4a59b0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  background: #05070f;
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}

#app {
  position: absolute;
  left: 50%; top: 50%;
  transform-origin: center center;
  /* size + transform set by JS */
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bot));
  overflow: hidden;
  border-radius: 2px;
}

/* ---- top bar ---- */
#topbar {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bar);
  border-bottom: 2px solid var(--bar-edge);
}
.iconbtn {
  width: 44px; height: 44px;
  border: none; border-radius: 12px;
  background: var(--btn);
  color: var(--txt);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.iconbtn:active { background: var(--btn-hi); }
#level-pill {
  background: var(--pill);
  padding: 8px 22px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
#score-pill {
  min-width: 64px;
  text-align: right;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  padding-right: 4px;
}

/* ---- stage ---- */
#stage {
  flex: 1 1 auto;
  position: relative;
}
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#shots-pill {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 6px 14px;
  border-radius: 999px;
  pointer-events: none;
  display: flex; align-items: center; gap: 6px;
}
#shots-pill.hidden { display: none; }
#shots-pill::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
}
#hint {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  max-width: 80%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#hint.show { opacity: 1; }

/* ---- gated tutorial mask (swap / bomb) ---- */
#tutorial-mask {
  position: absolute;
  inset: 0;
  background: rgba(6,9,20,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 32px;
  text-align: center;
  z-index: 40;
}
#tutorial-mask.hidden { display: none; }
#tutorial-text {
  font-size: 23px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  max-width: 82%;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

/* ---- bottom bar ---- */
#bottombar {
  height: 86px;
  flex: 0 0 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--bar);
  border-top: 2px solid var(--bar-edge);
}
.powerbtn {
  position: relative;
  min-width: 150px;
  height: 56px;
  border: none;
  border-radius: 14px;
  background: var(--btn);
  color: var(--txt);
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.powerbtn:active { background: var(--btn-hi); }
.powerbtn.armed {
  background: var(--accent);
  color: #2a1c00;
  box-shadow: 0 0 0 3px rgba(255,176,32,0.35);
}
.powerbtn:disabled { opacity: 0.45; cursor: default; }
.powerbtn.hint-pulse {
  animation: pw-pulse 1.1s ease-in-out infinite;
}
@keyframes pw-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,176,32,0.0); transform: translateY(0); }
  50%      { box-shadow: 0 0 0 6px rgba(255,176,32,0.5); transform: translateY(-3px); }
}
.pw-badge {
  position: absolute;
  top: -9px; right: -9px;
  min-width: 26px; height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--pill);
  border: 2px solid var(--bar);
  font-size: 14px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.pw-badge.ad {
  background: var(--ad);
  color: #fff;
  letter-spacing: 1px;
}

/* ---- overlays ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,9,20,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }
.overlay-card {
  background: linear-gradient(180deg, #2a3470, #1a2150);
  border: 2px solid var(--bar-edge);
  border-radius: 22px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0,0,0,0.55);
  min-width: 260px;
}
.stars {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}
.stars.hidden { display: none; }
.star {
  width: 46px; height: 46px;
  background: #1c2350;
  border: 2px solid #2e3a78;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.star.on { background: var(--accent); border-color: var(--accent); }
.overlay-title {
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 18px;
  letter-spacing: 0.5px;
}
.overlay-score {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 22px;
  font-variant-numeric: tabular-nums;
}
.overlay-score.hidden { display: none; }
.overlay-btn {
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #2a1c00;
  font-size: 24px;
  font-weight: 800;
  padding: 14px 46px;
  cursor: pointer;
}
.overlay-btn:active { filter: brightness(0.92); }
