/* Velvet Fox Roulette: the shell styles (tokens, plates, buttons, entry screen, overlays, sheets,
   daily wheel). The table, the wheel, the chips and every layout are in game.css.

   How this file is organised
   - Sizes are in em. The font-size of .app is the single scale knob of each layout.
   - Portrait is the base. Three media queries at the end adapt it: landscape (any height),
     tall landscape (desktop / tablet) and short landscape (phone lying down).
   - Each selector has one rule per layout (a few also share a rule placed right above their own),
     so what you read is what applies.
   - Plaques, pills and jackpot plates are painted images drawn with border-image:
     the slices keep the end caps at their drawn shape and stretch only the plain middle.
   - Stacking order: game < flying coins .fx (30) < overlay content (31) < HUD (32) < sheets (40) < toast (45). */

/* ======================================================================
   A. Tokens and reset
   ====================================================================== */

/* Palette and the notch / home-bar insets. Change a colour here and the whole HUD follows. */
:root {
  --gold-1: #fff3b0;
  --gold-2: #ffc93c;
  --gold-3: #e08a00;
  --gold-4: #7a3d00;
  --navy-1: #0d3a26;
  --navy-2: #06170f;
  --ptr-ar: 0.41; /* width / height of art/wheel-pointer.webp */
  --ivory: #fff1cf;
  --ink: #06101f;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* The game owns the whole viewport: no page scroll, no rubber-band bounce. */
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--navy-2);
  overscroll-behavior: none;
}

body {
  font-family:
    'Trebuchet MS',
    'Segoe UI',
    system-ui,
    -apple-system,
    Roboto,
    sans-serif;
  font-weight: 800;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  padding: 0;
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

img {
  display: block;
  -webkit-user-drag: none;
}

/* JS shows and hides screens with the hidden attribute; it must beat every display rule below. */
[hidden] {
  display: none !important;
}

/* Screen-reader-only live region. */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* Counters tick without the digits jumping sideways. */
.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* Every size below is in em, so this font-size is the one scale knob of the whole game.
   Portrait scales with the smaller of width and height, so nothing is pushed off screen. */
.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  font-size: clamp(11px, min(4vw, 1.9vh), 20px);
}

/* ======================================================================
   B. Background
   ====================================================================== */

.bg,
.bg-img {
  position: absolute;
  inset: 0;
}

.bg-img {
  background-size: cover;
  background-position: center;
}

.bg-base {
  background-image: url(../../art/bg-portrait.webp);
}

/* Free-spins scenery cross-fades over the base one. */

/* Vignette: darker edges keep the eye on the table. */
.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(2, 10, 7, 0.15) 0%, rgba(2, 10, 7, 0.6) 100%);
}

/* ======================================================================
   C. Shared pieces: gold text, plaques, buttons
   ====================================================================== */

/* Gradient clipped to the glyphs; the drop-shadows give the engraved edge. */
.gold-text {
  color: transparent;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 900;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 38%, var(--gold-3) 62%, #ffd86b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0.06em 0 var(--gold-4)) drop-shadow(0 0.12em 0.1em rgba(0, 0, 0, 0.7));
}

/* Painted pill (same art family as the table frame). The border-image slices keep the two end caps
   at their drawn shape and stretch only the plain middle, so one image fits any width.
   --ph is the pill height; the cap width follows it (0.787 = slice width / image height of pill.webp). */
.plaque,
.btn-pill {
  min-height: 0;
  height: var(--ph);
  border-radius: 0;
  border: 1px solid transparent;
  border-image: url(../../art/pill.webp) 0 104 fill / 0 calc(var(--ph) * 0.578) stretch;
  filter: drop-shadow(0 0.22em 0.3em rgba(0, 0, 0, 0.55));
}

.plaque {
  --ph: 2.9em;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0 1.25em;
  color: #fff;
  text-shadow:
    0 0.08em 0 #000,
    0 0 0.25em rgba(0, 0, 0, 0.8);
}

.plaque small {
  font-size: 0.68em;
  color: var(--gold-2);
  letter-spacing: 0.12em;
}

/* Tall enough for a 44 px touch target on a phone. */
.btn-pill {
  --ph: 3.7em;
  min-width: 8em;
  padding: 0 0.3em;
  font-size: 0.78em;
  letter-spacing: 0.08em;
  text-shadow: 0 0.08em 0 #000;
  white-space: nowrap;
  transition:
    transform 0.09s ease,
    background 0.2s,
    box-shadow 0.2s;
}

/* Toggle on: swap the art for the gold pill and add a glow. */
.btn-pill[aria-pressed='true'] {
  color: var(--gold-1);
  text-shadow:
    0 0.07em 0 #2a1400,
    0 0 0.3em rgba(0, 0, 0, 0.8);
  border-image-source: url(../../art/btn-gold.webp);
  border-image-slice: 0 113 fill;
  border-image-width: 0 calc(var(--ph) * 0.579);
  filter: drop-shadow(0 0 0.5em rgba(255, 190, 60, 0.9)) brightness(1.25);
}

/* Bet +/- : the box is a 40 px+ touch target, the painted gold disc stays small inside it
   (the gradient ends at 69%), and the negative margin keeps the boxes from widening the plaque. */
