#ambient-leaves {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0; /* push further behind everything, canvas wrapper/reel glow have higher z */
  overflow: hidden;
}
.ambient-leaf {
  position: absolute;
  top: -10%;
  width: clamp(24px, 3.9vw, 46px); /* slightly larger upper bound */
  height: auto;
  opacity: 0.85;
  will-change: transform;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
  animation: ambientLeafFade 1.2s ease forwards;
}
@keyframes ambientLeafFade { 0% { opacity:0; } 100% { opacity:.85; } }
/* Load a license-free Google webfont (Poppins) as a replacement for JungleAdventure */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;800&display=swap');

/* ====== CAPYBARA KING SLOT - Enhanced Multi-Platform CSS ====== */

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

body {
  font-family: Arial, sans-serif;
  background: url('assets/images/screen-bg.png') no-repeat center center fixed; /* Changed from main-bg */
  background-size: cover;
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 2vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.game-container {
  width: 100%;
  /* Allow the game area to expand to the viewport so the reel can fill horizontally */
  max-width: 100%;
  margin: 0 auto;
  padding: 8px; /* reduce padding so canvas can grow closer to edges */
  position: relative;
  margin-top: 12px;
}

.banner {
  width: clamp(180px, 25vw, 350px);
  max-width: 90vw;
  height: auto;
  /* Move the main logo slightly upward so a collector can sit visually beneath it */
  margin: -8px auto clamp(8px, 1.5vh, 15px);
  display: block;
  animation: logoFloat 3s ease-in-out infinite; /* ADDED: floating animation */
}

/* ADDED: Banner floating animation (matches login screen) */
@keyframes logoFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 100vw; /* allow full-bleed up to viewport width */
  background: transparent;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(0, 0, 0, 0.4);
  margin-bottom: clamp(12px, 2.2vh, 20px);
  transform: none;
  overflow: hidden;
  /* Keep an aspect hint but allow canvas sizing JS to control final pixel dimensions */
  min-height: 220px;
}
.canvas-wrapper::before,
.canvas-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.6s cubic-bezier(.2,.9,.2,1);
}
.canvas-wrapper::before {
  border: 2px solid rgba(255, 215, 0, 0.55);
  transform: scale(0.98);
}
.canvas-wrapper::after {
  box-shadow: 0 0 26px rgba(255, 215, 0, 0.45), 0 0 48px rgba(255, 173, 0, 0.35);
}
.canvas-wrapper.bonus-board-glow::before,
.canvas-wrapper.bonus-board-glow::after {
  opacity: 1;
}
.canvas-wrapper.bonus-board-glow::before {
  /* Remove the harsh outlined border when bonus board glow is active; use softer wash only */
  border: none;
  box-shadow: none;
  animation: none;
}
.canvas-wrapper.bonus-board-glow::after {
  animation: boardGlowWash 2.4s ease-in-out infinite;
}
@keyframes boardGlowRing {
  0%, 100% { transform: scale(0.98); opacity: 0.75; }
  50% { transform: scale(1.01); opacity: 1; }
}
@keyframes boardGlowWash {
  0%, 100% { box-shadow: 0 0 30px rgba(255,215,0,0.55), 0 0 60px rgba(255,188,40,0.35); }
  50% { box-shadow: 0 0 38px rgba(255,228,120,0.85), 0 0 80px rgba(255,188,40,0.5); }
}

#game-canvas {
  display: block;
  /* Use full width of the wrapper to avoid viewport overflow gaps */
  width: 100%;
  max-width: 100%;
  height: auto;
  background-color: transparent;
  border: none;
  border-radius: 12px; /* Match wrapper border radius */
  image-rendering: auto; /* let browser pick best sampling */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* ensure canvas scales cleanly when CSS size differs from backing buffer */
  display: block;
}

/* For any img elements used as reel overlays, prefer high-quality interpolation */
.canvas-wrapper img,
.canvas-wrapper .reel-symbol img {
  image-rendering: auto;
  -webkit-transform: translateZ(0); /* promote layer */
  transform: translateZ(0); /* promote layer - standard property for compatibility */
  backface-visibility: hidden;
}

.controls-layout {
	/* was: grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr); */
	/* make columns fluid: left/right columns scale but can shrink; center column grows */
	grid-template-columns:
		minmax(clamp(110px, 12vw, 260px), 1fr)
		minmax(clamp(160px, 28vw, 560px), 1fr)
		minmax(clamp(110px, 12vw, 260px), 1fr);
	gap: clamp(8px, 2.5vw, 32px);
  position: relative;
  min-height: auto;
  padding: 0 clamp(5px, 2vw, 20px);
  max-width: 100%;
  margin: 0 auto;
}

.stats-panel,
.actions-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 150px;
  width: 100%;
  max-width: none;
  min-width: 0;          /* allow panel to shrink below old hard limits */
  box-sizing: border-box;
}

