:root {
  --bg: #0d0d11;
  --cyan: #00f0ff;
  --magenta: #ff2d78;
  --violet: #a300ff;
  --panel: rgba(10, 12, 24, 0.72);
  --border: rgba(0, 240, 255, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #000;
  color: #e8f6ff;
  font-family: "Segoe UI", "Rajdhani", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: url("images/background.jpeg") center/cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
#stage::after { /* darken edges for readability */
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
}

/* ---- Preloader (splash + barra de carga) ---- */
#preloader {
  position: absolute; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  /* Color sólido instantáneo + splash encima (cubre la carga lenta del fondo) */
  background: #0d0d11 url("images/splash.webp") center / cover no-repeat;
  transition: opacity .45s ease;
}
#preloader.done { opacity: 0; pointer-events: none; }
#preload-track {
  width: min(320px, 72vw); height: 10px; border-radius: 6px;
  background: rgba(0,0,0,0.55); border: 1.5px solid var(--cyan); overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.8), 0 0 10px rgba(0,240,255,0.5);
}
#preload-bar {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta));
  box-shadow: 0 0 12px var(--cyan); transition: width .2s ease;
}
#preload-pct {
  font-size: 12px; letter-spacing: 3px; font-weight: 700;
  color: var(--cyan); opacity: .85; text-shadow: 0 0 8px rgba(0,240,255,0.6);
}
/* En vertical (móvil/tablet) usar el splash vertical (solo cambia la imagen;
   color, position, size y repeat del shorthand base se conservan). */
@media (orientation: portrait) {
  #preloader { background-image: url("images/splash_vertical.webp"); }
}

/* ---- VoltEdge energy meter ---- */
#energy {
  position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
  z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}

/* ---- Voltium HUD (cosmetic currency counter) ---- */
#voltium-hud {
  position: absolute; top: 16px; right: 18px; z-index: 11;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 8px; border-radius: 22px;
  background: rgba(8,16,28,0.7); border: 1.5px solid rgba(60,170,230,0.6);
  box-shadow: 0 0 14px rgba(40,150,220,0.35); backdrop-filter: blur(3px);
}
#voltium-hud #voltium-icon {
  width: 30px; height: 30px; object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(60,180,240,0.8));
}
#voltium-hud #voltium-count {
  color: #bfe9ff; font-weight: 800; font-size: 18px; min-width: 18px;
  text-shadow: 0 0 8px rgba(60,180,240,0.7);
}
#voltium-hud.bump { animation: vbump .45s ease-out; }
@keyframes vbump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); box-shadow: 0 0 22px rgba(60,180,240,0.9); }
  100% { transform: scale(1); }
}

#voltium-hud { cursor: pointer; }
/* Flying coin layer + individual coins.
   z-index above the board (2), win banner (7) and big/mega overlay (8) so the
   coin always flies in front on its way to the wallet HUD. */
#voltium-fly { position: absolute; inset: 0; z-index: 11; pointer-events: none; }

