/* ============================================================
   MYSTERY BOX — Luxury Fantasy Game
   style.css  |  HTML5 + CSS3 only (no libraries)
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* backgrounds */
  --bg-0: #04150E;
  --bg-1: #0A2C1C;
  --bg-2: #0F4A30;
  /* purples */
  --pp-0: #12B76A;
  --pp-1: #1FD683;
  --pp-2: #5CF0A8;
  /* gold */
  --gold-0: #FFD84A;
  --gold-1: #FFB100;
  --gold-deep: #C9871B;
  /* accents */
  --neon-blue: #52B9FF;
  --neon-pink: #FF5CC8;
  --orange: #FF8A2B;
  --ink: #04120B;
  --text: #EDFBF4;
  --text-dim: #A6D6C2;

  /* frame */
  --frame-w: 480px;

  --font-display: 'Baloo 2', 'Kanit', system-ui, sans-serif;
  --font-ui: 'Poppins', 'Kanit', system-ui, sans-serif;
  --font-accent: 'Chakra Petch', 'Kanit', system-ui, sans-serif;
}

/* Bengali language switches primary UI font to Bengali-capable families */
html[data-lang="bn"] {
  --font-ui: 'Hind Siliguri', 'Poppins', system-ui, sans-serif;
  --font-display: 'Baloo Da 2', 'Baloo 2', system-ui, sans-serif;
}

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;                 /* NO vertical scroll, ever */
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-ui);
  overscroll-behavior: none;
  touch-action: manipulation;
}
body {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ============================================================
   LIVING BACKGROUND (fills entire viewport behind the frame)
   ============================================================ */
#bgCanvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  display: block;
}
.bg-fog, .bg-rays, .bg-vignette { position: fixed; inset: -10%; z-index: 1; pointer-events: none; }

.bg-fog {
  background:
    radial-gradient(60% 45% at 30% 20%, rgba(18,183,106,.30), transparent 70%),
    radial-gradient(55% 45% at 78% 30%, rgba(46,227,160,.16), transparent 70%),
    radial-gradient(70% 60% at 50% 100%, rgba(11,54,35,.55), transparent 75%);
  filter: blur(8px);
  animation: fogDrift 22s ease-in-out infinite alternate;
  mix-blend-mode: screen;
}
@keyframes fogDrift {
  0%   { transform: translate3d(-2%, 1%, 0) scale(1.02); }
  100% { transform: translate3d(3%, -2%, 0) scale(1.08); }
}
.bg-rays {
  background:
    conic-gradient(from 0deg at 50% 38%,
      rgba(255,216,74,.00) 0deg,
      rgba(255,216,74,.07) 12deg,
      rgba(255,216,74,.00) 24deg,
      rgba(92,240,168,.06) 40deg,
      rgba(255,216,74,.00) 60deg);
  filter: blur(2px);
  animation: raySpin 60s linear infinite;
  opacity: .8;
}
@keyframes raySpin { to { transform: rotate(360deg); } }
.bg-vignette {
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(2,10,6,.85) 100%);
  z-index: 2;
}

/* ============================================================
   PHONE APP FRAME (~480px, centered, fills height)
   ============================================================ */