.stats-panel {
  background: url('assets/images/board-bg.png?v=2') center center / contain no-repeat;
  background-size: 100% 100%;
  padding: clamp(14px, 4vw, 28px) clamp(12px, 3.5vw, 30px); /* slightly tighter to center text visually */
  border-radius: clamp(5px, 1.5vw, 10px);
  backdrop-filter: none;
  width: clamp(180px, 35vw, 320px);
  max-width: 320px;
  min-height: clamp(110px, 22vw, 160px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: static;
  grid-column: 1;
  justify-self: center;
  transform: none;
  top: 0;
}

.stat-item {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;    /* center the two columns within the panel */
  align-items: center;
  gap: clamp(4px, 1vw, 8px); /* responsive gap - gets smaller on small screens */
  width: 100%;
  padding: 0 clamp(4px, 1vw, 6px);
  margin-bottom: clamp(0px, 0.15vh, 1px);
  line-height: 1.04;
}

.stat-label {
  justify-self: end;
  text-align: right;
  min-width: clamp(42px, 11vw, 72px); /* smaller min width so label doesn't force spacing */
  padding-right: clamp(4px, 1vw, 8px);
  font-family: 'Poppins', Arial, sans-serif; /* replaced Naluka */
  color: #ffd700; /* keep label color */
  font-size: clamp(0.85em, 1.6vw, 1.02em); /* slightly smaller */
  letter-spacing: 0.4px;
}

.stat-value {
  justify-self: start;
  text-align: left;
  font-family: 'Poppins', Arial, sans-serif; /* replaced Naluka */
  color: #ffffff; /* keep value color */
  font-size: clamp(0.9em, 1.8vw, 1.08em); /* slightly smaller */
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.spin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 2vh, 15px);
  position: relative;
  z-index: 10;
  grid-column: 2;
  transform: translateY(0);
  align-self: center;
  width: 100%;
  max-width: none;
  min-width: 0;
  justify-self: center;
}

.btn-spin {
  /* restore legacy button footprint so artwork reads clearly */
	width: clamp(72px, 20vw, 200px);
	height: clamp(72px, 20vw, 200px);
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
  padding: 0;
  outline: none; /* Remove outline */
}

.btn-spin img {
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
  object-fit: contain;
}

.btn-spin:hover {
  transform: scale(1.05);
  filter: brightness(1.2) drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
  background: transparent; /* Ensure no background */
  border: none; /* Ensure no border */
}

.btn-spin:active {
  transform: scale(0.95);
}

.btn-spin:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-spin:focus {
  outline: none; /* Remove focus outline */
  border: none;
}

.bet-adjust-btn {
  width: clamp(54px, 12vw, 96px);
  height: clamp(54px, 12vw, 96px);
  background: none;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.bet-adjust-btn:focus {
  outline: none;
}
.bet-adjust-btn img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.bet-adjust-btn:active {
  transform: scale(0.94);
}

.btn-spin.pressed-glow img,
.bet-adjust-btn.pressed-glow img,
.btn-maxbet.pressed-glow img {
  filter: drop-shadow(0 0 16px rgba(255,215,0,0.65)) brightness(1.1);
}

.btn-autospin.pressed-glow,
.btn-action.pressed-glow,
.settings-action-btn.pressed-glow {
  filter: drop-shadow(0 0 16px rgba(255,215,0,0.6)) brightness(1.1);
}

.btn-autospin {
  /* make autospin prominent and closer to its legacy footprint */
  width: clamp(110px, 24vw, 260px);
  height: clamp(110px, 24vw, 260px);
  min-width: clamp(96px, 18vw, 140px);
  min-height: clamp(96px, 18vw, 140px);
  max-width: 280px;
  max-height: 280px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: clamp(4px, 1.5vw, 8px);
  margin-top: 0;
  outline: none;
}

.btn-autospin:hover {
  transform: scale(1.05);
  filter: brightness(1.2) drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
  background: transparent;
  border: none;
}

.btn-autospin:focus {
  outline: none;
  border: none;
}

.autospin-img {
  width: 100%;
  height: 100%;
  display: block;
  transition: transform 0.3s, filter 0.3s;
  margin: 0;
  object-fit: contain;
}

.btn-autospin:hover .autospin-img {
  transform: scale(1.05);
  filter: brightness(1.2);
}

.btn-autospin:active .autospin-img {
  transform: scale(0.95);
}

.btn-autospin.active .autospin-img {
  animation: spin-rotate 2s linear infinite;
  filter: brightness(1.3) drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
}

@keyframes spin-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes activation-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.autospin-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  display: none;
}

.btn-autospin.holding .autospin-img {
  animation: activation-spin 1.5s linear;
}

.btn-autospin:active .autospin-progress,
.btn-autospin.holding .autospin-progress {
  opacity: 0;
  display: none;
}

#autospin-progress-circle {
  transition: stroke-dashoffset 0.05s linear;
}

.btn-action {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
  padding: 0;
  width: clamp(72px, 14vw, 180px);
  min-width: clamp(64px, 10vw, 72px);
  outline: none;
}

.btn-action img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.btn-action:hover {
  transform: scale(1.05);
  filter: brightness(1.2) drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
  background: transparent;
  border: none;
}

.btn-action:active {
  transform: scale(0.95);
}

.btn-action:focus {
  outline: none;
  border: none;
}

/* Anchor container for absolute dropdown */
.actions-panel { position: relative; /* was static; allow absolute children */ }