/* ---- Mini-shop (slide-in from right) ---- */
#shop-overlay {
  position: absolute; inset: 0; z-index: 14;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(1px);
}
#shop-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(380px, 86vw);
  z-index: 15; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0b1320, #0a0f18);
  border-left: 2px solid rgba(60,170,230,0.6);
  box-shadow: -8px 0 30px rgba(0,0,0,0.6);
  transform: translateX(100%); transition: transform .32s cubic-bezier(.2,.9,.3,1);
}
#shop-panel.open { transform: translateX(0); }
.shop-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px; border-bottom: 1px solid rgba(60,120,170,0.35);
}
.shop-title { font-weight: 800; letter-spacing: 3px; color: #cfeeff; font-size: 18px; }
.shop-balance { margin-left: auto; display: flex; align-items: center; gap: 6px; color: #bfe9ff; font-weight: 700; }
.shop-balance img { width: 22px; height: 22px; }
#shop-close {
  background: transparent; border: 0; color: #9fb3c8; font-size: 20px; cursor: pointer; padding: 4px 6px;
}
#shop-close:hover { color: #fff; }
#shop-body { overflow-y: auto; padding: 12px 14px 24px; }

.shop-cat-title { color: #7ad0ff; font-size: 12px; letter-spacing: 2px; margin: 14px 4px 8px; }
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shop-item {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(80,120,160,0.4);
  border-radius: 12px; padding: 10px; text-align: center; position: relative;
}
.shop-item img { width: 64px; height: 64px; object-fit: contain; }
.shop-item .si-name { color: #e8f6ff; font-size: 12px; font-weight: 700; margin-top: 4px; }
.shop-item .si-price { color: #ffd11a; font-size: 13px; font-weight: 800; margin-top: 4px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.shop-item .si-price img { width: 16px; height: 16px; }
.shop-item.premium { border-color: rgba(255,200,40,0.7); box-shadow: 0 0 14px rgba(255,200,40,0.25); }
.shop-item.premium .si-badge { position: absolute; top: 6px; right: 6px; font-size: 9px; color: #ffd11a; letter-spacing: 1px; }
.shop-item .si-btn {
  margin-top: 8px; width: 100%; padding: 6px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--cyan); background: #0d1828; color: #bfe9ff; font-weight: 700; font-size: 12px;
}
.shop-item .si-btn:hover { box-shadow: 0 0 10px var(--cyan); }
.shop-item.owned .si-btn { border-color: #3ce678; color: #3ce678; }
.shop-item.equipped .si-btn { background: #15351f; border-color: #3ce678; color: #aaffcc; cursor: default; }

/* Purchase confirmation popup */
#buy-confirm {
  position: absolute; inset: 0; z-index: 16;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6);
}
/* id selectors beat the .hidden class, so override hidden explicitly */
#buy-confirm.hidden, #shop-panel.hidden, #shop-overlay.hidden,
#dev-menu.hidden { display: none; }
#buy-confirm .bc-box {
  width: min(320px, 84vw); background: #0c1422; border: 1.5px solid var(--cyan);
  border-radius: 14px; padding: 20px; text-align: center;
  box-shadow: 0 0 30px rgba(0,240,255,0.25);
}
#buy-confirm .bc-box img#bc-icon { width: 80px; height: 80px; object-fit: contain; }
#buy-confirm .bc-text { color: #e8f6ff; font-size: 16px; margin-top: 10px; }
#buy-confirm .bc-price { color: #ffd11a; font-weight: 800; font-size: 18px; margin-top: 6px; display: flex; align-items: center; justify-content: center; gap: 6px; }
#buy-confirm .bc-price img { width: 20px; height: 20px; }
#buy-confirm .bc-actions { display: flex; gap: 10px; margin-top: 16px; }
.bc-btn { flex: 1; padding: 10px; border-radius: 8px; cursor: pointer; font-weight: 700; border: 1px solid; }
.bc-btn.cancel { background: #1a1020; border-color: #555; color: #ccc; }
.bc-btn.ok { background: #14251a; border-color: #3ce678; color: #aaffcc; }
.bc-btn.ok:hover { box-shadow: 0 0 12px rgba(60,230,120,0.6); }
.bc-btn[disabled], .bc-btn.disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.bc-btn[disabled]:hover { box-shadow: none; }
.vcoin {
  position: absolute; width: 54px; height: 54px;
  background-position: center; background-repeat: no-repeat; background-size: contain;
  filter: drop-shadow(0 0 10px rgba(60,180,240,0.9));
  will-change: transform, opacity;
}
#energy .energy-bolt {
  font-size: 20px; color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan), 0 0 16px var(--cyan);
}
#energy .energy-track {
  width: 16px; height: 240px; border-radius: 9px;
  background: rgba(0,0,0,0.5);
  border: 1.5px solid var(--cyan);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.8),
              0 0 6px var(--cyan), 0 0 14px rgba(0,240,255,0.6);
  display: flex; align-items: flex-end; overflow: hidden;
  animation: neonbar 2.2s ease-in-out infinite alternate;
}
@keyframes neonbar {
  from { box-shadow: inset 0 0 10px rgba(0,0,0,0.8), 0 0 5px var(--cyan), 0 0 10px rgba(0,240,255,0.45); }
  to   { box-shadow: inset 0 0 10px rgba(0,0,0,0.8), 0 0 9px var(--cyan), 0 0 20px rgba(0,240,255,0.8); }
}
#energy #energy-fill {
  width: 100%; height: 0%;
  background: linear-gradient(to top, var(--cyan), var(--violet), var(--magenta));
  box-shadow: 0 0 12px var(--cyan), 0 0 22px rgba(255,45,120,0.5);
  filter: saturate(1.3) brightness(1.15);
  transition: height .35s cubic-bezier(.2,1,.3,1);
}
#energy .energy-caption {
  font-size: 9px; letter-spacing: 2px; color: var(--cyan); opacity: .7;
  writing-mode: vertical-rl; text-orientation: upright;
}
#energy.ready .energy-track { border-color: var(--magenta); box-shadow: 0 0 18px var(--magenta); }
#energy.ready #energy-fill { background: linear-gradient(to top, var(--magenta), #fff); animation: surgeready .6s ease-in-out infinite alternate; }
#energy.ready .energy-bolt { color: var(--magenta); text-shadow: 0 0 14px var(--magenta); animation: surgeready .5s ease-in-out infinite alternate; }
#energy.ready .energy-caption { color: var(--magenta); opacity: 1; }
@keyframes surgeready { from { filter: brightness(1); } to { filter: brightness(1.6); } }