.app-frame {
  position: relative;
  z-index: 3;
  width: min(var(--frame-w), 100vw);
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(8px, 2.2vh, 18px) clamp(10px, 3.6vw, 18px) clamp(8px, 1.6vh, 14px);
  gap: clamp(6px, 1.2vh, 12px);
  overflow: hidden;
  /* subtle inner frame lighting so it reads as a device on desktop */
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(18,183,106,.22), transparent 60%),
    linear-gradient(180deg, rgba(8,40,26,.55), rgba(5,24,15,.72));
  box-shadow: 0 0 0 1px rgba(92,240,168,.18) inset, 0 30px 80px rgba(0,0,0,.55);
}
@media (min-width: 520px) {
  .app-frame {
    height: min(100dvh, 900px);
    border-radius: 26px;
    border: 1px solid rgba(92,240,168,.25);
  }
}

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; }
.hud-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.coin-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(11,54,35,.9), rgba(5,24,15,.9));
  border: 1px solid rgba(255,216,74,.4);
  box-shadow: 0 2px 10px rgba(0,0,0,.4), 0 0 12px rgba(255,177,0,.25) inset;
  font-family: var(--font-accent);
  font-weight: 700;
}
.coin-ico {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  background:
    radial-gradient(circle at 35% 30%, #FFF3B0, var(--gold-0) 45%, var(--gold-1) 75%, var(--gold-deep));
  box-shadow: 0 0 8px rgba(255,177,0,.7), inset 0 0 0 2px rgba(201,135,27,.7);
  position: relative;
}
.coin-ico::after { content: "৳"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: #7a4d05; font-weight: 800; }
.coin-ico.big { width: 26px; height: 26px; }
.coin-ico.big::after { font-size: 15px; }
.coin-amount { color: var(--gold-0); font-size: 16px; letter-spacing: .3px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.coin-plus {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
  background: linear-gradient(180deg, var(--gold-0), var(--gold-1));
  color: #5a3a00; font-weight: 800;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(11,54,35,.9), rgba(5,24,15,.9));
  border: 1px solid rgba(92,240,168,.35);
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  font-family: var(--font-accent); font-weight: 700; font-size: 13px; color: var(--pp-2);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(18,183,106,.5); filter: brightness(1.1); }
.icon-btn:active { transform: scale(.94); }
.ico-sound { width: 20px; height: 20px; display: inline-block; background: currentColor;
  color: var(--gold-0);
  -webkit-mask: var(--sound-on) center/contain no-repeat; mask: var(--sound-on) center/contain no-repeat; }
:root {
  --sound-on: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M4 9v6h4l5 5V4L8 9H4zm12.5 3a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4zm-2.5-9v2.06A7 7 0 0 1 19 12a7 7 0 0 1-5 6.94V21a9 9 0 0 0 0-18z'/></svg>");
  --sound-off: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M4 9v6h4l5 5V4L8 9H4zm15.07 1.93L17.66 12l1.41 1.41-1.06 1.06L16.6 13.06l-1.41 1.41-1.06-1.06L15.54 12l-1.41-1.41 1.06-1.06 1.41 1.41 1.41-1.41 1.06 1.06z'/></svg>");
}
.icon-btn.muted .ico-sound { color: #7f9a8f; -webkit-mask-image: var(--sound-off); mask-image: var(--sound-off); }

/* ---------- TITLE ---------- */
.title-wrap { position: relative; flex: 0 0 auto; text-align: center; padding: 4px 0 0; }

/* the badge hugs the title so the ribbon can sit exactly behind it */
.title-badge { position: relative; display: inline-block; padding: 10px 46px 12px; }

/* folded ribbon tails hanging below each end */
.title-badge::before, .title-badge::after {
  content: ""; position: absolute; bottom: -7px; z-index: 0;
  width: 40px; height: 30px;
  background: linear-gradient(180deg, #0E7A54, #06341F);
  clip-path: polygon(0 0, 100% 0, 100% 68%, 50% 100%, 0 68%);
  box-shadow: 0 6px 12px rgba(0,0,0,.4);
  filter: brightness(.9);
}
.title-badge::before { left: 10px; }
.title-badge::after  { right: 10px; }

/* GOLD outer edge (the clip-path shape) */
.title-ribbon {
  position: absolute; left: 0; right: 0; top: 4%; bottom: 8%; z-index: 1;
  background: linear-gradient(180deg, #FFF0A8 0%, var(--gold-0) 45%, var(--gold-1) 78%, var(--gold-deep) 100%);
  clip-path: polygon(6% 0, 94% 0, 100% 50%, 94% 100%, 6% 100%, 0 50%);
  box-shadow: 0 10px 22px rgba(0,0,0,.45), 0 0 26px rgba(46,227,160,.30);
}
/* EMERALD inner face (inset a few px so the gold shows as a border) */
.title-ribbon::before {
  content: ""; position: absolute; inset: 3px; z-index: 1;
  background:
    linear-gradient(180deg, rgba(255,255,255,.35), transparent 34%),
    linear-gradient(180deg, #3DE8A0 0%, #1FBE86 42%, #0F8A5C 74%, #0A5236 100%);
  clip-path: polygon(6% 0, 94% 0, 100% 50%, 94% 100%, 6% 100%, 0 50%);
}
/* soft moving sheen across the ribbon */
.title-ribbon::after {
  content: ""; position: absolute; inset: 3px; z-index: 2; overflow: hidden;
  clip-path: polygon(6% 0, 94% 0, 100% 50%, 94% 100%, 6% 100%, 0 50%);
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.28) 50%, transparent 60%);
  background-size: 260% 100%;
  animation: ribbonSheen 6s ease-in-out infinite;
}
@keyframes ribbonSheen { 0%, 60% { background-position: 140% 0; } 100% { background-position: -40% 0; } }

.game-title {
  position: relative; z-index: 3;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: .84;
  letter-spacing: 1px;
  display: flex; flex-direction: column; align-items: center;
  text-transform: uppercase;
}
.game-title .tl-1 { font-size: clamp(30px, 8.4vw, 44px); }
.game-title .tl-2 { font-size: clamp(38px, 10.8vw, 58px); margin-top: -2px; }
/* Bright legible gold with THIN dark outline (no glossy glare) */
.game-title span {
  color: var(--gold-0);
  background: linear-gradient(180deg, #FFF0A8 0%, var(--gold-0) 42%, var(--gold-1) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1.4px #3a1c02;
  paint-order: stroke fill;
  filter: drop-shadow(0 3px 0 rgba(58,28,2,.55)) drop-shadow(0 5px 6px rgba(0,0,0,.5));
}
.subtitle {
  margin-top: 6px; font-family: var(--font-ui); font-weight: 500;
  font-size: clamp(11px, 3.1vw, 13.5px); color: #E9DEFF;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

/* ============================================================
   BOX GRID (3 columns x 4 rows, auto-fills height, no scroll)
   ============================================================ */
.grid-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; }
.box-grid {
  width: 100%;
  height: 100%;
  display: grid;
  /* minmax(0,1fr) lets rows/cols shrink below the cubes' intrinsic size so the
     grid always fits the available height (no overflow onto the buttons below) */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: clamp(4px, 1.4vw, 12px);
  place-items: center;
}
.box-grid.locked { pointer-events: none; }
.box-grid.locked .box { filter: grayscale(.85) brightness(.5); opacity: .55; }

/* ---------- Individual box cell ---------- */
.box {
  position: relative;
  width: 100%; height: 100%;
  min-width: 0; min-height: 0;      /* allow shrinking inside the grid track */
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  border: none; background: none;
  transition: transform .16s ease, filter .2s ease, opacity .25s ease;
  will-change: transform;
}
.box .cube-slot {
  position: relative;
  flex: 1 1 auto;            /* take the remaining cell height (badge sits below) */
  min-height: 0;            /* allow it to shrink so cubes never overflow the row */
  width: 100%;
  display: grid; place-items: center;
  animation: boxFloat 4.4s ease-in-out infinite;
}
.box:nth-child(2n) .cube-slot { animation-duration: 5.1s; animation-delay: -1.2s; }
.box:nth-child(3n) .cube-slot { animation-duration: 4.8s; animation-delay: -.6s; }
@keyframes boxFloat {
  0%,100% { transform: translateY(0) rotate(-1.2deg); }
  50%     { transform: translateY(-6%) rotate(1.2deg); }
}

/* glow halo under/behind cube */
.box .glow {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 122%; height: 122%; border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 62%);
  filter: blur(6px); opacity: .55;
  animation: breathe 3.6s ease-in-out infinite;
  pointer-events: none; z-index: 0;
}
@keyframes breathe { 0%,100% { opacity: .4; transform: translate(-50%,-50%) scale(.92); } 50% { opacity: .72; transform: translate(-50%,-50%) scale(1.06); } }

/* ---------- The 3D cube (SVG) ---------- */
.cube {
  position: relative;
  /* square that fits BOTH the cell width and the (shrinking) cell height */
  width: 100%; max-width: 92%; max-height: 100%; aspect-ratio: 1 / 1;
  z-index: 1;
  display: grid; place-items: center;
}
.cube-svg {
  width: 100%; height: 100%;
  overflow: visible;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.5)) drop-shadow(0 0 6px var(--glow));
  transition: filter .2s ease;
}
/* the "?" text inside the SVG gets a soft glow */
.cube-svg text { filter: drop-shadow(0 0 5px var(--glow)); }

/* diagonal shine sweep (idle glint + hover sweep) */
.cube .shine {
  position: absolute; inset: 6% 14% 8% 8%; z-index: 3; pointer-events: none;
  border-radius: 14%;
  overflow: hidden;
  -webkit-mask: linear-gradient(#000, #000);
}
.cube .shine::before {
  content: ""; position: absolute; top: -60%; left: -120%;
  width: 60%; height: 220%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent);
  transform: rotate(18deg);
  animation: shineSweep 5.5s ease-in-out infinite;
}
@keyframes shineSweep {
  0%, 62% { left: -120%; }
  78%, 100% { left: 160%; }
}

/* number badge */
.box .badge {
  position: relative; z-index: 4;
  min-width: 26px; padding: 1px 8px;
  font-family: var(--font-accent); font-weight: 700; font-size: clamp(10px, 2.9vw, 13px);
  color: #2b1400;
  background: linear-gradient(180deg, var(--gold-0), var(--gold-1));
  border-radius: 999px;
  border: 1.5px solid rgba(120,80,10,.7);
  box-shadow: 0 2px 6px rgba(0,0,0,.5), 0 0 8px rgba(255,177,0,.4);
  text-align: center;
}

/* sparkle dots (created in JS) */
.spark { position: absolute; width: 4px; height: 4px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 6px 2px var(--glow); pointer-events: none; z-index: 2;
  animation: sparkle 2.6s ease-in-out infinite; }
@keyframes sparkle { 0%,100% { opacity: 0; transform: scale(.4); } 50% { opacity: 1; transform: scale(1); } }

/* HOVER */
.box:not(.dim):hover { transform: scale(1.08); z-index: 5; }
.box:not(.dim):hover .glow { opacity: 1; filter: blur(10px); }
.box:not(.dim):hover .cube-svg {
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.55)) drop-shadow(0 0 16px var(--glow)) brightness(1.12);
}
.box:not(.dim):hover .cube .shine::before { animation-duration: 1.1s; }

/* SELECTED / dimmed */
.box.dim { filter: brightness(.45) saturate(.7); opacity: .5; transform: scale(.94); }
.box.chosen { z-index: 8; animation: chosenShake .5s ease-in-out; }
.box.chosen .glow { opacity: 1; filter: blur(10px); }
@keyframes chosenShake {
  0%,100% { transform: scale(1.14) rotate(0); }
  20% { transform: scale(1.16) rotate(-4deg); }
  40% { transform: scale(1.16) rotate(4deg); }
  60% { transform: scale(1.16) rotate(-3deg); }
  80% { transform: scale(1.16) rotate(2deg); }
}
/* magic circle under chosen box */
.box.chosen::after {
  content: ""; position: absolute; left: 50%; bottom: 2%; transform: translateX(-50%);
  width: 92%; aspect-ratio: 1; border-radius: 50%;
  background:
    conic-gradient(from 0deg, transparent, var(--glow), transparent 30%, var(--glow) 50%, transparent 70%, var(--glow) 92%, transparent);
  -webkit-mask: radial-gradient(circle, transparent 38%, #000 40%, #000 48%, transparent 50%);
  mask: radial-gradient(circle, transparent 38%, #000 40%, #000 48%, transparent 50%);
  animation: circleSpin 2.2s linear infinite; opacity: .9; z-index: 0;
}
@keyframes circleSpin { to { transform: translateX(-50%) rotate(360deg); } }

/* ---------- INFO BUTTONS ---------- */
.info-nav { flex: 0 0 auto; display: flex; gap: 10px; justify-content: center; padding: 2px 0; }
.info-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 12px;
  font-family: var(--font-ui); font-weight: 600; font-size: clamp(12px,3.2vw,14px); color: #EEE4FF;
  background: linear-gradient(180deg, rgba(11,54,35,.92), rgba(5,24,15,.92));
  border: 1px solid rgba(92,240,168,.45);
  box-shadow: 0 3px 12px rgba(0,0,0,.4), 0 0 0 1px rgba(255,216,74,.12) inset;
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
.info-btn:hover { transform: translateY(-1px); filter: brightness(1.12); box-shadow: 0 6px 18px rgba(18,183,106,.5); }
.info-btn:active { transform: scale(.96); }
.info-ico { font-size: 15px; }

/* ---------- BOTTOM BANNER ---------- */
.bottom-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(14,66,42,.9), rgba(6,30,19,.95));
  border: 1px solid rgba(255,216,74,.4);
  box-shadow: 0 4px 16px rgba(0,0,0,.45), 0 0 18px rgba(18,183,106,.25) inset;
}
.box-strip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(5,24,15,.9), rgba(3,14,9,.9));
  border: 1px solid rgba(92,240,168,.5);
  font-family: var(--font-accent); font-weight: 700; font-size: 12px; color: var(--text-dim);
}
.box-strip b { color: var(--gold-0); font-size: 14px; }

