/* =====================================================================
   Jewels Bonanza — the cluster-pays slot (Gems Bonanza style) in Ariant.
   Shared by both themes; everything is scoped to .jb (the stage),
   .art-jewels (the lobby card) or .jb-pays (its pays window), since every
   game's CSS loads on every page.

   Set by jewels.js from the stage size: --cell (one grid cell), --logo-h.
   ===================================================================== */

.stage-jewels .stage-inner { padding: 0; }

.jb {
  --cell: 56px; --logo-h: 60px;
  --gold: #ffd65a; --gold-deep: #b9771d; --royal: #3b1d5e; --royal-deep: #22103a; --turq: #3fd6c8;
  position: relative; align-self: stretch; flex: 1; width: 100%; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; user-select: none; -webkit-user-select: none;
}
.jb-sky {
  position: absolute; inset: 0; z-index: 0; will-change: transform;
  background: linear-gradient(rgba(255, 245, 220, 0.06), rgba(60, 25, 70, 0.22)), url("/static/img/maple-ariant.jpg") center bottom / cover; /* anchored to the houses along the bottom */
  transition: filter 0.8s;
}
.jb.fever .jb-sky { filter: saturate(1.4) brightness(0.85) hue-rotate(-12deg); }
.jb.fever .jb-sky::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 210, 90, 0.35), transparent 65%), linear-gradient(rgba(80, 20, 90, 0.15), rgba(255, 150, 60, 0.18));
}

/* the sign: a gold Ariant palace plaque with an onion dome, jewels set in, the name carved
   (the SVG is in jewels.js — SIGN) */