/* Surge lightning bolt traveling to the spin button */
.surge-bolt {
  position: absolute; left: 0; top: 0; z-index: 10;
  font-size: 40px; line-height: 1; pointer-events: none;
  margin: -20px 0 0 -20px;        /* center the glyph on its coordinate */
  color: #fff;
  text-shadow: 0 0 10px var(--cyan), 0 0 22px var(--magenta), 0 0 40px var(--violet);
}
/* Spin button armed (Surge ready): a diffuse yellow "charged" glow behind the
   button (radial) plus a shape-following drop-shadow. No square box-shadow. */
#spin-btn { position: relative; }
#spin-btn.surge-ready {
  border-color: transparent;
  animation: surgearmed .8s ease-in-out infinite alternate;
}
#spin-btn.surge-ready::before {
  content: ""; position: absolute; inset: -50%; border-radius: 50%;
  /* Usa el color del rayo equipado (--ray-rgb); dorado como fallback. */
  background: radial-gradient(circle,
    rgba(var(--ray-rgb, 255,214,40), 0.62),
    rgba(var(--ray-rgb, 255,170,0), 0.30) 45%, transparent 70%);
  filter: blur(10px); z-index: -1; pointer-events: none;
  animation: surgeglow .8s ease-in-out infinite alternate;
}
@keyframes surgearmed {
  from { filter: drop-shadow(0 0 10px var(--ray, #ffd11a)) drop-shadow(0 0 20px rgba(var(--ray-rgb, 255,209,26), 0.7)); }
  to   { filter: drop-shadow(0 0 20px var(--ray, #ffe23d)) drop-shadow(0 0 40px rgba(var(--ray-rgb, 255,209,26), 0.95)) drop-shadow(0 0 66px rgba(var(--ray-rgb, 255,170,0), 0.5)); }
}
@keyframes surgeglow {
  from { opacity: .5; transform: scale(.9); }
  to   { opacity: 1; transform: scale(1.18); }
}

/* Spin button flash when the surge bolt arrives (shape-following, no square) */
#spin-btn.surge-flash {
  animation: spinflash .5s ease-out;
}
@keyframes spinflash {
  0%   { filter: brightness(2.2) drop-shadow(0 0 24px #fff) drop-shadow(0 0 44px var(--magenta)); }
  100% { filter: brightness(1) drop-shadow(0 0 12px var(--magenta)); }
}

/* ---- Developer debug menu ---- */
#dev-panel { position: absolute; top: 12px; left: 12px; z-index: 9; }
#dev-toggle {
  background: rgba(8,10,20,0.85); color: var(--cyan);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; letter-spacing: 1px; font-weight: 700;
  padding: 6px 10px; cursor: pointer;
}
#dev-toggle:hover { box-shadow: 0 0 10px var(--cyan); }
#dev-menu {
  margin-top: 6px; display: flex; flex-direction: column; gap: 4px;
  background: rgba(8,10,20,0.95); border: 1px solid var(--magenta);
  border-radius: 8px; padding: 8px; box-shadow: 0 0 16px rgba(255,45,120,0.4);
}
.dev-opt {
  text-align: left; background: #0d0d11; color: #e8f6ff;
  border: 1px solid rgba(0,240,255,0.25); border-radius: 5px;
  padding: 7px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.dev-opt:hover { border-color: var(--magenta); box-shadow: 0 0 8px var(--cyan); }

/* ---- Rain layer (between background and HUD) ---- */
#rain-layer {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
}
#rain-layer canvas { width: 100%; height: 100%; display: block; }

/* Procedural lightning overlay */
#fxbolt {
  position: absolute; inset: 0; z-index: 9; pointer-events: none;
}

/* ---- Big / Mega win overlay ---- */
#bigwin {
  position: absolute; inset: 0; z-index: 8;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
#bigwin .bigwin-glow {
  position: absolute; width: 90vmin; height: 90vmin; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,45,120,0.35), rgba(163,0,255,0.18) 45%, transparent 70%);
  animation: bwglow 1.4s ease-in-out infinite alternate;
}
@keyframes bwglow { from { transform: scale(.8); opacity:.6; } to { transform: scale(1.15); opacity:1; } }
#bigwin .bigwin-title {
  --neon: var(--cyan);            /* single neon color (cyan for BIG) */
  position: relative;
  font-weight: 900; letter-spacing: 6px;
  font-size: clamp(40px, 9vw, 110px);
  color: transparent;             /* hollow letters */
  -webkit-text-stroke: 2.5px var(--neon);
  text-stroke: 2.5px var(--neon);
  /* glow follows the stroke; last layer is a dark shadow for separation */
  filter:
    drop-shadow(0 0 4px var(--neon))
    drop-shadow(0 0 12px var(--neon))
    drop-shadow(0 0 22px var(--neon))
    drop-shadow(0 3px 5px rgba(0,0,0,0.9));
  transform: scale(.3); opacity: 0;
}
#bigwin.mega .bigwin-title { --neon: var(--magenta); }  /* magenta for MEGA */
#bigwin .bigwin-amount {
  position: relative; margin-top: 8px;
  font-weight: 800; font-size: clamp(26px, 5vw, 56px); color: #fff;
  text-shadow: 0 0 12px var(--cyan), 0 0 26px var(--cyan);
  transform: scale(.6); opacity: 0;
}
#bigwin.show .bigwin-title { animation: bwpop .6s cubic-bezier(.2,1.6,.4,1) forwards, bwpulse 1.2s .6s ease-in-out infinite alternate; }
#bigwin.show .bigwin-amount { animation: bwpop .5s .15s cubic-bezier(.2,1.6,.4,1) forwards; }
#bigwin.mega .bigwin-glow {
  background: radial-gradient(circle, rgba(255,220,0,0.4), rgba(255,45,120,0.22) 45%, transparent 70%);
}
@keyframes bwpop { to { transform: scale(1); opacity: 1; } }
@keyframes bwpulse {
  from {
    filter: drop-shadow(0 0 3px var(--neon)) drop-shadow(0 0 9px var(--neon))
            drop-shadow(0 3px 5px rgba(0,0,0,0.9));
  }
  to {
    filter: drop-shadow(0 0 6px var(--neon)) drop-shadow(0 0 18px var(--neon))
            drop-shadow(0 0 34px var(--neon)) drop-shadow(0 3px 5px rgba(0,0,0,0.9));
  }
}