/* latest-reward chip — shows the most recent box result, updates after Continue */
.last-reward {
  flex: 0 0 auto; display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(5,24,15,.92), rgba(3,14,9,.92));
  border: 1px solid var(--lr-c, rgba(92,240,168,.5));
  box-shadow: 0 0 10px -2px var(--lr-c, transparent);
  font-family: var(--font-accent); font-weight: 700;
}
.last-reward[hidden] { display: none; }
/* label kept in DOM for a11y/tooltip but hidden to save space in the bar */
.last-reward .lr-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.last-reward .lr-sym { font-size: 15px; line-height: 1; }
.last-reward .lr-amt { color: var(--lr-c, var(--gold-0)); font-size: 14px; }
.bottom-bar.locked .last-reward { display: none; }
.banner-text {
  flex: 1 1 auto; min-width: 0; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(13px, 3.6vw, 19px);
  color: var(--gold-0);
  text-shadow: 0 1px 2px rgba(0,0,0,.6), 0 0 12px rgba(255,177,0,.35);
  letter-spacing: .3px;
}
.bottom-bar.locked { border-color: rgba(140,140,160,.4); }
.bottom-bar.locked .banner-text { color: #cfd6e6; text-shadow: 0 1px 2px rgba(0,0,0,.7); }

/* ============================================================
   FX OVERLAY (opening animation)
   ============================================================ */
.fx-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(5,24,15,.4), rgba(2,10,6,.86));
}
.fx-overlay.show { display: flex; }
#fxCanvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.fx-flash { position: absolute; inset: 0; z-index: 3; background: #fff; opacity: 0; pointer-events: none; }
.fx-flash.burst { animation: flashBurst .5s ease-out; }
@keyframes flashBurst { 0% { opacity: 0; } 22% { opacity: .95; } 100% { opacity: 0; } }