/* Refined bet dropdown: themed, overlay (absolute) so layout doesn't shift when shown */
.bet-dropdown {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  position: absolute;       /* overlay so it doesn't reflow layout */
  display: none;            /* shown via JS by adding .open or display:block */
  z-index: 2200;
  right: 0;                 /* default anchor at right of actions-panel */
  top: calc(100% + 8px);    /* sits just below the panel */
  width: clamp(140px, 18vw, 220px);
  max-width: 100%;
  padding: 10px 40px 10px 12px; /* room for caret on the right */
  border-radius: 10px;
  background: linear-gradient(180deg, #fffbe6, #f6c85f);
  color: #041d1d;
  border: 2px solid #ffd700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.35);
  font-weight: 700;
  font-family: 'Poppins', Arial, sans-serif;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 160ms ease, transform 120ms ease;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%23041d1d' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  box-sizing: border-box;
}

/* visible state */
.bet-dropdown.open { display: block; }

/* focus & hover affordances */
.bet-dropdown:hover { transform: translateY(-1px); box-shadow: 0 12px 32px rgba(0,0,0,0.48); }
.bet-dropdown:focus { outline: none; box-shadow: 0 0 0 6px rgba(255,215,0,0.12), 0 12px 32px rgba(0,0,0,0.48); }

/* Option styling — limited browser support but improves appearance where supported */
.bet-dropdown option { background: #fffbe6; color: #041d1d; padding: 8px 12px; font-weight: 600; font-family: 'Poppins', Arial, sans-serif; }

/* Custom floating bet menu (ul/li) */
.bet-menu {
  position: absolute;
  display: none;               /* toggled by JS */
  z-index: 2300;
  right: 0;
  top: calc(100% + 8px);
  width: clamp(160px, 20vw, 240px);
  max-height: 240px;
  overflow: hidden;
  background: linear-gradient(180deg,#fffbe6,#f6c85f);
  border: 2px solid #ffd700;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5);
  border-radius: 10px;
  padding: 6px;
  box-sizing: border-box;
  font-family: 'Poppins', Arial, sans-serif;
}

.bet-menu[aria-hidden="false"] { display: block; }

.bet-menu ul {
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bet-menu li {
  padding: 8px 10px;
  margin: 4px 2px;
  border-radius: 8px;
  cursor: pointer;
  color: #041d1d;
  font-weight: 700;
  background: rgba(255,255,255,0);
  transition: background 120ms ease, transform 80ms ease;
}

.bet-menu li:hover,
.bet-menu li[aria-selected="true"],
.bet-menu li.focused {
  background: rgba(4,29,29,0.06);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}

.bet-menu li:active {
  transform: translateY(0);
}

/* Small-screen adjustments */
@media (max-width: 420px) {
  .bet-dropdown {
    left: 6px;
    right: 6px;
    width: auto;
    top: calc(100% + 6px);
    padding-right: 36px;
    font-size: 0.95rem;
  }
  
  .bet-menu { left: 6px; right: 6px; width: auto; top: calc(100% + 6px); }
}

/* Win Amount Display */
.win-display {
  /* fixed-size centered box so content changes do not resize it */
  width: clamp(240px, 60vw, 420px);
  height: clamp(100px, 20vw, 140px);
  box-sizing: border-box;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, #ffd700 0%, #ffdf5a 60%, #ffed4e 100%);
  color: #041d1d;
  padding: 14px 20px; /* keep inner spacing constant */
  border-radius: 16px;
  font-size: 16px;
  font-weight: 400; /* not bold */
  /* Add thin dark border and subtle inner shadow for a more professional look */
  border: 2px solid rgba(0,0,0,0.85);
  box-shadow: 0 10px 40px rgba(255, 215, 0, 0.45), inset 0 2px 8px rgba(0,0,0,0.12);
  z-index: 3000;
  opacity: 0;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden; /* prevent inner text from changing layout */
  font-family: 'Poppins', Arial, sans-serif;
}
.win-display.total-win {
  /* Match the popup/golden look used across other celebration popups */
  background: linear-gradient(135deg, #ffd700 0%, #ffdf5a 60%, #ffed4e 100%);
  box-shadow: 0 16px 48px rgba(255, 215, 0, 0.55), 0 4px 18px rgba(0,0,0,0.45), inset 0 1px 6px rgba(0,0,0,0.08);
  color: #041d1d;
}

.win-display.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.win-display.hide {
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}

.win-display.win-pop {
  animation: win-pop 0.9s cubic-bezier(.2,.9,.2,1);
  box-shadow: 0 16px 48px rgba(255, 200, 50, 0.35), 0 4px 18px rgba(0,0,0,0.5), inset 0 1px 6px rgba(0,0,0,0.06);
}

/* label - subtle, normal weight */
.win-label {
  font-size: clamp(14px, 2.6vw, 18px);
  font-weight: 400; /* not bold */
  margin-bottom: 6px;
  color: #041d1d;
  opacity: 0.95;
}
.win-display.total-win .win-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* Tighter layout for end-of-free-spins / bonus summaries to avoid text being cut off */
.win-display.free-spins-final,
.win-display.king-bonus-final {
  height: clamp(140px, 22vw, 180px);
  padding: 12px 18px;
}
.win-display.free-spins-final .win-label,
.win-display.king-bonus-final .win-label {
  font-size: clamp(12px, 2.2vw, 15px);
  margin-bottom: 4px;
}
.win-display.free-spins-final .win-amount,
.win-display.king-bonus-final .win-amount {
  font-size: clamp(24px, 5vw, 40px);
  line-height: 1.08;
  white-space: normal;
  max-width: 92%;
}

/* amount - large, non-bold, tabular numbers so digit widths remain stable */
.win-amount {
  font-size: clamp(36px, 6.6vw, 56px);
  font-weight: 400; /* not bold */
  color: #041d1d;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -moz-font-feature-settings: "tnum";
  -webkit-font-feature-settings: "tnum";
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

/* Popup messages — restyled to match win-display gold look */
.popup {
  /* match win-display sizing/placement but allow content to wrap/scroll */
  width: clamp(240px, 60vw, 420px);
  box-sizing: border-box;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  background: linear-gradient(135deg, #ffd700 0%, #ffdf5a 60%, #ffed4e 100%); /* gold gradient to match win box */
  color: #041d1d; /* dark text for contrast */
  padding: 14px 20px; /* same inner spacing as win-display */
  border-radius: 16px;
  font-size: clamp(1rem, 3.6vw, 1.4rem);
  font-weight: 600;
  text-align: center;
  z-index: 3000; /* above UI like win-display */
  /* matching thin dark border for popups */
  border: 2px solid rgba(0,0,0,0.85);
  box-shadow: 0 10px 40px rgba(255, 215, 0, 0.45), inset 0 2px 8px rgba(0,0,0,0.10);
  transition: all 0.3s ease;
  pointer-events: none;
  max-width: 92vw;
  max-height: 60vh;    /* allow taller content but keep it on-screen */
  overflow: auto;      /* scroll if content too large */
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: block;
  font-family: 'Poppins', Arial, sans-serif;
}

/* Grand (celebration) popup — larger, professional half-screen feel */
.popup.grand-pop {
  width: min(92vw, 50vw);
  max-width: 960px;
  max-height: 70vh;
  padding: clamp(18px, 3.2vw, 28px) clamp(20px, 3.6vw, 32px);
  background: linear-gradient(180deg, rgba(10,10,10,0.85), rgba(20,20,20,0.75));
  color: #ffd86b;
  border: 1px solid rgba(255,215,0,0.45);
  border-radius: 16px;
  box-shadow: 0 20px 56px rgba(0,0,0,0.55), 0 0 0 3px rgba(255,215,0,0.16) inset;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: clamp(1.1rem, 3.8vw, 2.2rem);
  line-height: 1.22;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(255,215,0,0.4);
}

/* keep hidden / visible behavior consistent */
.popup.hidden {
  display: none;
  opacity: 0;
  visibility: hidden;
  z-index: -1;
}

.popup:not(.hidden) {
  opacity: 1;
  visibility: visible;
  z-index: 3000;
  transition: opacity 0.3s, visibility 0s;
}

/* Volume toggle button - top left corner - NO BORDER */
.volume-toggle {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  outline: none;
  transition: transform 0.2s, filter 0.2s;
}

.volume-toggle:hover {
  transform: scale(1.1);
  filter: brightness(1.2) drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
  background: transparent;
  border: none;
}

.volume-toggle:focus {
  outline: none;
  border: none;
}

.volume-toggle img {
  width: 60px;
  height: 60px;
}

/* Username display - BELOW volume button on LEFT */
.username-display-left {
  position: fixed;
  top: 85px;
  left: 15px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 15px;
  border-radius: 10px;
  border: 2px solid #ffd700;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 200px;
  font-family: Arial, sans-serif;
}

.username-label {
  font-size: 11px;
  color: #ffd700;
  margin-bottom: 3px;
  font-weight: bold;
  font-family: Arial, sans-serif;
}

.username-value {
  font-size: 13px;
  color: #fff;
  word-break: break-word;
  font-family: Arial, sans-serif;
}

/* Logout button - TOP RIGHT - NO BORDER */
.logout-btn {
  position: fixed;
  top: 20px; /* Changed from 15px */
  right: 20px; /* Changed from 15px */
  z-index: 1000;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.logout-btn:hover {
  background: transparent;
  transform: scale(1.05);
  filter: brightness(1.2) drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
  border: none;
}

.logout-btn:focus {
  outline: none;
  border: none;
}

.logout-btn img {
  width: 120px;
  height: auto;
}

/* Free-spins badge: fixed at left edge, slightly transparent background, non-intrusive */
.free-spins-indicator,
#free-spins-indicator {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  position: fixed !important;
  left: 12px !important;            /* small padding from screen edge */
  top: 12px;                        /* default; JS will nudge to align with autospin btn */
  transform: none !important;
  max-width: 60vw;
  padding: 6px 10px;
  background: rgba(0,0,0,0.45);     /* slightly transparent dark background */
  color: #ffd700;                   /* gold text */
  font-weight: 700;
  font-size: 0.98rem;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  pointer-events: none;             /* don't intercept clicks */
  z-index: 1300;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bonus multiplier pulse animation */
@keyframes bonusPulseScale {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,215,0,0)); }
  35% { transform: scale(1.14); filter: drop-shadow(0 0 12px rgba(255,215,0,0.55)) brightness(1.15); }
  65% { transform: scale(1.06); filter: drop-shadow(0 0 8px rgba(255,215,0,0.35)) brightness(1.08); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,215,0,0)); }
}
/* Reel glow removed */

@keyframes bonusPulseRing {
  0% { opacity:0; transform: scale(0.6); }
  20% { opacity:.55; }
  70% { opacity:.22; transform: scale(1.25); }
  100% { opacity:0; transform: scale(1.35); }
}
.free-spins-indicator.bonus-pulse,
#free-spins-indicator.bonus-pulse {
  animation: bonusPulseScale 640ms cubic-bezier(.25,.85,.25,1) 1;
  position: relative;
}
.free-spins-indicator.bonus-pulse::after,
#free-spins-indicator.bonus-pulse::after {
  content:'';
  position:absolute;
  left:50%; top:50%;
  transform: translate(-50%, -50%);
  width:160%; height:160%;
  background: radial-gradient(circle, rgba(255,216,107,0.55) 0%, rgba(255,216,107,0.22) 55%, rgba(255,216,107,0) 75%);
  pointer-events:none;
  border-radius:50%;
  animation: bonusPulseRing 640ms ease-out 1;
}

/* Small screens: allow wrapping and reduce width */
@media (max-width: 420px) {
  .free-spins-indicator,
  #free-spins-indicator {
    max-width: 70vw;
    font-size: 0.92rem;
    padding: 5px 8px;
    white-space: normal;
    word-break: break-word;
    left: 8px !important;
  }
}