/* ---- Top HUD ---- */
#hud-top {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
}
.brand-logo {
  position: relative; z-index: 1;
  height: 120px; width: auto; max-width: 60vw;
  /* Neon glow that follows the logo's own shape (drop-shadow respects alpha),
     pulsing between cyan and magenta. */
  animation: logoNeon 2.4s ease-in-out infinite alternate;
}
@keyframes logoNeon {
  from {
    filter: drop-shadow(0 0 6px rgba(0,240,255,0.9))
            drop-shadow(0 0 14px rgba(0,240,255,0.6))
            drop-shadow(0 0 22px rgba(0,240,255,0.35));
  }
  to {
    filter: drop-shadow(0 0 8px rgba(255,45,120,0.9))
            drop-shadow(0 0 18px rgba(255,45,120,0.6))
            drop-shadow(0 0 30px rgba(255,45,120,0.4));
  }
}

#win-banner {
  position: absolute; top: 50%; left: 50%; z-index: 7;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 64px; font-weight: 900; color: #fff;
  text-shadow: 0 0 14px var(--magenta), 0 0 40px var(--violet);
  opacity: 0; transition: all .35s cubic-bezier(.2,1.4,.4,1);
  pointer-events: none;
}
#win-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#win-banner::before { content: "+"; }

/* ---- Reels ---- */
#machine {
  position: relative; z-index: 2;
  flex: 1;
  display: flex; align-items: center; justify-content: center;
}
#reels-wrap {
  width: min(58vw, 60vh);
  aspect-ratio: 1 / 1;
  padding: 14px;
  background: var(--panel);
  border: 2.5px solid #29b6ff;
  border-radius: 14px;
  backdrop-filter: blur(2px);
  animation: boxelectric 7s linear infinite;
}
/* electric border cycling yellow -> electric blue -> purple */
@keyframes boxelectric {
  0%, 100% { border-color: #ffd11a;
    box-shadow: 0 0 22px rgba(255,209,26,0.45), inset 0 0 40px rgba(0,0,0,0.6); }
  33% { border-color: #29b6ff;
    box-shadow: 0 0 24px rgba(41,182,255,0.5), inset 0 0 40px rgba(0,0,0,0.6); }
  66% { border-color: #a300ff;
    box-shadow: 0 0 24px rgba(163,0,255,0.5), inset 0 0 40px rgba(0,0,0,0.6); }
}
#reels-wrap canvas { width: 100%; height: 100%; display: block; }