.fx-stage { position: relative; z-index: 2; width: min(70vw, 320px); aspect-ratio: 1; display: grid; place-items: center; }

.fx-magic-circle {
  position: absolute; width: 128%; aspect-ratio: 1; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--fx-glow, #12B76A), transparent 25%, var(--fx-glow,#12B76A) 50%, transparent 75%, var(--fx-glow,#12B76A), transparent);
  -webkit-mask: radial-gradient(circle, transparent 40%, #000 42%, #000 49%, transparent 51%);
  mask: radial-gradient(circle, transparent 40%, #000 42%, #000 49%, transparent 51%);
  opacity: 0; animation: circleSpin 3s linear infinite;
}
.fx-overlay.show .fx-magic-circle { opacity: .85; }

.fx-chest {
  position: relative; width: 62%; aspect-ratio: 1; display: grid; place-items: center;
}
.chest-halo {
  position: absolute; inset: -30%; border-radius: 50%;
  background: radial-gradient(circle, var(--fx-glow,#12B76A) 0%, transparent 62%);
  filter: blur(10px); opacity: .7; animation: haloPulse 1s ease-in-out infinite;
}
@keyframes haloPulse { 0%,100% { transform: scale(.9); opacity: .5; } 50% { transform: scale(1.12); opacity: .9; } }
.chest-cube {
  position: relative; width: 78%; aspect-ratio: 1; border-radius: 18%;
  background: radial-gradient(130% 110% at 30% 20%, rgba(255,255,255,.35), transparent 42%), linear-gradient(160deg, var(--fx-c1,#1FD683), var(--fx-c2,#083A20));
  border: 3px solid rgba(255,216,74,.9);
  box-shadow: inset 0 0 18px rgba(0,0,0,.5), 0 0 30px var(--fx-glow,#12B76A);
}
.fx-chest.charging .chest-cube { animation: chestShudder .28s linear infinite; }
@keyframes chestShudder {
  0%,100% { transform: translate(0,0) rotate(0); }
  25% { transform: translate(-2px,1px) rotate(-1.5deg); }
  50% { transform: translate(2px,-1px) rotate(1.5deg); }
  75% { transform: translate(-1px,-1px) rotate(-1deg); }
}
.fx-chest.charging.fast .chest-cube { animation-duration: .12s; }
.chest-q { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 74px; color: #fff; text-shadow: 0 0 12px var(--fx-glow,#12B76A); }
.chest-cube.open { animation: chestOpen .5s ease-out forwards; }
@keyframes chestOpen { 0% { transform: scale(1); } 40% { transform: scale(1.18) rotate(-3deg); } 100% { transform: scale(0) rotate(8deg); opacity: 0; } }

.chest-lightcol {
  position: absolute; left: 50%; bottom: 40%; transform: translateX(-50%) scaleY(0);
  width: 40%; height: 160%; transform-origin: bottom center;
  background: linear-gradient(180deg, transparent, rgba(255,240,180,.9) 40%, #fff);
  filter: blur(4px); opacity: 0; border-radius: 50% 50% 0 0;
}
.chest-lightcol.burst { animation: lightCol .8s ease-out forwards; }
@keyframes lightCol { 0% { transform: translateX(-50%) scaleY(0); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateX(-50%) scaleY(1.4); opacity: 0; } }

.fx-reward-item {
  position: absolute; z-index: 4; font-size: 96px; opacity: 0;
  filter: drop-shadow(0 0 22px var(--fx-glow,#FFD84A));
}
.fx-reward-item.rise { animation: rewardRise 1s cubic-bezier(.2,.9,.3,1) forwards; }
@keyframes rewardRise {
  0% { opacity: 0; transform: translateY(40px) scale(.3); }
  55% { opacity: 1; transform: translateY(-8px) scale(1.2); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* screen shake helper (applied to app-frame + overlay) */
.shake { animation: screenShake .5s cubic-bezier(.36,.07,.19,.97); }
@keyframes screenShake {
  10%,90% { transform: translate3d(-2px,0,0); }
  20%,80% { transform: translate3d(3px,0,0); }
  30%,50%,70% { transform: translate3d(-6px,0,0); }
  40%,60% { transform: translate3d(6px,0,0); }
}

/* ============================================================
   MODALS
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.show { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,10,6,.72); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- reward / claim / miss cards ---- */
.reward-card, .claim-card, .miss-card {
  position: relative; z-index: 2; width: min(360px, 90vw);
  padding: 26px 22px 20px; text-align: center;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(11,55,36,.92), rgba(5,22,14,.96));
  border: 1px solid rgba(92,240,168,.5);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 40px rgba(18,183,106,.35);
  animation: popIn .4s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes popIn { 0% { opacity: 0; transform: scale(.8) translateY(10px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

.reward-rarity, .claim-title {
  display: inline-block; margin-bottom: 14px; padding: 6px 22px;
  font-family: var(--font-display); font-weight: 800; letter-spacing: 1px; font-size: 17px;
  color: #fff2c8; text-transform: uppercase;
  background: linear-gradient(180deg, var(--rar-c, var(--pp-1)), var(--rar-c2, var(--pp-0)));
  clip-path: polygon(6% 0, 94% 0, 100% 50%, 94% 100%, 6% 100%, 0 50%);
  box-shadow: 0 3px 12px rgba(0,0,0,.5), 0 0 0 2px rgba(255,216,74,.35) inset;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}

.reward-symbol-wrap { position: relative; height: 130px; display: grid; place-items: center; margin: 6px 0 10px; }
.reward-symbol-wrap.small { height: 96px; }
.reward-symbol-glow {
  position: absolute; width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, var(--rar-c, var(--gold-1)) 0%, transparent 62%);
  filter: blur(6px); opacity: .8; animation: breathe 2.6s ease-in-out infinite;
}
.reward-symbol { position: relative; font-size: 84px; animation: symFloat 3s ease-in-out infinite; filter: drop-shadow(0 6px 12px rgba(0,0,0,.5)); }
.reward-symbol-wrap.small .reward-symbol { font-size: 62px; }
@keyframes symFloat { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }

.reward-amount {
  font-family: var(--font-display); font-weight: 800; font-size: 46px; line-height: 1;
  color: var(--gold-0); margin-bottom: 16px;
  text-shadow: 0 2px 4px rgba(0,0,0,.6), 0 0 18px rgba(255,177,0,.4);
}
.reward-actions { display: flex; gap: 12px; justify-content: center; }
.reward-boxinfo { margin-top: 12px; font-family: var(--font-accent); font-size: 12px; color: var(--text-dim); }

.claim-amount { display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-display); font-weight: 800; font-size: 40px; color: var(--gold-0); margin-bottom: 18px; text-shadow: 0 2px 4px rgba(0,0,0,.6), 0 0 18px rgba(255,177,0,.4); }

.miss-cloud { font-size: 74px; filter: grayscale(.3) drop-shadow(0 4px 10px rgba(0,0,0,.5)); animation: symFloat 3s ease-in-out infinite; }
.miss-amount { font-family: var(--font-display); font-weight: 800; font-size: 42px; color: #cfd6e6; margin-bottom: 6px; }
.miss-text { font-size: 14px; color: var(--text-dim); margin-bottom: 16px; }

/* ---- buttons ---- */
.btn {
  position: relative; padding: 12px 22px; border-radius: 12px;
  font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: .3px;
  color: #fff; min-width: 120px;
  box-shadow: 0 4px 0 rgba(0,0,0,.35), 0 6px 16px rgba(0,0,0,.4);
  transition: transform .1s ease, filter .15s ease, box-shadow .1s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.4); }
.btn.wide { width: 100%; }
.btn.big { font-size: 20px; padding: 16px 34px; }
.btn-green { background: linear-gradient(180deg, #3ee07a, #16a34a); text-shadow: 0 1px 2px rgba(0,0,0,.4); box-shadow: 0 4px 0 #0d7a37, 0 6px 16px rgba(22,163,74,.4); }
.btn-green:active { box-shadow: 0 1px 0 #0d7a37, 0 3px 8px rgba(22,163,74,.4); }
.btn-gold { background: linear-gradient(180deg, var(--gold-0), var(--gold-1)); color: #4a2d00; text-shadow: 0 1px 1px rgba(255,255,255,.35); box-shadow: 0 4px 0 var(--gold-deep), 0 6px 16px rgba(255,177,0,.4); }
.btn-gold:active { box-shadow: 0 1px 0 var(--gold-deep), 0 3px 8px rgba(255,177,0,.4); }
.btn-locked { background: linear-gradient(180deg, #5b6472, #3a414d); color: #e6ebf5; box-shadow: 0 4px 0 #262c36, 0 6px 16px rgba(0,0,0,.4); font-size: 14px; }
.btn-locked:active { box-shadow: 0 1px 0 #262c36; }

/* ---- glass info cards ---- */
.glass-card {
  position: relative; z-index: 2; width: min(420px, 92vw); max-height: 86dvh; overflow: auto;
  padding: 24px 22px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(10,50,32,.82), rgba(4,20,12,.9));
  border: 1px solid rgba(92,240,168,.45);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 40px rgba(18,183,106,.3);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: popIn .35s cubic-bezier(.2,.9,.3,1.1);
}
.close-x {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px; color: #eee;
  background: rgba(255,255,255,.08); border: 1px solid rgba(92,240,168,.35);
  transition: transform .1s, background .2s;
}
.close-x:hover { background: rgba(255,255,255,.16); transform: rotate(90deg); }
.glass-title {
  text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 24px;
  color: var(--gold-0); margin-bottom: 18px; text-shadow: 0 2px 4px rgba(0,0,0,.5);
}

/* how-to-play steps */
.steps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.step {
  padding: 14px 12px; border-radius: 14px; text-align: center;
  background: linear-gradient(180deg, rgba(11,54,35,.6), rgba(5,24,15,.6));
  border: 1px solid rgba(92,240,168,.3);
}
.step .step-ico { font-size: 34px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.5)); }
.step .step-n { display: inline-block; margin: 8px 0 4px; width: 24px; height: 24px; line-height: 24px; border-radius: 50%; font-family: var(--font-accent); font-weight: 700; font-size: 13px; color: #4a2d00; background: linear-gradient(180deg, var(--gold-0), var(--gold-1)); }
.step .step-t { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: #fff; margin-bottom: 3px; }
.step .step-d { font-size: 11.5px; color: var(--text-dim); line-height: 1.35; }

/* keep-latest rule note under the 4 steps */
.steps-note {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  display: flex; gap: 10px; align-items: flex-start;
  background: linear-gradient(180deg, rgba(18,183,106,.20), rgba(5,24,15,.5));
  border: 1px solid rgba(255,216,74,.38);
  box-shadow: 0 0 16px rgba(18,183,106,.18) inset;
  font-size: 12.5px; line-height: 1.55; color: #EADFFF;
}
.steps-note .note-ico { font-size: 18px; flex: 0 0 auto; line-height: 1.2; }
.steps-note b { color: var(--gold-0); font-weight: 700; }

/* all-rewards table */
.rewards-table { font-family: var(--font-accent); }
.rt-head, .rt-row {
  display: grid; grid-template-columns: 1.3fr 1fr .6fr; align-items: center;
  padding: 9px 12px; gap: 8px;
}
.rt-head { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid rgba(92,240,168,.25); }
.rt-body { display: flex; flex-direction: column; }
.rt-row { border-bottom: 1px solid rgba(255,255,255,.06); }
.rt-row:nth-child(odd) { background: rgba(255,255,255,.03); }
.rt-rarity { font-weight: 700; font-size: 14px; }
.rt-reward { font-weight: 700; font-size: 15px; color: var(--gold-0); }
.rt-icon { font-size: 20px; text-align: center; }

/* ---------- login gate (username entry) ---------- */
.login-gate {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 38%, rgba(11,54,35,.72), rgba(2,10,6,.97));
  backdrop-filter: blur(5px);
}
.login-gate.hide { display: none; }
.gate-logo {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(30px, 9vw, 50px);
  color: var(--gold-0); -webkit-text-stroke: 1.4px #3a1c02; paint-order: stroke fill;
  filter: drop-shadow(0 4px 0 rgba(58,28,2,.5)) drop-shadow(0 6px 10px rgba(0,0,0,.5));
  margin-bottom: 6px; letter-spacing: 2px;
}
.login-card {
  position: relative; width: min(360px, 92vw); text-align: center;
  padding: 26px 22px 24px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(11,55,36,.92), rgba(4,20,12,.96));
  border: 1px solid rgba(92,240,168,.4);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 40px rgba(18,183,106,.3);
  animation: popIn .4s cubic-bezier(.2,.9,.3,1.15);
}
.login-sub { font-family: var(--font-ui); font-weight: 500; font-size: 14px; color: var(--text-dim); margin-bottom: 18px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-field {
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; border-radius: 12px;
  background: rgba(2,10,6,.6);
  border: 1.5px solid rgba(92,240,168,.35);
  transition: border-color .2s, box-shadow .2s;
}
.login-field:focus-within { border-color: var(--gold-0); box-shadow: 0 0 0 3px rgba(255,216,74,.18); }
.login-uico { font-size: 18px; flex: 0 0 auto; opacity: .9; }
.login-input {
  flex: 1 1 auto; width: 100%; padding: 13px 0; border: none; outline: none; background: none;
  color: var(--text); font-family: var(--font-ui); font-weight: 600; font-size: 16px;
}
.login-input::placeholder { color: #6f8c7f; font-weight: 500; }
.login-error { min-height: 16px; font-size: 12.5px; color: #FF8080; font-weight: 600; text-align: left; padding-left: 2px; }
#loginBtn.loading { opacity: .75; pointer-events: none; }
.login-lang {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  width: 42px; height: 34px; border-radius: 10px;
  background: rgba(11,55,36,.9); border: 1px solid rgba(92,240,168,.4);
  color: var(--pp-2); font-family: var(--font-accent); font-weight: 700; font-size: 13px;
}
.login-lang:hover { filter: brightness(1.15); }

/* username chip in the header (after login) */
.user-chip {
  display: flex; align-items: center; gap: 6px;
  max-width: 150px; padding: 5px 12px 5px 9px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(11,54,35,.9), rgba(5,24,15,.9));
  border: 1px solid rgba(92,240,168,.4);
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
  font-family: var(--font-accent); font-weight: 700;
}
.user-chip[hidden] { display: none; }
.user-chip .user-ico { font-size: 14px; flex: 0 0 auto; }
.user-chip .user-name { color: var(--pp-2); font-size: 13px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; z-index: 61; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 9px; height: 14px; opacity: .95;
  animation: confFall linear forwards;
}
@keyframes confFall {
  0% { transform: translateY(-20px) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: .9; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- very short screens: shrink title a touch ---------- */
@media (max-height: 640px) {
  .subtitle { display: none; }
  .game-title .tl-1 { font-size: clamp(24px, 7vw, 34px); }
  .game-title .tl-2 { font-size: clamp(30px, 9vw, 44px); }
}