/* Remove blue outline on focus/active for all interactive elements */
button, a, input, select, textarea {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus, a:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border: none;
}

button:hover {
  border: none !important;
  outline: none !important;
}

/* Mobile adjustments for 320px */
@media (max-width: 320px) {
  body {
    padding-top: 1vh;
  }

  .btn-autospin {
    position: relative;
    top: 0px;
    margin-top: clamp(-35px, -6vw, -30px); /* Less negative margin for more spacing */
  }
  
  .banner {
    width: clamp(100px, 45vw, 180px);
    margin-bottom: clamp(4px, 1vh, 8px);
  }
  
  .volume-toggle {
    width: 40px;
    height: 40px;
    top: 12px;
    left: 12px;
  }
  
  .username-display-left {
    top: 60px; /* Closer to volume button */
    left: 12px;
    padding: 4px 6px;
    max-width: 90px;
    gap: 2px;
  }
  
  .username-label {
    font-size: 0.5em;
    line-height: 1.1;
  }
  
  .username-value {
    font-size: 0.65em;
  }
  
  .logout-btn {
    width: 60px;
    height: 60px;
    top: 8px; /* Adjusted */
    right: 8px; /* Adjusted */
  }
  
  .banner {
    width: clamp(100px, 45vw, 180px);
    margin-bottom: clamp(4px, 1vh, 8px);
    margin-right: 0; /* Remove right margin */
  }
}