.btn-round {
  flex: none;
  width: 2.7em;
  height: 2.7em;
  margin: 0 -0.42em;
  font-size: 1em;
  line-height: 1;
  color: #3b1c00;
  border-radius: 50%;
  background: radial-gradient(
      circle closest-side,
      #fff6c4 0%,
      var(--gold-2) 38%,
      var(--gold-3) 62%,
      var(--gold-4) 67%,
      transparent 69%
    )
    center / 100% 100% no-repeat;
  transition:
    transform 0.09s ease,
    filter 0.15s;
}

.btn-ico {
  /* painted round button (gold knot rim, navy glass); the icon is drawn on top */
  width: 2.75em;
  height: 2.75em;
  display: grid;
  place-items: center;
  background: url(../../art/btn-blank.webp) center / contain no-repeat;
  filter: drop-shadow(0 0.2em 0.3em rgba(0, 0, 0, 0.55));
  transition: transform 0.09s;
}

.btn-ico svg {
  width: 1.45em;
  height: 1.45em;
  fill: none;
  stroke: var(--gold-1);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sound button: waves when on, a cross when muted. */
#btn-sound .cross {
  display: none;
}

#btn-sound[aria-pressed='true'] .waves {
  display: none;
}
#btn-sound[aria-pressed='true'] .cross {
  display: inline;
}

/* Call-to-action button: same slicing trick as the pill, with the gold art (cap = half the height). */
.btn-gold {
  --ph: 3.1em;
  padding: 0 2.2em;
  height: var(--ph);
  min-width: 11em;
  font-size: 1.55em;
  letter-spacing: 0.06em;
  color: var(--gold-1);
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 900;
  text-shadow:
    0 0.07em 0 #2a1400,
    0 0 0.35em rgba(0, 0, 0, 0.8);
  border-radius: 0;
  border: 1px solid transparent;
  border-image: url(../../art/btn-gold.webp) 0 113 fill / 0 calc(var(--ph) * 0.579) stretch;
  filter: drop-shadow(0 0.3em 0.5em rgba(0, 0, 0, 0.6)) drop-shadow(0 0 0.8em rgba(255, 190, 60, 0.55));
  transition: transform 0.09s;
}

.btn-round:active,
.btn-pill:active,
.btn-ico:active,
.btn-gold:active {
  transform: scale(0.92);
}

/* disabled: the same painted piece, only dimmer (never grey: grey reads as broken) */
button:disabled {
  filter: saturate(0.7) brightness(0.62);
  cursor: default;
}

/* A filter replaces the whole list, so the pill repeats its own drop-shadow here. */
/* ======================================================================
   D. Entry screen
   ====================================================================== */

/* Logo at the top, play button low (pushed down by margin-top: auto), notice at the foot. */
.entry {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1.2em;
  padding: calc(1em + var(--safe-t)) 1em calc(1em + var(--safe-b));
  padding-top: calc(5vh + var(--safe-t));
  padding-bottom: calc(15vh + var(--safe-b));
  text-align: center;
}

/* Dark fade at the foot so the notice reads over any scenery. */
.entry::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16vh;
  background: linear-gradient(180deg, rgba(2, 10, 7, 0), rgba(2, 10, 7, 0.78));
  pointer-events: none;
}

/* On a short screen (phone browser bars) the column is too tall: only the logo may shrink.
   The button and the symbols keep their size, or the label would be squeezed out of its plate. */
.entry > * {
  flex-shrink: 0;
}
/* the logo stays in front of the mascot (her raised arms pass behind the letters) */
.entry-logo {
  position: relative;
  z-index: 2;
}

.entry-logo {
  width: min(86vw, 62vh, 34em);
  height: auto;
  aspect-ratio: 1888 / 780; /* its space is kept before the image arrives: nothing jumps */
  flex-shrink: 1;
  min-height: 0;
  object-fit: contain; /* shrinking keeps its proportions */
  filter: drop-shadow(0 0.6em 1em rgba(0, 0, 0, 0.6));
  animation: floaty 4.5s ease-in-out infinite;
}

.btn-play {
  grid-area: 1 / 1;
  font-size: 1.75em;
  /* a soft golden glow that breathes; the shadow under the button never switches off */
  filter: drop-shadow(0 0.25em 0.35em rgba(0, 0, 0, 0.45)) drop-shadow(0 0 0.7em rgba(255, 190, 60, 0.45));
  animation: play-breathe 1.8s ease-in-out infinite;
}

@keyframes play-breathe {
  50% {
    transform: scale(1.04);
    filter: drop-shadow(0 0.25em 0.35em rgba(0, 0, 0, 0.45)) drop-shadow(0 0 1.1em rgba(255, 200, 80, 0.8))
      brightness(1.08);
  }
}

/* Optical centring of the label on the painted button. */
.btn-play span {
  display: block;
  transform: translateY(-0.04em);
}

