#screen-game {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
}
.hud-hp {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-hp-bar {
  width: 120px;
  height: 14px;
  background: rgba(0,0,0,0.5);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}
.hud-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #6bffb0, #4dd8ff);
  transition: width 0.2s ease;
}
.hud-hp-text { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; }
.hud-coins { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--gold); }
.hud-center { text-align: center; }
.hud-wave-label { font-size: 0.7rem; color: var(--text-dim); letter-spacing: 1px; }
.hud-wave { font-size: 1.2rem; font-weight: 800; color: var(--purple); }
.hud-difficulty { font-size: 0.7rem; color: var(--text-dim); }
.hud-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.btn-icon {
  width: 38px; height: 38px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 1.1rem;
}

/* .game-stage centers the board and, in mobile-in-game/fullscreen mode, is
   given a bounded height by its parent so canvas-wrap (sized by main.js'
   fitStage()) can become the largest square that fits — not just as wide
   as the viewport, but as TALL as the freed-up space allows too. */
.game-stage {
  display: block;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(124,92,255,0.25);
  box-shadow: 0 0 40px rgba(124,92,255,0.12), inset 0 0 60px rgba(0,0,0,0.4);
  touch-action: none;
}
#game-canvas { width: 100%; height: 100%; display: block; }

.wave-banner {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 5;
}
.wave-banner .banner-main {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255,209,102,0.7), 0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 1px;
}
.wave-banner .banner-sub {
  margin-top: 4px;
  font-size: 0.95rem;
  color: var(--text);
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.wave-banner.pop { animation: bannerPop 0.4s ease; }
@keyframes bannerPop {
  0% { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.combo-badge {
  position: absolute;
  top: 4%;
  right: 4%;
  background: rgba(124,92,255,0.18);
  border: 1px solid rgba(124,92,255,0.6);
  color: var(--gold);
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  z-index: 5;
  pointer-events: none;
}
.combo-badge.pulse { animation: comboPulse 0.25s ease; }
@keyframes comboPulse { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }

.boss-bar-wrap {
  position: absolute;
  top: 4%;
  left: 8%;
  right: 8%;
  z-index: 6;
  text-align: center;
  pointer-events: none;
}
.boss-bar-name {
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--red);
  font-weight: 800;
  margin-bottom: 3px;
  text-shadow: 0 0 10px rgba(255,77,94,0.7);
}
.boss-bar-track {
  height: 12px;
  background: rgba(0,0,0,0.55);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,77,94,0.5);
}
.boss-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff4d5e, #ff8f5e);
}

/* Build Defense is now a real centered popup — same .modal-backdrop/
   .modal-box pattern as the WAVE COMPLETE upgrade modal (see index.php),
   living outside #canvas-wrap so its scrollable body isn't fighting that
   element's touch-action:none. .slot-modal-box only needs to add its own
   grid width/sizing on top of the shared .modal-box rules in ui.css. */
.slot-modal-box {
  max-width: 420px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.slot-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  background: inherit;
}
.slot-panel-head h3 { font-size: 1.05rem; color: var(--text); }
.slot-panel-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.slot-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 92px;
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--accent, rgba(255,255,255,0.15));
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  transition: transform 0.12s ease, background 0.12s ease;
}
.slot-option:not(:disabled):active { transform: scale(0.95); background: rgba(255,255,255,0.09); }
.slot-option:disabled { opacity: 0.35; }
.slot-option .slot-icon { font-size: 1.5rem; }
.slot-option .slot-name { font-weight: 700; font-size: 0.88rem; }
.slot-option .slot-desc { font-size: 0.72rem; color: var(--text-dim); line-height: 1.25; }
.slot-option .slot-cost {
  margin-top: 2px;
  font-size: 0.75rem; color: var(--gold); font-weight: 700;
  background: rgba(255,209,102,0.12);
  border-radius: 10px;
  padding: 2px 9px;
}
.slot-actions { grid-column: 1 / -1; display: flex; gap: 10px; }
.slot-actions button { flex: 1; padding: 14px; border-radius: 10px; font-weight: 700; min-height: 48px; }

/* Belt-and-suspenders body-scroll lock while the build/upgrade sheet is
   open (see ui.js showSlotPanel/hideSlotPanel) — harmless on desktop,
   prevents any double-scroll confusion on mobile. */
body.panel-open { overflow: hidden; }

.pause-overlay {
  position: absolute; inset: 0;
  background: rgba(6,6,16,0.85);
  z-index: 12;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.pause-box {
  background: var(--navy2, #10122a);
  border: 1px solid rgba(124,92,255,0.4);
  border-radius: 16px;
  padding: 24px 26px;
  min-width: 240px;
  display: flex; flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.pause-box h2 { font-size: 1.4rem; color: var(--gold); text-align: center; letter-spacing: 1px; }
.pause-toggles { display: flex; justify-content: center; gap: 10px; margin-bottom: 4px; }
/* Scoped to the two full-width action buttons only. A bare `.pause-box
   button` selector here previously matched EVERY button inside the popup,
   including the round 🔊/🎵/⛶ icon toggles above — its specificity beat
   .btn-icon's own width/height, stretching those circular buttons into
   flattened ovals (the "méo" — warped — icons reported after round 3). */
.pause-box .btn-primary,
.pause-box .btn-secondary { width: 100%; }

@media (max-width: 480px) {
  .hud-hp-bar { width: 84px; }
  .slot-panel-body { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 360px) {
  .btn-icon { width: 32px; height: 32px; font-size: 0.95rem; }
  .hud-hp-bar { width: 64px; }
  .hud { gap: 4px; padding: 8px 4px; }
  .hud-coins { font-size: 0.85rem; }
}

/* ===================== Fullscreen / mobile full-board mode =====================
   Two triggers share the exact same layout: body.game-fullscreen (the ⛶
   button, any screen size) and body.in-game under the mobile breakpoint
   (gameplay always gets the full viewport on phones, no explicit tap
   needed). Both hide the surrounding site chrome and let #screen-game take
   over the viewport as a column: HUD keeps its natural height, .game-stage
   gets whatever is left and centers canvas-wrap — which main.js's
   fitStage() then sizes in JS to the largest square that actually fits,
   using the freed-up height instead of just the viewport width. */
body.game-fullscreen .site-header,
body.game-fullscreen .ad-slot,
body.game-fullscreen .seo-content,
body.game-fullscreen .site-footer {
  display: none;
}
body.game-fullscreen #app-root { max-width: none; padding: 0; }
body.game-fullscreen #screen-game {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh;
  max-width: none; margin: 0;
  display: flex; flex-direction: column;
  background: var(--navy);
  z-index: 200;
}
body.game-fullscreen .game-stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
}
body.game-fullscreen .canvas-wrap { border-radius: 10px; }

@media (max-width: 700px) {
  body.in-game .site-header,
  body.in-game .ad-slot,
  body.in-game .seo-content,
  body.in-game .site-footer {
    display: none;
  }
  body.in-game #app-root { max-width: none; padding: 0; }
  body.in-game #screen-game {
    position: fixed; inset: 0;
    height: 100vh; height: 100dvh;
    max-width: none; margin: 0;
    display: flex; flex-direction: column;
    background: var(--navy);
    z-index: 30;
  }
  body.in-game .game-stage {
    flex: 1 1 auto; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 6px;
  }
  body.in-game .canvas-wrap { border-radius: 10px; }
}