/* Mobile adjustments for 375px */
@media (min-width: 321px) and (max-width: 375px) {
  body {
    padding-top: 1.5vh;
  }

  .btn-autospin {
    position: relative;
    top: 0px;
    margin-top: clamp(-35px, -5vw, -30px); /* Less negative margin */
  }
  
  .banner {
    width: clamp(120px, 42vw, 200px);
  }
  
  .volume-toggle {
    width: 42px;
    height: 42px;
  }
  
  .username-display-left {
    top: 65px;
    left: 12px;
    padding: 5px 8px;
    max-width: 95px;
    gap: 3px;
  }
  
  .username-label {
    font-size: 0.55em;
  }
  
  .username-value {
    font-size: 0.7em;
  }
  
  .logout-btn {
    width: 70px;
    height: 70px;
    top: 12px; /* Adjusted */
    right: 12px; /* Adjusted */
  }
  
  .banner {
    margin-right: 0;
  }
}

/* Mobile adjustments for 425px */
@media (min-width: 376px) and (max-width: 425px) {
  body {
    padding-top: 2vh;
  }

  .btn-autospin {
    position: relative;
    top: 0px;
    margin-top: clamp(-30px, -4vw, -25px); /* Less negative margin */
  }
  
  .banner {
    width: clamp(140px, 40vw, 230px);
  }
  
  .volume-toggle {
    width: 45px;
    height: 45px;
  }
  
  .username-display-left {
    top: 70px;
    left: 15px;
    max-width: 105px;
  }
  
  .logout-btn {
    width: 80px;
    height: 80px;
    top: 15px; /* Adjusted */
    right: 15px; /* Adjusted */
  }
}

/* Mobile adjustments for 480px */
@media (max-width: 480px) {
  .banner {
    max-width: clamp(140px, 45vw, 200px);
  }
  
  .canvas-wrapper {
    margin-bottom: clamp(6px, 1.5vh, 8px);
  }
  
  .controls-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
    gap: clamp(4px, 1vw, 5px);
    padding: 0 clamp(2px, 0.8vw, 3px);
  }
  
  .stats-panel {
    padding: clamp(8px, 2.1vw, 12px) clamp(6px, 1.5vw, 8px);
    width: clamp(130px, 40vw, 155px);
    max-width: 155px;
    min-height: clamp(85px, 18vw, 105px);
  }
  
  .stat-item {
    font-size: clamp(0.6em, 2.3vw, 0.72em);
    margin-bottom: clamp(0px, 0.2vh, 1px); /* Reduced */
    padding: 0 clamp(0px, 0.6vw, 1px);
    line-height: 1.05; /* Reduced */
    gap: clamp(1px, 0.6vw, 2px);
  }
  
  .stat-label {
    margin-right: clamp(1px, 0.6vw, 2px);
    min-width: clamp(50px, 16vw, 58px);
    font-size: clamp(0.82em, 2.6vw, 0.98em); /* Reduced from 0.92em/2.8vw/1.08em */
  }
  
  .stat-value {
    font-size: clamp(0.82em, 2.6vw, 0.98em); /* Reduced from 0.92em/2.8vw/1.08em */
  }

  .spin-container {
    gap: clamp(5px, 1vh, 8px); /* Increased gap */
  }

  .btn-spin {
    width: clamp(68px, 26vw, 140px);
    height: clamp(68px, 26vw, 140px);
    margin-top: clamp(5px, 1.5vh, 10px);
  }

  .btn-autospin {
    width: clamp(100px, 34vw, 190px);
    height: clamp(100px, 34vw, 190px);
    min-width: clamp(80px, 24vw, 110px);
    min-height: clamp(80px, 24vw, 110px);
    margin-top: clamp(-30px, -5vw, -25px); /* Less negative margin */
  }

  .btn-action {
    max-width: clamp(85px, 28vw, 100px);
    min-width: clamp(70px, 22vw, 80px);
  }

  .actions-panel {
    gap: clamp(3px, 1vh, 5px);
  }

  .popup {
    font-size: clamp(0.9em, 3vw, 1.2em);
    padding: clamp(10px, 2.5vw, 15px) clamp(18px, 3.5vw, 25px);
  }
  
  .volume-toggle {
    width: 38px;
    height: 38px;
  }
}