/* legal notice: on a small carved plate at the foot, never loose over the gold */
.disclaimer {
  --ph: 2.6em;
  position: absolute;
  left: 50%;
  bottom: calc(12px + 1em + var(--safe-b));
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: min(calc(100% - 1.6em), 34em); /* a long notice wraps to two lines instead of running into the caps */
  min-height: var(--ph);
  margin: 0;
  padding: 0.55em 2.9em; /* clear of the carved caps, with air above and below on two lines */
  text-align: center;
  text-wrap: balance;
  border: 1px solid transparent;
  border-image: url(../../art/pill.webp) 0 104 fill / 0 calc(var(--ph) * 0.578) stretch;
  font-size: 0.66em;
  font-weight: 700;
  line-height: 1.15;
  text-shadow: 0 0.08em 0 #000;
}

.age {
  display: grid;
  place-items: center;
  margin: 0;
  width: 2.6em;
  height: 2.6em;
  font-size: 0.75em;
  border: 0.14em solid #fff;
  border-radius: 50%;
}

/* ======================================================================
/* ======================================================================
   I. Overlays: coins, announcement, celebration
   ====================================================================== */

/* Canvas for coins and sparks, above the game and below the banners. */
.fx {
  position: absolute;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Dim layer. It has no z-index on purpose: it stays below the coins (30) and the HUD (32),
   while its content (.over-box, 31) rises above the coins. */
.announce,
.celebrate {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
}

.announce {
  background: rgba(2, 10, 7, 0.92);
  pointer-events: none;
}

.celebrate {
  /* a veil, not a wall: the table, the winning number and the croupier stay in the scene behind the title */
  background: radial-gradient(
    ellipse at 50% 46%,
    rgba(2, 10, 7, 0.82) 0%,
    rgba(2, 10, 7, 0.76) 45%,
    rgba(2, 10, 7, 0.66) 100%
  );
}

/* The overlay content lives inside the play area: JS places this box on the canvas rect.
   container-type: size lets everything inside scale with that window (cqw / cqh), so nothing crosses the frame. */
.over-box {
  position: absolute;
  z-index: 31;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2cqh;
  container-type: size;
  padding: 3cqh 2cqw;
}

/* Painted banner plate; it is a container too, so the text inside scales with the plate. */
.announce-card,
.banner {
  z-index: 31;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(80cqw, 88cqh);
  aspect-ratio: 1200 / 368;
  container-type: inline-size;
  text-align: center;
  background: url(../../art/banner.webp) center / 100% 100% no-repeat;
  filter: drop-shadow(0 0.8em 1.4em rgba(0, 0, 0, 0.7));
}

/* (no padding in %: it would follow the play area's width, not the plate's; fitText keeps the text on the glass) */
.announce-card {
  overflow: hidden;
  animation: banner-in 0.45s cubic-bezier(0.2, 1.5, 0.35, 1) both;
}

#announce-title {
  /* as big as the glass allows (the glass is about half the plate's height); fitText() shrinks longer texts */
  font-size: 11.5cqw;
  line-height: 1;
  white-space: nowrap;
}

/* The title stands above the plate. Every tier uses the same size so it always fits the window;
   higher tiers are told apart by the step-up burst (.banner.step), not by overflowing. */
/* The tier title is painted lettering (title-big/mega/epic.webp), sized to stay inside the play area. */
.cel-title {
  position: relative;
  z-index: 31;
  line-height: 0;
  /* room for the slam overshoot (scale 1.07): the title never touches the plate below, even for a frame */
  margin-bottom: 2.5cqh;
  animation: banner-in 0.5s cubic-bezier(0.2, 1.6, 0.35, 1) both;
}

.cel-title img {
  width: min(84cqw, 132cqh);
  height: auto;
  filter: drop-shadow(0 0.4em 0.6em rgba(0, 0, 0, 0.8));
}

.celebrate[data-tier='mega'] .cel-title img {
  width: min(88cqw, 146cqh);
}

.celebrate[data-tier='epic'] .cel-title img {
  width: min(92cqw, 160cqh);
}

/* a soft golden bloom behind title and amount: the "rays" of the celebration */
.celebrate .over-box::before {
  content: '';
  position: absolute;
  inset: -8% -4%;
  z-index: -1;
  background: radial-gradient(
    ellipse at 50% 42%,
    rgba(255, 196, 70, 0.34) 0%,
    rgba(255, 150, 20, 0.12) 38%,
    rgba(255, 150, 20, 0) 66%
  );
  pointer-events: none;
}

.banner {
  animation: banner-in 0.5s cubic-bezier(0.2, 1.6, 0.35, 1) both;
}

.banner.step {
  animation: banner-step 0.4s cubic-bezier(0.2, 1.7, 0.35, 1);
}

/* The amount fills the glass of the plate. */
.cel-amount {
  font-size: 13cqw;
  line-height: 1;
  color: var(--gold-1);
  text-shadow:
    0 0.07em 0 var(--gold-4),
    0 0.14em 0.2em #000;
}

/* the hint sits on its own small carved plate, so coins behind it never hurt its reading */
.skip {
  --ph: 2.3em;
  position: relative;
  z-index: 31;
  display: flex;
  align-items: center;
  height: var(--ph);
  padding: 0 1.9em;
  border: 1px solid transparent;
  border-image: url(../../art/pill.webp) 0 104 fill / 0 calc(var(--ph) * 0.578) stretch;
  font-size: min(3.6cqw, 7.5cqh, 0.8em);
  letter-spacing: 0.16em;
  text-shadow: 0 0.08em 0 #000;
  opacity: 0.92;
}