/* ---- Bottom HUD ---- */
#hud-bottom {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  gap: 18px;
  padding: 16px 22px;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
}
.meter { text-align: center; min-width: 92px; }
.meter label {
  display: block; font-size: 11px; letter-spacing: 2px;
  color: var(--cyan); opacity: .8;
}
.meter .value {
  font-size: 24px; font-weight: 700; color: #fff;
  text-shadow: 0 0 8px rgba(0,240,255,0.5);
}

/* Image-based controls from controls.svg */
.ctrl {
  border: 0; background: transparent no-repeat center / contain;
  cursor: pointer; padding: 0;
  transition: transform .12s, filter .2s;
  filter: drop-shadow(0 0 6px rgba(0,240,255,0.35));
}
.ctrl:hover { filter: drop-shadow(0 0 12px var(--cyan)) drop-shadow(0 0 14px var(--magenta)); }
.ctrl:active { transform: scale(0.93); }
.ctrl:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.ctrl-bet  { width: 58px; height: 92px; }
.ctrl-spin { width: 118px; height: 118px; }
.ctrl-auto { width: 132px; height: 70px; }
.ctrl-auto.on { filter: drop-shadow(0 0 14px var(--magenta)); animation: autoglow .9s ease-in-out infinite alternate; }
@keyframes autoglow { from { transform: scale(1);} to { transform: scale(1.04);} }
.ctrl-spin.spinning { animation: spinpulse .7s ease-in-out infinite alternate; }
@keyframes spinpulse {
  from { filter: drop-shadow(0 0 6px var(--cyan)); transform: scale(1); }
  to   { filter: drop-shadow(0 0 18px var(--magenta)); transform: scale(1.06); }
}

/* Auto Spin count selector */
.auto-wrap { position: relative; display: flex; align-items: center; }
.auto-menu {
  position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  background: rgba(8,10,20,0.95); border: 1px solid var(--magenta);
  border-radius: 10px; box-shadow: 0 0 18px rgba(255,45,120,0.5); z-index: 6;
}
.auto-menu-title { font-size: 10px; letter-spacing: 2px; color: var(--cyan); text-align: center; }
.auto-opt {
  min-width: 64px; padding: 7px 10px; border-radius: 6px; cursor: pointer;
  background: #0d0d11; border: 1px solid var(--border); color: #fff;
  font-weight: 700; font-size: 15px; transition: all .15s;
}
.auto-opt:hover { box-shadow: 0 0 12px var(--cyan); border-color: var(--magenta); }
.auto-count {
  position: absolute; top: -6px; right: -6px;
  background: var(--magenta); color: #fff; font-weight: 800; font-size: 13px;
  min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 10px var(--magenta); pointer-events: none;
}