/* Mobile adjustments for 380px */
@media (max-width: 380px) {
  .controls-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
    gap: clamp(3px, 1vw, 4px);
    padding: 0 clamp(1px, 0.5vw, 2px);
  }
  
  .stats-panel {
    padding: clamp(5px, 1.5vw, 8px) clamp(3px, 1vw, 5px);
    width: clamp(95px, 38vw, 110px);
    max-width: 110px;
    min-height: clamp(65px, 14vw, 80px);
  }
  
  .stat-item {
    font-size: clamp(0.5em, 1.8vw, 0.6em);
    margin-bottom: 0px; /* Removed margin */
    padding: 0;
    line-height: 1.0; /* Reduced */
    gap: clamp(1px, 0.4vw, 2px);
  }
  
  .stat-label {
    margin-right: 1px;
    min-width: clamp(38px, 13vw, 45px);
    font-size: clamp(0.68em, 2.1vw, 0.82em); /* Reduced from 0.75em/2.3vw/0.9em */
  }
  
  .stat-value {
    font-size: clamp(0.68em, 2.1vw, 0.82em); /* Reduced from 0.75em/2.3vw/0.9em */
  }

  .spin-container {
    gap: clamp(5px, 1vh, 8px); /* Increased gap */
  }

  .btn-spin {
    width: clamp(60px, 32vw, 120px);
    height: clamp(60px, 32vw, 120px);
    margin-top: clamp(5px, 1.5vh, 10px);
  }

  .btn-autospin {
    width: clamp(88px, 38vw, 150px);
    height: clamp(88px, 38vw, 150px);
    min-width: clamp(70px, 28vw, 110px);
    min-height: clamp(70px, 28vw, 110px);
    margin-top: clamp(-25px, -4vw, -20px); /* Less negative margin */
  }

  .btn-action {
    max-width: clamp(75px, 26vw, 85px);
    min-width: clamp(60px, 20vw, 70px);
  }

  .actions-panel {
    gap: clamp(2px, 0.8vh, 4px);
  }
  
  .banner {
    width: clamp(90px, 48vw, 150px);
  }
  
  .volume-toggle {
    width: 35px;
    height: 35px;
    top: 10px;
    left: 10px;
  }
}

/* Tablet adjustments for 768px */
@media (min-width: 426px) and (max-width: 768px) {
  /* ...existing code... */
  
  .username-display-left {
    top: 75px;
    left: 18px;
    max-width: 130px;
  }
  
  .logout-btn {
    width: 90px;
    height: 90px;
    top: 15px;
    right: 15px;
  }
}

@media (max-width: 768px) {
  /* ...existing code... */
  
  /* Remove extra padding since username is on left now */
  .game-container {
    padding-top: clamp(5px, 2vw, 20px); /* Reset to normal */
  }
  
  .controls-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
    grid-template-rows: auto;
    gap: clamp(5px, 1.5vw, 8px);
    position: static;
    padding: 0 clamp(3px, 1vw, 5px);
    min-height: auto;
    align-items: center; /* Changed from start */
    justify-content: center;
    max-width: 100%;
    overflow: visible;
  }
  
  .spin-container {
    grid-column: 2;
    grid-row: 1;
    gap: clamp(2px, 0.5vh, 2px);
    align-self: center;
  }

  .stats-panel {
    grid-column: 1;
    grid-row: 1;
    position: static;
    width: clamp(155px, 37vw, 210px);
    max-width: 210px;
    padding: clamp(10px, 2.3vw, 14px) clamp(8px, 1.8vw, 10px);
    margin: 0;
    justify-self: center;
    align-self: center; /* Changed from start */
    transform: none;
  }
  
  .actions-panel {
    grid-column: 3;
    grid-row: 1;
    position: static;
    width: auto;
    padding: 0;
    gap: clamp(3px, 1vh, 5px);
    align-self: center; /* Changed from start */
    transform: none;
    justify-self: center;
    margin-top: 0;
  }
  
  /* ...existing code... */
}

/* Landscape mobile - special handling */
@media (max-height: 600px) and (orientation: landscape) {
  /* ...existing code... */
  
  .username-display-left {
    top: 60px;
    left: 10px;
    padding: 4px 7px;
    max-width: 100px;
    gap: 2px;
  }
  
  .username-label {
    font-size: 0.5em;
  }
  
  .username-value {
    font-size: 0.65em;
  }
  
  .logout-btn {
    width: 60px;
    height: 60px;
    top: 8px;
    right: 8px;
  }
  
  .banner {
    margin-right: 0;
  }
}

/* Very small screens - minimize everything */
@media (max-width: 280px) {
  .username-display-left {
    top: 55px;
    left: 8px;
    padding: 2px 4px;
    max-width: 70px;
    gap: 1px;
  }
  
  .username-label {
    font-size: 0.4em;
    line-height: 0.9;
  }
  
  .username-value {
    font-size: 0.55em;
  }
  
  .logout-btn {
    width: 45px;
    height: 45px;
    top: 6px;
    right: 6px;
  }
  
  .banner {
    margin-right: 0;
    width: clamp(60px, 30vw, 100px);
  }
}

/* Compact stat rows: label and value side-by-side, centered over board image */
.stat-item {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  gap: clamp(4px, 1vw, 8px); /* responsive gap - gets smaller on small screens */
  width: 100%;
  padding: 0 clamp(4px, 1vw, 6px);
  margin-bottom: clamp(0px, 0.15vh, 1px);
  line-height: 1.04;
}

/* Tighter spacing on tablets and phones */
@media (max-width: 768px) {
  .stat-item {
    gap: clamp(3px, 0.8vw, 6px);
    margin-bottom: clamp(0px, 0.12vh, 1px);
  }
  .stat-label { font-size: clamp(0.80em, 1.5vw, 0.98em); }
  .stat-value { font-size: clamp(0.86em, 1.6vw, 1.02em); }
}

@media (max-width: 480px) {
  .stat-item {
    gap: clamp(2px, 0.6vw, 4px);
    margin-bottom: 0;
  }
  .stat-label { font-size: clamp(0.76em, 2.2vw, 0.92em); }
  .stat-value { font-size: clamp(0.82em, 2.6vw, 0.98em); }
}

/* Ensure images never force overflow — size to parent */
.btn-spin img,
.btn-autospin img,
.btn-action img,
.stats-panel img,
.actions-panel img {
	width: 100% !important;
	height: auto !important;
	max-width: 100%;
	object-fit: contain;
}

/* Narrow screens: keep single-column stacked layout but still fully fluid */
@media (max-width: 720px) {
	.controls-layout {
		grid-template-columns: 1fr !important;
		padding: 6px;
		gap: 8px;
	}
	.stats-panel, .spin-container, .actions-panel {
		max-width: 92vw;
		width: 100%;
	}
	/* scale buttons down further on small phones */
	.btn-spin { width: clamp(64px, 28vw, 160px); height: clamp(64px, 28vw, 160px); }
	.btn-autospin { width: clamp(90px, 34vw, 210px); height: clamp(90px, 34vw, 210px); }
	.btn-action { width: clamp(64px, 24vw, 140px); }
}