/* ======================================================================
   J. Sheets (rules, autospin) and toast
   ====================================================================== */

.sheet {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1em;
  background: rgba(2, 10, 7, 0.72);
}

/* The panel wears the table's own frame: felt inside the gold border (9 pieces, baked by nine.js). */
.sheet-card {
  --fb: 3em; /* the corner piece; the gold border itself is about a fifth of it */
  position: relative;
  display: flex;
  width: min(100%, 40em);
  min-width: 0;
  /* never taller than the screen: the body scrolls inside the frame */
  max-height: calc(100vh - 2em);
  max-height: calc(100dvh - 2em);
  border: var(--fb) solid transparent;
  border-width: calc(var(--fb) * 0.677) var(--fb);
  border-image: url(../../art/frame.webp) 153 226 fill stretch;
  filter: drop-shadow(0 1em 1.6em rgba(0, 0, 0, 0.75));
  animation: banner-in 0.3s cubic-bezier(0.2, 1.3, 0.35, 1) both;
}

/* painted close button, tucked inside the top-right corner of the panel */
.sheet-close {
  position: absolute;
  top: 0.2em;
  right: 0.2em;
  z-index: 2;
  width: 2.9em;
  height: 2.9em;
  border: 0;
  box-shadow: none;
  background: url(../../art/btn-close.webp) center / contain no-repeat;
}

.sheet-close svg {
  display: none;
}

.sheet-body h2 {
  padding: 0 2.2em;
}

/* on/off switch and "step through the choices" button: the game's own pill, never a native control */
.opt-row .btn-pill {
  flex: none;
  min-width: 8.8em;
  font-size: 1em;
  --ph: max(3.5em, 42px); /* a finger-sized target even on a small phone */
  height: var(--ph);
}

.opt-row span {
  text-align: left;
  color: var(--gold-1);
}

.sheet-body {
  overflow-y: auto;
  padding: 1.2em 1.1em;
  width: 100%;
  font-weight: 600;
  font-size: 0.82em;
  line-height: 1.4;
  -webkit-overflow-scrolling: touch;
}

.sheet-body h2 {
  margin: 0 0 0.5em;
  font-size: 1.5em;
  text-align: center;
}

.sheet-body h3 {
  margin: 1.1em 0 0.4em;
  color: var(--gold-2);
  font-size: 1.1em;
  letter-spacing: 0.05em;
}

.sheet-body p {
  margin: 0.4em 0;
}

.sheet-body {
  min-width: 0;
  min-height: 0;
}

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin: 0.6em 0;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(9em + var(--safe-b));
  z-index: 45;
  padding: 0.5em 1.1em;
  max-width: 90vw;
  font-size: 0.8em;
  text-align: center;
  border-radius: 1.2em;
  background: rgba(6, 16, 31, 0.92);
  border: 0.12em solid var(--gold-2);
  translate: -50% 0;
  pointer-events: none;
}

/* ======================================================================
   K. Animations and "less motion"
   ====================================================================== */

.shake {
  animation: shake 0.3s linear;
}

@keyframes floaty {
  50% {
    transform: translateY(-0.45em);
  }
}

@keyframes breathe {
  50% {
    transform: scale(1.05);
    filter: brightness(1.12);
  }
}

/* ---------- bonus banner: painted title, big text on the plate, note on a small plate ---------- */
.announce-art {
  position: relative;
  z-index: 31;
  width: min(84cqw, 118cqh);
  height: auto;
  filter: drop-shadow(0 0.4em 0.6em rgba(0, 0, 0, 0.8));
  animation: slam 0.5s cubic-bezier(0.2, 1.4, 0.35, 1) both;
}

.note {
  --ph: 2.9em;
  position: relative;
  z-index: 31;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ph);
  max-width: 94cqw;
  padding: 0.75em 2.9em; /* clear of the carved caps; a second line makes the plate taller instead of touching its border */
  border: 1px solid transparent;
  border-image: url(../../art/pill.webp) 0 104 fill / 0 calc(var(--ph) * 0.578) stretch;
  font-size: min(4cqw, 8cqh, 0.86em);
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
  color: #fff;
  text-shadow: 0 0.08em 0 #000;
}

/* ---------- beats ---------- */
.cel-title img.slam {
  animation: slam 0.5s cubic-bezier(0.2, 1.4, 0.35, 1) both;
}

/* the final number lands with a flash; it stays inside its plate */
.cel-amount.slam {
  animation: amount-hit 0.4s cubic-bezier(0.2, 1.4, 0.35, 1);
}

@keyframes amount-hit {
  0% {
    transform: scale(1.1);
    filter: brightness(2.2);
  }
  100% {
    transform: scale(1);
  }
}

.cel-title img.step {
  animation: step-punch 0.42s cubic-bezier(0.2, 1.6, 0.35, 1);
}