.chip {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: 2px solid var(--border);
  color: #fff; font-size: 20px; cursor: pointer;
  transition: all .15s;
}
.chip:hover { box-shadow: 0 0 12px var(--cyan); }
.chip:active { transform: scale(0.92); }

.hidden { display: none; }

/* toast for messages (insufficient funds, errors) */
#toast {
  position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); border: 1px solid var(--magenta);
  color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 5;
  box-shadow: 0 0 16px var(--magenta); font-size: 15px;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
#toast.show { opacity: 1; }

/* ---- Free spins welcome overlay (operator promotion) ---- */
#fs-overlay {
  position: absolute; inset: 0; z-index: 16;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.72); backdrop-filter: blur(3px);
}
#fs-overlay.hidden { display: none; }
#fs-overlay .fs-box {
  width: min(420px, 88vw); text-align: center; padding: 32px 28px;
  background: radial-gradient(circle at 50% 0%, #1a2740, #0b1018);
  border: 2px solid var(--cyan); border-radius: 18px;
  box-shadow: 0 0 40px rgba(0,240,255,0.35);
}
#fs-overlay .fs-bolt { font-size: 54px; filter: drop-shadow(0 0 16px var(--cyan)); animation: fsbolt 1s ease-in-out infinite alternate; }
@keyframes fsbolt { from { transform: scale(1); } to { transform: scale(1.12); } }
#fs-overlay .fs-title {
  font-weight: 800; letter-spacing: 2px; font-size: 22px; margin-top: 6px;
  color: #fff; text-shadow: 0 0 12px var(--cyan);
}
#fs-overlay .fs-amount {
  margin-top: 14px; font-size: 40px; font-weight: 900;
  color: var(--magenta); text-shadow: 0 0 16px var(--magenta);
}
#fs-overlay .fs-amount span:first-child { color: #fff; }
#fs-overlay .fs-bet { margin-top: 6px; color: #9fe9ff; font-size: 14px; }
#fs-overlay .fs-expiry { margin-top: 4px; color: #ffd11a; font-size: 12px; min-height: 14px; }
#fs-overlay .fs-actions { display: flex; gap: 12px; margin-top: 22px; }
.fs-btn { flex: 1; padding: 12px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 14px; border: 1px solid; }
.fs-btn.later { background: transparent; border-color: rgba(255,255,255,0.3); color: #ccc; }
.fs-btn.now { background: var(--cyan); border-color: var(--cyan); color: #04222a; }
.fs-btn.now:hover { box-shadow: 0 0 16px var(--cyan); }

/* Free spins active badge */
#fs-badge {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  z-index: 6; background: rgba(8,16,28,0.85); border: 1.5px solid var(--magenta);
  color: #fff; padding: 6px 16px; border-radius: 16px; font-weight: 700; font-size: 14px;
  box-shadow: 0 0 14px rgba(255,45,120,0.5); pointer-events: none;
}
#fs-badge.hidden { display: none; }
#fs-badge span:first-child { color: var(--magenta); }

/* =========================================================================
   RESPONSIVE — móvil y tablet
   El canvas de Pixi tiene resolución interna fija (760×760) y se escala por
   CSS (canvas { width:100% }), así que toda la adaptación es CSS: no toca el
   render ni la lógica de juego.
   ========================================================================= */

/* Altura real del viewport en móvil (evita el salto de la barra del navegador) */
@supports (height: 100dvh) {
  #stage { height: 100dvh; }
}

/* Sin highlight azul al tocar; sin delay de 300 ms ni zoom por doble-tap */
body { -webkit-tap-highlight-color: transparent; }
.ctrl, .chip, #spin-btn, #bet-up, #bet-down, #auto-btn, #mute-btn,
.dev-opt, .auto-opt, .si-btn, .bc-btn, .fs-btn, #shop-close, #voltium-hud, #dev-toggle {
  touch-action: manipulation;
}

/* En táctil el hover no debe dejar el glow "pegado" tras soltar */
@media (hover: none) {
  .ctrl:hover { filter: drop-shadow(0 0 6px rgba(0,240,255,0.35)); }
  .chip:hover, #dev-toggle:hover, .si-btn:hover, .auto-opt:hover { box-shadow: none; }
}