.scatter-glow {
  /* subtler, less intrusive gold-only glow (remove white component) */
  box-shadow: 0 0 12px 4px rgba(255,215,0,0.6), 0 0 18px 8px rgba(255,185,60,0.14);
  border-radius: 12px;
  transition: box-shadow 0.18s ease;
  outline: none;
}

/* Scatter popup: gold glow hugged to PNG edges */
.scatter-wrap { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2900; pointer-events: none; }
.scatter-wrap .scatter-img { position: relative; display: block; margin: 0 auto; z-index: 2; filter: drop-shadow(0 0 28px rgba(255,215,0,0.78)) drop-shadow(0 12px 26px rgba(255,200,50,0.22)); will-change: transform, filter; }
/* When showing, slightly increase glow intensity */
.scatter-wrap.show .scatter-img { filter: drop-shadow(0 0 36px rgba(255,215,0,0.9)) drop-shadow(0 14px 30px rgba(255,200,50,0.28)); }

.scatter-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,10,16,0.68);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  z-index: 2800;
}
.scatter-backdrop.show {
  opacity: 1;
}

.king-collector {
  position: absolute;
  top: clamp(8px, 1.5vw, 22px);
  left: 50%;
  transform: translateX(-50%) scale(0.98);
  background: rgba(4, 29, 29, 0.88);
  border: 1px solid rgba(255, 215, 0, 0.55);
  border-radius: 18px;
  padding: 12px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: clamp(240px, 46vw, 420px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), 0 0 24px rgba(255, 215, 0, 0.15);
  z-index: 2100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.3s ease;
  backdrop-filter: blur(8px);
}
.king-collector.hidden {
  display: none !important;
}
.king-collector.show {
  display: flex;
  opacity: 1;
  transform: translateX(-50%) scale(1);
}
.king-collector-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Poppins', Arial, sans-serif;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #ffd86b;
  text-transform: uppercase;
}
.king-collector-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  gap: 2px;
}
.king-collector-label {
  font-size: 12px;
  color: rgba(255, 216, 107, 0.85);
}
.king-collector-count {
  font-size: 15px;
  line-height: 1;
  color: #ffffff;
}
.king-collector-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
}
.king-collector-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(28px, 1fr));
  gap: 8px;
}
.king-slot {
  position: relative;
  padding-top: 56%; /* longer and thinner */
  border-radius: 10px;
  border: 2px dashed rgba(255, 255, 255, 0.12);
  overflow: hidden;
  background: rgba(0,0,0,0.16);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.king-slot::before,
.king-slot::after {
  content: '';
  position: absolute;
  inset: 8% 10%;
  border-radius: 8px;
  opacity: 1;
  transition: opacity 0.28s ease, transform 0.28s ease, filter 0.28s ease;
}
.king-slot::before {
  /* soft circular accent behind the silhouette */
  background: linear-gradient(180deg, rgba(255,215,0,0.06), rgba(255,215,0,0.02));
  transform: scale(0.98);
}
.king-slot::after {
  /* Use the capybara PNG as a mask so we can tint the silhouette.
     This creates a subtle outlined/ghost placeholder effect before fill. */
  -webkit-mask-image: url('/assets/images/capybara-king.png');
  -webkit-mask-size: 78%;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-image: url('/assets/images/capybara-king.png');
  mask-size: 78%;
  mask-position: center;
  mask-repeat: no-repeat;
  background-color: rgba(255,215,0,0.08);
  transform: scale(0.96);
  filter: drop-shadow(0 0 6px rgba(255,215,0,0.08));
}
.king-slot.filled {
  border-style: solid;
  border-color: rgba(255, 215, 0, 0.95);
  background: radial-gradient(circle, rgba(255, 215, 0, 0.22), rgba(255, 215, 0, 0.03));
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.36);
  animation: kingTokenFill 360ms cubic-bezier(.2,.9,.2,1);
}
.king-slot.filled::before {
  opacity: 0.95;
  transform: scale(1.12);
  filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.6));
}
.king-slot.filled::after {
  /* when filled we switch the mask to a direct image with stronger drop shadow */
  -webkit-mask-image: none;
  mask-image: none;
  background-image: url('/assets/images/capybara-king.png');
  background-size: 78%;
  background-position: center;
  background-repeat: no-repeat;
  background-color: transparent;
  opacity: 1;
  transform: scale(1);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6));
}

.king-slot .king-slot-img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 78%;
  height: 78%;
  transform: translate(-50%, -50%) scale(0.92);
  transition: transform 280ms cubic-bezier(.2,.9,.2,1), opacity 220ms ease;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6));
}
.king-slot.filling .king-slot-img {
  transform: translate(-50%, -50%) scale(1.08);
  opacity: 0.98;
}
@keyframes kingTokenFill {
  0% { transform: scale(0.92); opacity: 0.5; }
  60% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.king-token-hit {
  position: fixed;
  width: 76px;
  height: 76px;
  margin-left: -38px;
  margin-top: -38px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.6);
  transition: transform 0.6s cubic-bezier(.2,.8,.2,1), opacity 0.6s ease, filter 0.6s ease;
  z-index: 2200;
  filter: drop-shadow(0 0 26px rgba(255, 215, 0, 0.9));
}
.king-token-hit img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(255, 215, 0, 0.95));
}
.king-token-hit.glow {
  opacity: 1;
  transform: scale(1);
}
.king-slot.pulse {
  animation: kingSlotPulse 520ms cubic-bezier(.2,.9,.2,1) forwards;
}
@keyframes kingSlotPulse {
  0% { transform: translateY(0) scale(1); box-shadow: 0 0 0 rgba(255,215,0,0); }
  40% { transform: translateY(-4px) scale(1.05); box-shadow: 0 0 22px rgba(255,215,0,0.6); }
  100% { transform: translateY(0) scale(1); box-shadow: 0 0 0 rgba(255,215,0,0); }
}
.king-slot-glow {
  pointer-events: none;
  z-index: 2190;
  border-radius: 50%;
}