.jb-logo { position: relative; z-index: 2; height: var(--logo-h); display: flex; align-items: center; justify-content: center; }
.jb-logo svg {
  display: block; height: calc(var(--logo-h) - 4px); width: auto; aspect-ratio: 400 / 98; max-width: calc(100% - 16px); overflow: visible;
  filter: drop-shadow(0 3px 0 #1d0e33) drop-shadow(0 6px 10px rgba(30, 10, 40, 0.4)); /* static: never animated */
}
.jb-logo image { image-rendering: pixelated; }
.jb-sign-face { fill: url(#jbg-face); stroke: url(#jbg-rim); stroke-width: 5; stroke-linejoin: round; }
.jb-sign-line { fill: none; stroke: #ffd65a; stroke-opacity: 0.5; stroke-width: 1.5; }
.jb-sign-text {
  font: 900 37px "Cinzel", Georgia, serif; fill: url(#jbg-text); stroke: #1d0e33; stroke-width: 4px; paint-order: stroke fill; stroke-linejoin: round;
}
.jb-twinkle { fill: #fff; transform-box: fill-box; transform-origin: center; animation: jb-twinkle 1.8s ease-in-out infinite; }
@keyframes jb-twinkle { 0%, 55%, 100% { opacity: 0; transform: scale(0.3) rotate(0deg); } 70% { opacity: 1; transform: scale(1.2) rotate(45deg); } }

/* the Jewel Fever meter (in the fever: the climb meter and the 2x … 10x ladder) */
.jb-meter {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
  width: calc(var(--cell) * 8 + 16px); max-width: 100%;
}
.jb-meter-label {
  flex-shrink: 0; font: 700 14px / 1 "Fredoka", system-ui, sans-serif; letter-spacing: 0.05em; color: var(--gold);
  -webkit-text-stroke: 3px var(--royal-deep); paint-order: stroke fill;
}
.jb-meter-track {
  position: relative; flex: 1; height: 22px; border-radius: 999px; overflow: hidden;
  background: rgba(34, 16, 58, 0.78); border: 2px solid rgba(255, 214, 90, 0.85); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}
.jb-meter-fill {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); transition: transform 0.35s ease-out;
  background: linear-gradient(90deg, var(--turq), #7cf2b5 40%, var(--gold) 75%, #ff9f2e);
}
.jb-meter-text {
  position: absolute; inset: 0; display: grid; place-items: center; font: 700 13px / 1 "Fredoka", system-ui, sans-serif; color: #fff;
  -webkit-text-stroke: 3px var(--royal-deep); paint-order: stroke fill; font-variant-numeric: tabular-nums;
}
.jb-meter.full .jb-meter-track { border-color: #fff; box-shadow: 0 0 14px rgba(255, 214, 90, 0.95), inset 0 2px 4px rgba(0, 0, 0, 0.3); }
.jb-ladder { display: flex; gap: 4px; flex-shrink: 0; }
.jb-ladder[hidden] { display: none; }
.jb-ladder span {
  padding: 3px 7px; border-radius: 999px; font: 700 13px / 1 "Fredoka", system-ui, sans-serif; color: rgba(255, 255, 255, 0.55);
  background: rgba(34, 16, 58, 0.78); border: 2px solid rgba(255, 255, 255, 0.25);
}
.jb-ladder span.done { color: #fff; border-color: rgba(255, 214, 90, 0.6); }
.jb-ladder span.now { color: #2a1300; background: var(--gold); border-color: #fff; box-shadow: 0 0 12px rgba(255, 214, 90, 0.9); }

/* the board: a royal-purple panel trimmed in gold, the 8x8 grid on a soft checker */
.jb-board {
  position: relative; z-index: 1; padding: 8px; border-radius: 16px; flex-shrink: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 50%, transparent 50%) 8px 8px / calc(var(--cell) * 2) calc(var(--cell) * 8) no-repeat,
    linear-gradient(rgba(59, 29, 94, 0.82), rgba(34, 16, 58, 0.88));
  border: 3px solid var(--gold); box-shadow: inset 0 0 0 2px rgba(63, 214, 200, 0.45), 0 12px 30px rgba(30, 10, 40, 0.45);
}
.jb.fever .jb-board { box-shadow: inset 0 0 0 2px rgba(255, 214, 90, 0.7), 0 0 26px rgba(255, 190, 70, 0.75), 0 12px 30px rgba(30, 10, 40, 0.5); }
.jb-grid, .jb-marks, .jb-fx { width: calc(var(--cell) * 8); height: calc(var(--cell) * 8); }
.jb-grid { position: relative; z-index: 2; overflow: hidden; border-radius: 10px; }
.jb-marks { position: absolute; left: 8px; top: 8px; z-index: 1; pointer-events: none; }
.jb-fx { position: absolute; left: 8px; top: 8px; z-index: 4; pointer-events: none; }

.jb-cell { position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); display: grid; place-items: center; will-change: transform; contain: layout style; transition: opacity 0.2s; }
.jb-grid.dim .jb-cell:not(.win) { opacity: 0.32; } /* a cluster lights up: the rest of the board steps back */
.jb-cell > * { grid-area: 1 / 1; }
.jb-cell img {
  width: calc(var(--cell) * var(--k, 0.78)); height: calc(var(--cell) * var(--k, 0.78)); object-fit: contain; image-rendering: pixelated;
  filter: drop-shadow(0 2px 2px rgba(20, 5, 30, 0.45));
}
.jb-cell.j-wild img { filter: drop-shadow(0 0 6px rgba(255, 230, 120, 0.95)) drop-shadow(0 2px 2px rgba(20, 5, 30, 0.45)); }
/* winners pulse and glow — transform and opacity only, so it stays smooth */
.jb-cell::before {
  content: ""; width: 94%; height: 94%; border-radius: 30%; opacity: 0; grid-area: 1 / 1;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 214, 90, 0.6) 42%, transparent 72%);
}
.jb-cell.win::before { animation: jb-halo 0.28s ease-in-out infinite alternate; }
@keyframes jb-halo { from { opacity: 0.35; transform: scale(0.85); } to { opacity: 1; transform: scale(1.05); } }
.jb-cell.win img { animation: jb-win 0.26s ease-in-out infinite alternate; }
@keyframes jb-win { to { transform: scale(1.18); } }

/* markers: a coloured square under the jewel (its feature's colour), gently pulsing — they
   light up on the empty board before the jewels drop in */
.jb-mark {
  position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); will-change: transform;
  --m: #4aa8ff;
}
.jb-mark::before {
  content: ""; position: absolute; inset: 4%; border-radius: 20%;
  background: radial-gradient(circle, color-mix(in srgb, var(--m) 40%, #fff) 0%, color-mix(in srgb, var(--m) 85%, transparent) 45%, color-mix(in srgb, var(--m) 45%, transparent) 100%);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--m) 55%, #fff), 0 0 16px var(--m), 0 0 4px var(--m);
  animation: jb-mark 0.9s ease-in-out infinite alternate;
}
@keyframes jb-mark { from { opacity: 0.82; } to { opacity: 1; } }
.jb-mark.hit::before { animation: none; opacity: 1; box-shadow: inset 0 0 0 4px #fff, 0 0 22px var(--m); background: color-mix(in srgb, var(--m) 70%, transparent); }
.jb .m-nuke, .jb-pays .m-nuke { --m: #3d9bff; }
.jb .m-wildgem, .jb-pays .m-wildgem { --m: #ff4fbf; }
.jb .m-squares, .jb-pays .m-squares { --m: #f2a516; }
.jb .m-colossal, .jb-pays .m-colossal { --m: #ff4848; }
.jb .m-lucky, .jb-pays .m-lucky { --m: #2fc46a; }

/* a feature's sign: its MapleStory skill icon in a slot framed in the feature's colour
   (the heads-up, Muhamad's throw, the rules) */
.jb .jb-tok, .jb-pays .jb-tok {
  display: inline-grid; place-items: center; box-sizing: border-box; border-radius: 22%; padding: 0; /* (% padding would follow the parent's width) */
  background: linear-gradient(color-mix(in srgb, var(--m) 70%, #fff), var(--m) 55%, color-mix(in srgb, var(--m) 70%, #000));
  border: 2px solid #fff; box-shadow: 0 0 10px var(--m), 0 2px 3px rgba(20, 5, 30, 0.5);
}
.jb .jb-tok img, .jb-pays .jb-tok img { display: block; width: 84%; height: 84%; object-fit: contain; image-rendering: pixelated; border-radius: 12%; }
.jb-pays .jb-tok.key { flex-shrink: 0; width: 32px; height: 32px; }

/* a cleared marker's heads-up: its sign, big, with the feature's name, over the square */
.jb-alert { position: absolute; left: 0; top: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none; will-change: transform, opacity; }
.jb-alert .jb-tok { width: calc(var(--cell) * 1.15); height: calc(var(--cell) * 1.15); border-width: 3px; box-shadow: 0 0 22px var(--m), 0 0 0 4px rgba(255, 255, 255, 0.3), 0 4px 8px rgba(20, 5, 30, 0.5); }
.jb-alert b {
  font: 700 max(15px, calc(var(--cell) * 0.32)) / 1 "Fredoka", system-ui, sans-serif; color: #fff; white-space: nowrap;
  padding: 4px 12px; border-radius: 999px; background: var(--m); border: 2px solid #fff; box-shadow: 0 0 12px var(--m); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
/* Muhamad's throw: the sign arcs onto the board and lands with a ring */
.jb .jb-fly { position: absolute; left: 0; top: 0; z-index: 8; width: calc(var(--cell) * 0.8); height: calc(var(--cell) * 0.8); pointer-events: none; will-change: transform; }
.jb-land {
  position: absolute; left: 0; top: 0; z-index: 7; width: calc(var(--cell) * 1.4); height: calc(var(--cell) * 1.4); border-radius: 50%; pointer-events: none;
  border: 4px solid #fff; box-shadow: 0 0 24px var(--m), inset 0 0 18px var(--m); will-change: transform, opacity;
}

/* Muhamad, Ariant's jeweller (muhamad.png, 11 frames; --f picks one, --npc-s scales him) */
.jb-npc { position: absolute; left: 0; top: 0; z-index: 5; width: calc(68px * var(--npc-s, 2)); height: calc(84px * var(--npc-s, 2)); pointer-events: none; will-change: transform; }
.jb-npc.cheer { z-index: 11; } /* over the big-win screen */
.jb-npc::after {
  content: ""; position: absolute; left: 14%; right: 26%; bottom: -5px; height: 12px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(30, 10, 40, 0.5), transparent);
}
.jb-npc-body { position: absolute; inset: 0; z-index: 1; transform-origin: 50% 100%; animation: jb-breathe 2.8s ease-in-out infinite alternate; }
@keyframes jb-breathe { to { transform: scaleY(1.025); } }
.jb-npc.cheer .jb-npc-body { animation: jb-cheer 0.4s cubic-bezier(.3, 0, .5, 1) infinite alternate; }
@keyframes jb-cheer { to { transform: translateY(-22px); } }
.jb-npc-fig {
  position: absolute; inset: 0; transform: scaleX(-1); image-rendering: pixelated; /* the art faces left; he faces the board */
  background: url("/static/img/jewels/muhamad.png") no-repeat;
  background-size: calc(68px * var(--npc-s, 2) * 11) 100%; background-position: calc(var(--f, 0) * -68px * var(--npc-s, 2)) 0;
  filter: drop-shadow(0 0 1px rgba(30, 10, 40, 0.6));
}
.jb-npc-top { position: absolute; left: 50%; bottom: calc(100% + 2px); z-index: 2; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.jb.npc-low .jb-npc-top { left: 0; transform: none; align-items: flex-start; }
.jb-bubble {
  position: relative; width: max-content; max-width: 170px; padding: 7px 12px; border-radius: 12px; text-align: center;
  background: #fff; border: 2px solid var(--royal); color: var(--royal-deep); font: 600 15px / 1.2 "Fredoka", system-ui, sans-serif;
  box-shadow: 0 3px 0 rgba(30, 10, 40, 0.35); opacity: 0; transform: translateY(6px) scale(0.85);
  transition: opacity 0.18s, transform 0.22s cubic-bezier(.2, 1.5, .4, 1);
}
.jb-bubble.show { opacity: 1; transform: none; }
.jb-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 11px; height: 11px; margin-left: -6px;
  background: #fff; border-right: 2px solid var(--royal); border-bottom: 2px solid var(--royal); transform: rotate(45deg);
}
.jb.npc-low .jb-bubble::after { left: 30%; }
.jb.npc-low .jb-under { padding-left: calc(68px * var(--npc-s, 1) + 8px); }

/* under the board: the running win */
.jb-under { position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; min-height: 36px; flex-wrap: wrap; }
.jb-bar {
  position: relative; padding: 5px 18px; border-radius: 999px; text-align: center;
  background: rgba(34, 16, 58, 0.78); border: 2px solid rgba(255, 214, 90, 0.85);
  font: 700 21px / 1.2 "Fredoka", system-ui, sans-serif; color: #fff; letter-spacing: 0.01em; font-variant-numeric: tabular-nums;
}
.jb-bar[hidden] { display: block; visibility: hidden; }
.jb-bar.win { color: var(--gold); }
.jb-bar.mult { color: #fff; background: linear-gradient(#9b3cff, #5a1aa0); border-color: var(--gold); }
.jb .coin { display: inline-block; height: 0.82em; width: auto; margin-left: 0.18em; vertical-align: -0.08em; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.4)); }

/* what each cluster paid, popping up over it */
.jb-pop {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; animation: jb-pop 1.3s ease-out forwards;
  font: 700 calc(var(--cell) * 0.44) / 1 "Fredoka", system-ui, sans-serif; color: #fff; -webkit-text-stroke: 4px var(--royal); paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--royal-deep);
}
.jb-pop .coin { height: 0.75em; }
@keyframes jb-pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -110%) scale(1); } }
.jb-burst { position: absolute; width: 0; height: 0; }
.jb-burst i {
  position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 6px var(--gold); animation: jb-burst 0.6s ease-out forwards; will-change: transform;
}
.jb-burst i:nth-child(even) { background: var(--turq); }
@keyframes jb-burst { to { transform: rotate(var(--a)) translateX(calc(var(--cell) * 0.55 * var(--d))) scale(0.2); opacity: 0; } }
/* features: Nuclear's flash, the golden frame round a block */
.jb-flash { position: absolute; inset: 0; z-index: 4; border-radius: 16px; pointer-events: none; background: radial-gradient(circle, #fff, rgba(200, 230, 255, 0.85) 45%, rgba(74, 168, 255, 0) 80%); }
.jb-block { position: absolute; inset: 0; filter: drop-shadow(0 0 5px var(--c, #ffd65a)) drop-shadow(0 0 2px var(--c, #ffd65a)); }
.jb-block i { position: absolute; box-sizing: border-box; border: 0 solid var(--c, var(--gold)); border-radius: 3px; }

/* overlays: banners and big wins */
.jb-overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
.jb-overlay.show { opacity: 1; }
.jb-overlay.waiting { pointer-events: auto; cursor: var(--cur-click); } /* a landed big win: click to close */
.jb-overlay.big::before {
  content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(255, 220, 140, 0.4), rgba(34, 16, 58, 0.86) 62%);
}
.jb-banner {
  padding: 10px 26px; border-radius: 16px; background: linear-gradient(color-mix(in srgb, var(--m, #ff7ac8) 85%, #fff), var(--m, #c03aa0));
  border: 3px solid #fff; font: 900 36px / 1.1 "Cinzel", Georgia, serif; letter-spacing: 0.03em; color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); box-shadow: 0 0 24px var(--m, #ff7ac8), 0 10px 30px rgba(30, 10, 40, 0.5);
}
.jb-banner.fever, .jb-banner.level, .jb-banner.climb { --m: #f3a21e; color: #fff; }
.jb-banner.fever { font-size: 54px; padding: 14px 34px; }
.jb-overlay.banner.show .jb-banner { animation: jb-in 0.5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes jb-in { from { opacity: 0; transform: scale(0.4); } }
.jb-big { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.jb-big span { font: 900 46px / 1.1 "Cinzel", Georgia, serif; letter-spacing: 0.03em; color: var(--gold); -webkit-text-stroke: 4px var(--royal); paint-order: stroke fill; text-shadow: 0 5px 0 var(--royal-deep); }
.jb-big b { font: 700 64px / 1 "Fredoka", system-ui, sans-serif; color: #fff; -webkit-text-stroke: 5px #6a1aa0; paint-order: stroke fill; text-shadow: 0 5px 0 #3a0a60, 0 0 30px rgba(255, 220, 120, 0.8); font-variant-numeric: tabular-nums; will-change: transform; }
.jb-big em { font: 700 20px / 1 "Fredoka", system-ui, sans-serif; font-style: normal; color: #2a1300; background: var(--gold); padding: 4px 12px; border-radius: 999px; }
.jb-overlay.big.show .jb-big { animation: jb-in 0.6s cubic-bezier(.2, 1.6, .4, 1) both; }
.jb-count { position: relative; display: grid; place-items: center; }
.jb-count > * { grid-area: 1 / 1; }
.jb-ring {
  width: 115%; height: 170%; border-radius: 50%; opacity: 0; pointer-events: none; will-change: transform, opacity;
  background: radial-gradient(closest-side, rgba(255, 246, 190, 0.95), rgba(255, 200, 70, 0.6) 45%, rgba(255, 140, 40, 0) 100%);
}
/* the meso rain behind a big-win count-up (inside the overlay: over its backdrop, under the number) */
.jb-rain { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.jb-meso { position: absolute; left: 0; top: 0; overflow: hidden; will-change: transform; filter: drop-shadow(0 2px 2px rgba(60, 20, 0, 0.35)); }
.jb-meso img { display: block; height: 100%; width: auto; max-width: none; animation: jb-meso-spin 0.42s steps(4) infinite; will-change: transform; }
@keyframes jb-meso-spin { to { transform: translateX(-100%); } }

/* pays & rules */
.jb-pays p { margin: 0 0 10px; }
.jb-paytable { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.jb-paytable th, .jb-paytable td { padding: 4px 6px; text-align: center; font-size: 13px; }
.jb-paytable thead th { font-size: 12px; opacity: 0.8; }
.jb-paytable tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.06); }
.jb-paytable img { width: 30px; height: 30px; object-fit: contain; image-rendering: pixelated; vertical-align: middle; }
.jb-inline { width: 22px; height: 22px; object-fit: contain; image-rendering: pixelated; vertical-align: -5px; }
.jb-rules p { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }

/* ---- lobby card art ---- */
.art-jewels { position: relative; overflow: hidden; background: url("/static/img/maple-ariant.jpg") center bottom / cover; }
.art-jewels .mini-grid {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%); display: grid; grid-template-columns: repeat(6, 34px); gap: 2px; padding: 6px;
  border-radius: 12px; background: rgba(34, 16, 58, 0.72); border: 2px solid #ffd65a; box-shadow: inset 0 0 0 2px rgba(63, 214, 200, 0.45), 0 8px 18px rgba(30, 10, 40, 0.35);
}
.art-jewels .mini-grid img { width: 34px; height: 30px; object-fit: contain; image-rendering: pixelated; }
.art-jewels .mini-grid .win { filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 3px #ffd65a); }

@media (max-width: 760px) {
  .jb-bar { font-size: 17px; }
  .jb-banner { font-size: 28px; }
  .jb-banner.fever { font-size: 36px; }
  .jb-big span { font-size: 34px; }
  .jb-big b { font-size: 42px; }
  .jb-meter-label { font-size: 12px; }
  .jb-ladder span { padding: 2px 5px; font-size: 11px; }
  .jb-bubble { font-size: 13px; max-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .jb-twinkle, .jb-cell.win img, .jb-meso img, .jb-mark::before, .jb-npc-body { animation: none !important; }
  .jb-cell.win::before { animation: none !important; opacity: 0.8; }
}
