:root { color-scheme: dark; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: #f0f0f0;
  overflow: hidden;
}
#app {
  /* Absolute-positioned children: #stage covers the full app, #hud/#controls overlay it.
     This lets balloons + bottom glow appear to come from BEHIND the controls panel. */
  height: 100vh; max-width: 600px; margin: 0 auto;
  position: relative;
  background: url('images/neonBG.webp') center / cover no-repeat;
  box-shadow:
    0 0 80px rgba(80, 200, 255, 0.35),
    inset 0 0 0 1px rgba(120, 220, 255, 0.18);
}
/* Blurred neon backdrop covering the rest of the viewport (visible on wide screens) */
/* Body's blurred neonBG backdrop — fixed pseudo-element so the blur doesn't cascade to children */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: url('images/neonBG.webp') center/cover no-repeat;
  filter: blur(28px);
  opacity: 1;
  transform: scale(1.1); /* hide the soft edges from the blur */
  z-index: -1;
}
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 10; /* over the canvas */
  height: 130px;
  margin: 6px auto 0;
  background: url('images/balancePanel.png') 90% no-repeat;
  background-size: cover;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 15%;
  box-sizing: border-box;
}
#hud > div { flex: 1; text-align: center; /* margin-top: 12px; */ }
#hud .label {
  font-size: 12px; opacity: 0.85; text-transform: uppercase; letter-spacing: 1.2px;
  color: #b8e8ff;
}
#hud .value {
  font-size: 25px; font-weight: 800; color: #ffffff;
  text-shadow: 0 0 8px rgba(80, 200, 255, 0.75);
}
#hud .win {
  color: #ffe066;
  text-shadow: 0 0 8px rgba(255, 200, 80, 0.75);
}
#stage {
  position: absolute; inset: 0; /* fill the entire #app, behind hud + controls */
  z-index: 1;
  overflow: hidden;
}
#stage canvas { display: block; width: 100%; height: 100%; }
/* When the bonus stage popup is active, lift the canvas above HUD/controls/guns
   so the popup truly covers the whole game like a separate scene. */