/* coin value overlay used on animated clones and on-reel coin symbols */
.coin-value-overlay {
  font-family: 'Arial', 'Helvetica', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #ffd86b; /* gold */
  /* black outline using multiple text-shadows for a crisp stroke-like effect */
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  pointer-events: none;
}

.king-bonus-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 3200;
  animation: popupFade 200ms ease forwards;
}
.king-bonus-popup img {
  width: min(90vw, 420px);
  max-height: 80vh;
  object-fit: contain;
  animation: bonusPop 520ms cubic-bezier(.2,.9,.2,1);
}
.king-bonus-popup.hide {
  animation: popupFadeOut 200ms ease forwards;
}
@keyframes popupFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popupFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes bonusPop {
  0% { transform: scale(0.8); opacity: 0; }
  70% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}

.king-bonus-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 3300;
}
.king-bonus-modal.show {
  display: flex;
}
.king-bonus-content {
  width: min(92vw, 540px);
  background: linear-gradient(180deg, rgba(6,59,42,0.95), rgba(3,28,22,0.95));
  border: 2px solid rgba(255, 215, 0, 0.6);
  border-radius: 22px;
  padding: 28px 32px;
  text-align: center;
  color: #fff;
  font-family: 'Poppins', Arial, sans-serif;
  position: relative;
  overflow: hidden;
  box-shadow: 0 24px 50px rgba(0,0,0,0.55);
}
.king-bonus-title {
  font-size: clamp(20px, 4vw, 28px);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #ffd86b;
}
.king-bonus-subtitle {
  font-size: clamp(14px, 2.8vw, 16px);
  margin: 8px 0 18px;
  color: rgba(255,255,255,0.85);
}
.king-bonus-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.king-bonus-tile {
  aspect-ratio: 1/1.25;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 6px;
  position: relative;
  overflow: hidden;
}
.king-bonus-tile-inner {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.08), rgba(0,0,0,0.25));
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}
.king-bonus-icon {
  width: 75%;
  height: 55%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.4));
}
.king-bonus-value {
  font-weight: 600;
  color: #ffd86b;
  text-shadow: 0 0 6px rgba(0,0,0,0.7);
}
.king-bonus-tile.royal .king-bonus-icon {
  /* Subtle hugged glow animation (avoid large ring) */
  animation: royalGlow 1.2s ease-in-out infinite;
}
.king-bonus-tile.royal {
  border-color: rgba(255,215,0,0.9);
  /* remove large outer box-shadow to avoid a ring effect */
  box-shadow: none;
}
.king-bonus-tile.collecting {
  opacity: 0.35;
}
@keyframes royalGlow {
  0%,100% { filter: drop-shadow(0 0 6px rgba(255,215,0,0.45)); }
  50% { filter: drop-shadow(0 0 10px rgba(255,215,0,0.6)); }
}
.king-bonus-footer {
  margin-top: 18px;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.7);
}

.king-bonus-collect-clone {
  position: absolute;
  width: 80px;
  height: 80px;
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 10;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.5));
  transition: transform 0.6s cubic-bezier(.2,.8,.2,1), opacity 0.6s ease;
}

/* Move settings/header buttons to fixed top-left and make them static (non-sticky) */
.header-buttons {
  position: fixed !important;   /* always fixed in viewport */
  top: 12px !important;
  left: 12px !important;
  right: auto !important;
  z-index: 3500 !important;     /* above main UI */
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  width: auto !important;
  padding: 6px !important;
  background: transparent !important;
  pointer-events: auto !important;
}

/* fallback/sticky-fixed class kept but ensure it behaves the same */
.header-buttons.sticky-fixed {
  position: fixed;
  top: 12px;
  left: 12px;
}

/* Make the settings button compact and visually neutral so it doesn't reflow layout */
.settings-btn {
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,215,0,0.06);
  padding: 6px;
  border-radius: 10px;
  width: clamp(56px, 12vw, 120px);
  height: clamp(40px, 8vw, 56px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

/* ensure icon inside settings button scales nicely */
.settings-btn #settings-icon,
.header-buttons img {
  width: 100%;
  height: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}

/* Prevent the header buttons from causing page content to shift when toggled */
.game-container {
  /* leave existing spacing but ensure top content isn't hidden under fixed header */
  padding-top: max(20px, 4vh); /* preserves breathing room below fixed header area */
}

/* Small-screen: nudge fixed items to avoid overlap and reduce size */
@media (max-width: 420px) {
  .header-buttons { top: 8px; left: 8px; gap: 8px; padding: 4px; }
  .settings-btn { width: clamp(44px, 18vw, 84px); height: clamp(36px, 12vw, 44px); border-radius: 8px; padding: 4px; }
  /* move volume toggle (if present) slightly right so they don't overlap */
  .volume-toggle { left: auto; right: 12px; top: 10px; }
  /* ensure username block (if present) is lower to avoid collisions */
  .username-display-left { top: 64px; left: 12px; }
}

/* Tablet and larger: keep fixed but slightly larger hit area */
@media (min-width: 421px) {
  .header-buttons { top: 14px; left: 14px; }
  .settings-btn { padding: 8px; }
}

/* Subtle FX overlay canvas for confetti, etc. */
#fx-overlay {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none; /* allow clicks to pass through */
  z-index: 2500; /* below popup (3000), above most UI */
}