@keyframes slam {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  /* the overshoot is small on purpose: the title may not leave the play area, even for a frame */
  60% {
    transform: scale(1.07);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes step-punch {
  0% {
    transform: scale(1.07);
    filter: brightness(2.1) drop-shadow(0 0.4em 0.6em rgba(0, 0, 0, 0.8));
  }
  100% {
    transform: scale(1);
  }
}

@keyframes punch {
  0% {
    transform: scale(1.6);
    filter: brightness(1.8);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes jolt {
  35% {
    transform: translateY(0.22em);
  }
  70% {
    transform: translateY(-0.06em);
  }
}

/* every coin that lands makes the balance coin pop */
.coin-ico.bump {
  animation: coin-bump 0.18s ease-out;
}

@keyframes coin-bump {
  40% {
    transform: scale(1.35);
    filter: brightness(1.5);
  }
}

@keyframes pop {
  0% {
    transform: translateX(-50%) scale(1.35);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

@keyframes bump {
  40% {
    transform: scale(1.18);
  }
}

@keyframes ring {
  to {
    transform: rotate(360deg);
  }
}

@keyframes banner-in {
  0% {
    transform: scale(0.3) rotate(-4deg);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes banner-step {
  /* the step up is a flash, not a jump in size: the plate must stay inside the play area */
  0% {
    transform: scale(1.035);
    filter: brightness(2) drop-shadow(0 0.8em 1.4em rgba(0, 0, 0, 0.7));
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  15% {
    transform: translate(0.22em, -0.12em);
  }
  35% {
    transform: translate(-0.2em, 0.14em);
  }
  55% {
    transform: translate(0.14em, 0.1em);
  }
  75% {
    transform: translate(-0.08em, -0.06em);
  }
}

/* ======================================================================
   L. Living scenery and a HUD that answers back
   ====================================================================== */

/* Parallax: the cave is a little bigger than the screen and leans away from the pointer.
   On touch screens (no pointer to follow) it drifts slowly instead. */
.bg-img {
  scale: 1.05;
  translate: calc(var(--px, 0) * -1.2%) calc(var(--py, 0) * -0.8%);
  transition:
    translate 0.5s ease-out,
    opacity 0.9s ease;
}

@media (hover: none) {
  .bg-img {
    animation: bg-drift 26s ease-in-out infinite alternate;
  }
}

@keyframes bg-drift {
  from {
    translate: -1% 0;
  }
  to {
    translate: 1% -0.6%;
  }
}

/* A win lights the hall around the table: a soft local glow, never a full-screen flash. */
.bg-lit {
  inset: 0;
  background: radial-gradient(ellipse 80% 46% at 50% 44%, rgba(255, 190, 90, 0.4), transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.app.lit .bg-lit {
  opacity: 1;
}

.app.calm .bg-img {
  translate: none;
}

/* Spin button: the tap charges it, turbo spins the ring faster. */
.spin.busy.fast .spin-ring {
  animation-duration: 0.32s;
}
.spin.charge {
  animation: spin-charge 0.32s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes spin-charge {
  0% {
    transform: scale(0.86);
    filter: brightness(1.6) drop-shadow(0 0 1em rgba(255, 220, 120, 0.9));
  }
}

/* Numbers on a spring: mostly up and down, so they never push past the sides of their plate. */
#balance.spring,
#status-num.spring {
  animation: spring 0.42s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes spring {
  25% {
    transform: scale(1.04, 1.2);
  }
  50% {
    transform: scale(1.01, 0.92);
  }
  75% {
    transform: scale(1, 1.05);
  }
}

/* ---------- win in steps ---------- */
.cel-amount.mile {
  animation: mile 0.26s cubic-bezier(0.2, 1.5, 0.4, 1);
}

@keyframes mile {
  0% {
    transform: scale(1.03, 1.16);
    filter: brightness(1.7);
  }
}

/* Final seal: one line of gold runs around the plate. */
@property --seal {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.banner {
  position: relative;
}

.banner.seal::after {
  content: '';
  position: absolute;
  inset: 13% 6%;
  padding: 0.16em;
  border-radius: 999px;
  background: conic-gradient(from var(--seal), transparent 0 76%, #fff6c8 92%, transparent 100%);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
  filter: drop-shadow(0 0 0.3em #ffd24a);
  pointer-events: none;
  animation: seal 0.9s linear 1 both;
}

@keyframes seal {
  from {
    --seal: 0deg;
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  to {
    --seal: 360deg;
    opacity: 0;
  }
}

/* ---------- rules sheet in four short pages ---------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4em;
  margin: 0.5em 0 0.9em;
}

.tabs .btn-pill {
  min-width: 0;
  width: 100%;
  --ph: 3.3em;
  font-size: max(0.72em, 11px); /* readable on a 360 px phone */
  letter-spacing: 0.04em;
  /* ornate plates: the carved ends take about a quarter of each side, the label stays on the glass */
  padding-inline: 1.3em;
}

/* a narrow sheet: the tabs go in two rows, so each label sits on its plate's glass (never on the ends) */
@media (max-width: 560px) {
  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* the rules card keeps one height for every tab (no jump); a long page scrolls inside it */
.sheet-card:has(.tabs) {
  height: min(100dvh - 2em, 46em);
}

/* ---------- loading: a gold bar fills inside a carved pill, then TAP TO PLAY takes its place ---------- */
/* both live in ONE slot as tall as the button, so the swap moves nothing on the screen */
.entry-cta {
  flex-shrink: 0;
  margin-top: auto;
  display: grid;
  place-items: center;
  height: calc(1.75em * 3.1);
}

.loading {
  --ph: 2.6em;
  grid-area: 1 / 1;
  position: relative;
  flex-shrink: 0;
  width: min(78vw, 22em);
  height: var(--ph);
  border: 1px solid transparent;
  border-image: url(../../art/pill.webp) 0 104 fill / 0 calc(var(--ph) * 0.578) stretch;
  filter: drop-shadow(0 0.3em 0.5em rgba(0, 0, 0, 0.6));
}

/* the fill runs inside the glass of the pill (between the carved caps) */
.loading i {
  position: absolute;
  left: 9%;
  top: 30%;
  bottom: 30%;
  width: calc(82% * var(--p, 0));
  border-radius: 1em;
  background: linear-gradient(180deg, #fff3b0, #ffc93c 45%, #c97a00);
  box-shadow: 0 0 0.6em rgba(255, 200, 80, 0.8);
  transition: width 0.25s ease-out;
}

.loading span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.85em;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow:
    0 0.08em 0 #000,
    0 0 0.3em #000;
}

.loading[hidden] {
  display: none;
}
.btn-play.pop {
  animation:
    banner-in 0.45s cubic-bezier(0.2, 1.6, 0.35, 1) both,
    play-breathe 1.8s ease-in-out 0.45s infinite;
}

/* ---------- level badge and free-coins gift (top buttons) ---------- */
.btn-level {
  position: relative;
}

/* XP: a gold ring around the badge fills up to the next level */
.btn-level::before {
  content: '';
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background: conic-gradient(#ffd24a calc(var(--xp, 0) * 1turn), rgba(255, 255, 255, 0.12) 0);
  -webkit-mask: radial-gradient(circle, transparent 66%, #000 68%);
  mask: radial-gradient(circle, transparent 66%, #000 68%);
}

.btn-level b {
  position: relative;
  font-size: 1.05em;
  line-height: 1;
  color: var(--gold-1);
  text-shadow: 0 0.08em 0 #000;
}

.btn-level.up {
  animation: mult-punch 0.5s cubic-bezier(0.2, 1.6, 0.35, 1);
}

.btn-gift {
  position: relative;
}

.gift-dot {
  position: absolute;
  top: 6%;
  right: 6%;
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c4, #ffc93c 55%, #b86f00);
  box-shadow: 0 0 0.5em #ffd24a;
  animation: breathe 1.2s ease-in-out infinite;
}

.btn-gift:has(.gift-dot:not([hidden])) svg {
  stroke: #fff3b0;
  filter: drop-shadow(0 0 0.3em #ffc93c);
}

/* phones without a fullscreen API (iPhone) have no use for the fullscreen button */
#btn-full[hidden] {
  display: none;
}

.wheel-row {
  display: flex;
  justify-content: center;
  min-height: 3.4em;
  align-items: center;
}
.wheel-row .btn-gold {
  --ph: max(3em, 42px);
  font-size: 1em;
  min-width: 0;
  padding: 0 calc(var(--ph) * 0.95);
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}
#wheel-go {
  --ph: max(3em, 42px);
  font-size: 1em;
  min-width: 0;
  padding: 0 calc(var(--ph) * 0.9);
  flex: none;
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}
#coins-go {
  --ph: max(3.5em, 42px);
  min-width: 0;
  padding: 0 calc(var(--ph) * 0.75);
  flex: none;
}
.wait {
  color: var(--gold-1);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.opt-row small {
  display: block;
  color: #cfe2ff;
  font-size: 0.8em;
}

/* level sheet: XP bar */
.xp-bar {
  position: relative;
  height: 2.2em;
  margin: 0.8em 0;
  border-radius: 1.1em;
  background: rgba(3, 10, 26, 0.8);
  border: 0.12em solid var(--gold-2);
  overflow: hidden;
}

.xp-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(100% * var(--p, 0));
  background: linear-gradient(180deg, #fff3b0, #ffc93c 45%, #c97a00);
}
.xp-bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 0.08em 0 #000,
    0 0 0.3em #000;
}

/* ---------- daily wheel: its own full-screen moment, not a box ---------- */
.wheel-stage {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: min(2.2vh, 1.2em);
  padding: calc(1em + var(--safe-t)) 1em calc(1em + var(--safe-b));
  background: radial-gradient(ellipse at 50% 48%, rgba(20, 40, 90, 0.55) 0%, rgba(2, 10, 7, 0.94) 70%);
  overflow: hidden;
}

/* slow golden rays turning behind the wheel */
.ws-rays {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 180vmax;
  height: 180vmax;
  margin: -90vmax 0 0 -90vmax;
  background: repeating-conic-gradient(rgba(255, 210, 90, 0.16) 0deg 7deg, rgba(255, 210, 90, 0) 7deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 42%);
  mask: radial-gradient(circle, #000 0%, transparent 42%);
  animation: ws-turn 40s linear infinite;
  pointer-events: none;
}

@keyframes ws-turn {
  to {
    transform: rotate(360deg);
  }
}

.ws-title {
  position: relative;
  margin: 0 0 0.9em;
  line-height: 0;
} /* clear of the pointer under it */
/* painted lettering, like BIG WIN and FREE SPINS */
.ws-title img {
  width: min(82vw, 62vh, 30em);
  height: auto;
  filter: drop-shadow(0 0.3em 0.5em rgba(0, 0, 0, 0.7));
}

.ws-wheel {
  position: relative;
  width: min(88vw, 56vh, 34em);
  aspect-ratio: 1;
  flex-shrink: 0;
  animation: banner-in 0.5s cubic-bezier(0.2, 1.5, 0.35, 1) both;
}

.ws-wheel canvas {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 1em 1.4em rgba(0, 0, 0, 0.7)) drop-shadow(0 0 2em rgba(255, 200, 80, 0.35));
}

.ws-ptr {
  position: absolute;
  left: 50%;
  top: -6%;
  width: calc(20% * var(--ptr-ar, 0.7));
  transform: translateX(-50%);
  filter: drop-shadow(0 0.25em 0.35em rgba(0, 0, 0, 0.7));
}

/* the prize, on the carved banner plate, laid over the lower half of the wheel */
.ws-won {
  position: absolute;
  left: 50%;
  top: 79%;
  translate: -50% 0;
  width: 78%;
  aspect-ratio: 1200 / 368;
  display: grid;
  place-items: center;
  padding: 0 15%;
  container-type: inline-size;
  background: url(../../art/banner.webp) center / 100% 100% no-repeat;
  animation: banner-in 0.45s cubic-bezier(0.2, 1.6, 0.35, 1) both;
}

.ws-won b {
  font-size: 15cqw;
  line-height: 1;
  color: var(--gold-1);
  text-shadow:
    0 0.07em 0 var(--gold-4),
    0 0.14em 0.2em #000;
  white-space: nowrap;
}

.ws-actions {
  position: relative;
  display: flex;
  gap: 0.8em;
  align-items: center;
}
.ws-actions .btn-gold {
  --ph: max(3.2em, 52px);
  font-size: max(1.5em, 20px);
  min-width: 7.5em;
  padding: 0 calc(var(--ph) * 0.8);
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}
.ws-actions .btn-pill {
  --ph: max(3.7em, 46px);
  font-size: max(1em, 14px);
  min-width: 7em;
}
/* while it turns there is nothing to press: the button steps out (its place is kept) */
.wheel-stage.done:not(.won) #ws-go {
  visibility: hidden;
}
.wheel-stage.done #ws-later {
  display: none;
}
.app.calm .ws-rays {
  animation: none;
}

/* the Mascot watches the wheel from the corner (the screen edge cuts him); no room for him on a phone held upright */
.ws-mascot {
  position: fixed;
  left: 0.6em;
  bottom: -3%;
  height: min(60vh, 50vw);
  pointer-events: none;
  transform-origin: 50% 100%;
  animation: mascot-hype 0.32s ease-in-out infinite;
}
.wheel-stage.won .ws-mascot {
  animation: mascot-cheer 0.5s ease-in-out infinite;
}
@media (orientation: portrait) {
  .ws-mascot {
    display: none;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .ws-mascot {
    height: 34vh;
  }
}

/* the pointer flicks every time a peg passes it */
.ws-ptr {
  transform-origin: 50% 20%;
}
.ws-ptr.flick {
  animation: ws-flick 0.12s ease-out;
}
@keyframes ws-flick {
  40% {
    transform: translateX(-50%) rotate(-16deg);
  }
}

/* a win: the rays burn brighter and faster */
.wheel-stage.won .ws-rays {
  animation-duration: 9s;
  filter: brightness(2.2);
}

/* while the wheel is on, the effects layer (coins, sparks) plays OVER it */
.app.staging .fx {
  z-index: 46;
}

.wheel-stage.leaving {
  animation: ws-out 0.28s ease-in forwards;
}
@keyframes ws-out {
  to {
    opacity: 0;
  }
}

/* a short landscape phone: the wheel on the left, title and buttons on the right */
@media (orientation: landscape) and (max-height: 520px) {
  .wheel-stage {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-areas: 'wheel title' 'wheel actions';
    align-content: center;
    justify-content: center;
    column-gap: 2em;
  }
  .ws-wheel {
    grid-area: wheel;
    width: min(84vh, 50vw);
  }
  .ws-title {
    grid-area: title;
    align-self: end;
  }
  .ws-actions {
    grid-area: actions;
    align-self: start;
    flex-direction: column;
  }
}

/* ---------- painted gold numbers (src/ui/glyphs.js): each character is a piece of one atlas ---------- */
.glyph {
  display: inline-block;
  height: 0.86em;
  vertical-align: -0.1em;
  margin-right: -0.035em;
  background: url(../../art/font-gold.webp) no-repeat;
  background-size: calc(var(--glyph-atlas, 10) * 1em) 0.86em;
  filter: drop-shadow(0 0.05em 0.04em rgba(20, 8, 0, 0.95)) drop-shadow(0 0 0.12em rgba(0, 0, 0, 0.6));
}

/* ---------- top row: one menu button instead of three ---------- */
.top-buttons {
  position: relative;
}
.menu-pop {
  position: absolute;
  top: calc(100% + 0.4em);
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  animation: banner-in 0.25s cubic-bezier(0.2, 1.4, 0.35, 1) both;
}
.menu-pop[hidden] {
  display: none;
}
#btn-menu[aria-expanded='true'] .ico {
  filter: drop-shadow(0 0 0.35em #ffc93c) brightness(1.2);
}
.btn-level {
  margin-left: 0.3em;
} /* clear of the balance plate */

/* ---------- quick messages on a carved plate, never a flat black pill ---------- */
.toast {
  --ph: 2.9em;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--ph);
  padding: 0 calc(var(--ph) * 0.95);
  white-space: nowrap;
  font-size: 0.85em;
  color: #fff;
  text-shadow: 0 0.08em 0 #000;
  background: none;
  border-radius: 0;
  border: 1px solid transparent;
  border-image: url(../../art/pill.webp) 0 104 fill / 0 calc(var(--ph) * 0.578) stretch;
  filter: drop-shadow(0 0.3em 0.5em rgba(0, 0, 0, 0.6));
  animation: banner-in 0.3s cubic-bezier(0.2, 1.5, 0.35, 1) both;
}

/* ---------- loading screen: the Mascot ---------- */
.entry-mascot {
  position: fixed;
  left: 0.6em;
  bottom: -3%;
  height: min(62vh, 40vw);
  pointer-events: none;
  transform-origin: 50% 100%;
  animation: mascot-breathe 3.2s ease-in-out infinite;
}
.entry-mascot-cta {
  display: none;
}
@media (orientation: portrait) {
  /* upright phone: no free corner, so he stands behind TAP TO PLAY (the button hides where his legs are cut) */
  /* he stands big in the middle, behind TAP TO PLAY and the notice; the screen edge cuts his legs */
  /* centred by its margins, not by translate: Safari drew the first frames without the translate (the fox stood
     half off the right edge until the scripts ran) while its breathing animation was starting */
  .entry-mascot {
    left: 0;
    right: 0;
    margin-inline: auto;
    bottom: -7vh;
    height: min(66vh, 150vw);
    width: auto;
  }
  .entry-cta {
    position: relative;
  }
  .btn-play,
  .loading {
    position: relative;
    z-index: 1;
  }
}

/* a 9-slice piece baked into one picture by src/ui/nine.js: the browser's 9-piece drawing is switched off */
.nine {
  border-image: none !important;
  background-size: 100% 100% !important;
  background-origin: border-box !important;
  background-clip: border-box !important;
  background-repeat: no-repeat !important;
}

/* ---------- painted icons on the round buttons ---------- */
.btn-ico .ico {
  width: 58%;
  height: 58%;
  object-fit: contain;
  filter: drop-shadow(0 0.06em 0.06em rgba(0, 0, 0, 0.8));
  pointer-events: none;
}
.btn-ico .ico.off {
  display: none;
}
#btn-sound[aria-pressed='true'] .ico.on {
  display: none;
}
#btn-sound[aria-pressed='true'] .ico.off {
  display: block;
}
.app:fullscreen #btn-full .ico.on {
  display: none;
}
.app:fullscreen #btn-full .ico.off {
  display: block;
}
.btn-gift:has(.gift-dot:not([hidden])) .ico {
  filter: drop-shadow(0 0 0.35em #ffc93c) brightness(1.15);
}

/* painted digits are boxes: a number must never wrap between them (it did on a short screen) */
.cel-amount,
#win,
#announce-title,
.ws-won b {
  white-space: nowrap;
}

/* the open menu sits on its own dark carved panel, above whatever is under it */
.menu-pop {
  --fb: 1.7em;
  padding: 0;
  border: var(--fb) solid transparent;
  border-width: calc(var(--fb) * 0.677) var(--fb);
  border-image: url(../../art/frame.webp) 153 226 fill stretch;
  filter: drop-shadow(0 0.5em 0.8em rgba(0, 0, 0, 0.6));
}

/* short banners (level up): the table stays visible under a lighter veil, a painted burst turns behind the title */
.announce {
  background: rgba(2, 10, 7, 0.62);
}
.announce .over-box::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 42%;
  width: 120cqmin;
  aspect-ratio: 1;
  translate: -50% -50%;
  z-index: -1;
  background: url(../../art/burst.webp) center / contain no-repeat;
  opacity: 0.85;
  animation: ws-turn 18s linear infinite;
  pointer-events: none;
}
.app.calm .announce .over-box::after {
  animation: none;
}

/* the wheel's prize plate sits on its lower rim, not over the wedges */

/* Less motion: keep the state changes, drop the movement. */
.app.calm *,
.app.calm *::before,
.app.calm *::after {
  animation: none !important;
  transition: none !important;
}

/* the gold seal is pure motion: without it there is nothing to show */
.app.calm .banner.seal::after {
  display: none;
}

/* Phone in portrait with the browser bars showing: the em-based sizes drop under a finger's
   size, so every control keeps a 42 px floor (the art scales with the box). */
@media (orientation: portrait) {
  .btn-pill {
    --ph: max(3.7em, 42px);
  }
  .btn-round {
    width: max(2.7em, 42px);
    height: max(2.7em, 42px);
  }
  .btn-ico {
    width: max(2.75em, 42px);
    height: max(2.75em, 42px);
  }
}

/* the prize lands: a flash, no growth (it stays inside its plate) */
.ws-won b.slam {
  animation: ws-hit 0.45s ease-out;
}
@keyframes ws-hit {
  0% {
    filter: brightness(2.4);
  }
}

/* End of assets/ui/styles.css */