#app.bonus-active #stage { z-index: 100; }
#app.bonus-active #hud,
#app.bonus-active #controls,
#app.bonus-active #guns { pointer-events: none; }
#controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  z-index: 10; /* over the canvas */
  box-sizing: border-box;
  display: flex; align-items: stretch; justify-content: space-between;
  gap: 6px; background: transparent;
  height: 160px;
}
/* Gun rigs (leg + gun) anchored just above the controls bar */
#guns {
  position: absolute;
  left: 0; right: 0;
  bottom: 110px; /* lowered toward the bottom — partially overlaps the controls bar edges */
  height: 140px;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 8px; box-sizing: border-box;
  pointer-events: none;
  z-index: 5;
}
.gun-mount {
  position: relative;
  width: 100px;
  height: 100%;
}
.gun-leg {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 88%;
  height: auto;
  display: block;
}
.gun-mount.right .gun-leg { transform: translateX(-50%) scaleX(-1); }
.gun-mount .gun {
  position: absolute;
  bottom: 38%; /* sits on top of the leg's socket */
  left: 0;
  width: 100%;
  height: auto;
  display: block;
  transform-origin: 50% 50%; /* bolt-in-the-middle pivot — gun tilts like a turret */
  transform: rotate(-22deg);  /* front-up, back-down */
  transition: transform 0.22s cubic-bezier(0.2, 0.6, 0.2, 1);
  filter: drop-shadow(0 6px 18px rgba(80, 200, 255, 0.45));
}
.gun-mount.right .gun { transform: scaleX(-1) rotate(-22deg); }
.control-panel {
  flex: 1; height: 100%;
  background: url('images/contrtolsPanel.png') center / 120% 170% no-repeat;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  justify-items: center;
  padding: 0; gap: 0;
  box-sizing: border-box;
}
.slot {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.control-panel input#bet,
.control-panel button {
  background: transparent;
  border: none;
  color: #ffffff;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(80, 200, 255, 0.85);
  cursor: pointer;
  padding: 0;
  width: 78%; height: 60%;
  box-sizing: border-box;
  text-align: center;
  letter-spacing: 1px;
  font-family: inherit;
}
.control-panel #bet {
  font-size: 22px;
  -moz-appearance: textfield;
  width: auto; min-width: 0;
}
.bet-group {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 0 6px; box-sizing: border-box;
}
.bet-prefix {
  color: #b8e8ff;
  font-weight: 900; font-size: 22px;
  text-shadow: 0 0 8px rgba(80, 200, 255, 0.85);
  pointer-events: none;
}
.control-panel #bet { flex: 1; min-width: 0; max-width: 80px; }
.bet-arrows {
  display: flex; flex-direction: column; gap: 2px;
  flex-shrink: 0;
}
.bet-arrows button {
  background: rgba(8, 10, 24, 0.55);
  border: 1px solid rgba(120, 220, 255, 0.5);
  border-radius: 3px;
  color: #b8e8ff;
  width: 22px; height: 16px;
  padding: 0; line-height: 1;
  font-size: 9px;
  font-family: inherit;
  cursor: pointer;
  text-shadow: 0 0 4px rgba(80, 200, 255, 0.7);
  transition: background 0.1s, transform 0.08s;
}
.bet-arrows button:hover {
  background: rgba(80, 200, 255, 0.25);
}
.bet-arrows button:active { transform: scale(0.92); }
.control-panel #bet::-webkit-outer-spin-button,
.control-panel #bet::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.control-panel #spin {
  background: url('images/popBTN.webp') center/contain no-repeat;
  width: 95%; height: 95%;
  font-size: 0; /* hides the aria-label text without affecting screen readers */
  text-shadow: none;
  transition: transform 0.1s ease-out, filter 0.15s ease-out;
  filter: drop-shadow(0 0 8px rgba(255, 80, 200, 0.55));
  outline: none;
  -webkit-tap-highlight-color: transparent; /* kill mobile tap highlight */
}
.control-panel #spin:focus { outline: none; }
.control-panel #spin:hover { transform: scale(1.05); filter: drop-shadow(0 0 14px rgba(255, 120, 220, 0.85)); }
.control-panel #spin:active { transform: scale(0.94); }
.control-panel #spin:disabled { opacity: 0.45; cursor: not-allowed; filter: none; transform: none; }
/* Bonus-ready state: gold pulse, spell out it's not just a regular spin */
.control-panel #spin.bonus-ready {
  filter: drop-shadow(0 0 16px rgba(255, 215, 0, 1)) hue-rotate(20deg) brightness(1.15);
  animation: bonusPulse 0.9s ease-in-out infinite;
}
@keyframes bonusPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.10); }
}
.control-panel #mode {
  font-size: 13px;
  color: #b8e8ff;
  text-shadow: 0 0 8px rgba(80, 200, 255, 0.85);
}
.control-panel #mode.manual { color: #ffe066; text-shadow: 0 0 8px rgba(255, 200, 80, 0.85); }
/* Mute toggle as a circular icon button next to AUTO/MANUAL */
.slot.right { flex-direction: row; gap: 4px; padding: 0 4px; }
.slot.right #mode { flex: 1; min-width: 0; }
.mute-icon {
  flex-shrink: 0;
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(8, 10, 24, 0.55);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.35));
  transition: opacity 0.15s, transform 0.1s, filter 0.15s;
}
.mute-icon:hover  { transform: scale(1.1); filter: drop-shadow(0 0 10px rgba(255,255,255,0.7)); }
.mute-icon:active { transform: scale(0.9); }
.mute-icon.off    { opacity: 0.55; filter: none; }
.mute-icon svg    { display: block; width: 18px; height: 18px; fill: #ffffff; }
#mode:disabled { opacity: 0.45; cursor: not-allowed; }
#status {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55); padding: 6px 14px; border-radius: 16px;
  font-size: 12px; opacity: 0; transition: opacity 0.2s;
  pointer-events: none; white-space: nowrap;
  z-index: 10;
}
#status.show { opacity: 1; }
#status.error {
  top: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  color: #fff;
  font-size: 18px; font-weight: 800;
  padding: 18px 28px; border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.25);
  text-align: center; white-space: normal;
  max-width: 80%; line-height: 1.35;
  animation: errorPop 0.25s ease-out;
}
@keyframes errorPop {
  0%   { transform: translate(-50%, -50%) scale(0.85); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
/* Viewport-spanning layer for HTML coins flying from canvas balloons → HUD slots */
#coinsLayer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9999; /* above HUD panel and everything else */
  overflow: visible;
}
.flying-coin {
  position: absolute; top: 0; left: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff8d4 0%, #ffd166 38%, #c98800 100%);
  box-shadow:
    0 0 14px rgba(255, 209, 102, 0.85),
    inset 0 -3px 5px rgba(0, 0, 0, 0.35),
    inset 0 2px 3px rgba(255, 255, 255, 0.6);
  display: flex; align-items: center; justify-content: center;
  color: #6a3500;
  font-weight: 900; font-size: 18px; line-height: 1;
  font-family: Arial, sans-serif;
  will-change: transform, opacity;
}
.flying-coin::before { content: '$'; }
/* Sprite mode — using extracted frame from rotaitingCoinsV2.png */
.flying-coin.has-sprite {
  background-color: transparent;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 0;
  box-shadow: none;
  width: 40px; height: 40px;
}
.flying-coin.has-sprite::before { content: ''; }
/* Env badge — populated by client.js after /session/init. Hidden by default
   (prod), shown amber when env != production, always with the SHA chip. */
#env-badge {
  position: fixed; bottom: 6px; right: 6px;
  z-index: 9999;
  display: none;
  gap: 4px;
  font-family: ui-monospace, 'Segoe UI Mono', monospace;
  font-size: 10px; line-height: 1;
  pointer-events: none;
}
#env-badge.show { display: flex; }
#env-badge .chip {
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid;
  backdrop-filter: blur(4px);
}
#env-badge .chip.env {
  background: rgba(245, 158, 11, 0.85);
  color: #000;
  border-color: rgba(252, 211, 77, 1);
  font-weight: 700;
}
#env-badge .chip.sha {
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.1);
}