/* ---- TABLET / móvil grande: hasta 1024px ---- */
@media (max-width: 1024px) {
  .brand-logo { height: 88px; }
  #hud-bottom { gap: 14px; padding: 14px 16px; }
  .ctrl-bet  { width: 50px; height: 78px; }
  .ctrl-spin { width: 100px; height: 100px; }
  .ctrl-auto { width: 110px; height: 58px; }
  .meter { min-width: 74px; }
  .meter .value { font-size: 21px; }
  #reels-wrap { width: min(72vw, 60vh); }
  #energy .energy-track { height: 200px; }
}

/* ---- MÓVIL VERTICAL: hasta 600px de ancho ---- */
@media (max-width: 600px) {
  #hud-top { padding: 8px; }
  .brand-logo { height: 50px; max-width: 70vw; }

  /* Rodillos: dejar hueco a la izquierda para la barra Surge, sin solaparse */
  #machine { padding: 0 6px; }
  #reels-wrap { width: min(82vw, 46vh); padding: 7px; border-radius: 11px; }

  /* Barra Surge: fina y pegada a la izquierda */
  #energy { left: 4px; gap: 4px; }
  #energy .energy-bolt { font-size: 14px; }
  #energy .energy-track { width: 10px; height: 120px; }
  #energy .energy-caption { font-size: 7px; letter-spacing: 1px; }

  /* HUD superior secundario más compacto */
  #voltium-hud { top: 8px; right: 8px; padding: 4px 10px 4px 6px; gap: 5px; }
  #voltium-hud #voltium-icon { width: 22px; height: 22px; }
  #voltium-hud #voltium-count { font-size: 14px; }
  #dev-panel { top: 8px; left: 8px; }
  #dev-toggle { font-size: 10px; padding: 4px 7px; }

  /* HUD inferior en 2 filas con grid (el orden del DOM no cambia en desktop) */
  #hud-bottom {
    display: grid;
    align-items: center;
    justify-content: center;
    gap: 4px 8px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    grid-template-columns: auto auto auto auto auto;
    grid-template-areas:
      "bal  bal  bet  win  win"
      "mute bdn  spin bup  auto";
  }
  .meter.m-bal { grid-area: bal; }
  .meter.m-bet { grid-area: bet; }
  .meter.m-win { grid-area: win; }
  #mute-btn  { grid-area: mute; justify-self: center; }
  #bet-down  { grid-area: bdn;  justify-self: center; }
  #spin-btn  { grid-area: spin; justify-self: center; }
  #bet-up    { grid-area: bup;  justify-self: center; }
  .auto-wrap { grid-area: auto; justify-self: center; }

  .meter { min-width: 0; }
  .meter label { font-size: 9px; letter-spacing: 1px; }
  .meter .value { font-size: 17px; }

  .ctrl-bet  { width: 42px; height: 56px; }
  .ctrl-spin { width: 76px; height: 76px; }
  .ctrl-auto { width: 66px; height: 44px; }
  .chip { width: 38px; height: 38px; font-size: 17px; }

  /* Popups/insignias por encima del HUD de 2 filas */
  #toast { bottom: 150px; }
  #fs-badge { bottom: 132px; }
  .auto-menu { bottom: 56px; }

  #win-banner { font-size: 44px; }
  #dev-menu .dev-opt { font-size: 11px; padding: 6px 8px; }
}

/* ---- MÓVIL HORIZONTAL: poca altura ---- */
@media (max-height: 500px) and (orientation: landscape) {
  #hud-top { padding: 4px; }
  .brand-logo { height: 38px; }
  #reels-wrap { width: min(54vh, 56vw); padding: 6px; }
  #energy .energy-track { height: 104px; }
  #energy .energy-caption { display: none; }
  #hud-bottom { gap: 10px; padding: 6px 14px; }
  .ctrl-bet  { width: 38px; height: 54px; }
  .ctrl-spin { width: 70px; height: 70px; }
  .ctrl-auto { width: 84px; height: 44px; }
  .meter { min-width: 62px; }
  .meter .value { font-size: 18px; }
  .meter label { font-size: 9px; }
}
