:root {
  --bg: #3a0008;
  --bg-deep: #1c0004;
  --red: #c8102e;
  --red-dark: #7a0018;
  --gold: #ffd34d;
  --gold-light: #fff1a8;
  --gold-dark: #b8860b;
  --text: #fff6e0;
  --muted: #e8b9a0;
  --ruby: #ff3b4e;
  --sapphire: #3b8bff;
  --jade: #2fd47a;
  --radius: 12px;
  /* Grid cell size: fits five across the width, and the height on short
     phones. */
  --cell: min(calc((min(100vw, 520px) - 32px - 24px - 12px) / 5), 10.5vh);
}

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

html,
body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(90% 50% at 50% 30%, #8a0a1e, transparent 70%),
    linear-gradient(180deg, var(--bg), var(--bg-deep)) fixed;
  /* No double-tap zoom, no text selection, no grey tap flash. */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  touch-action: manipulation;
  cursor: pointer;
}

/* Portrait, one-handed: credits on top, the prize tower, the reels, and
   the spin and upgrade buttons at the bottom where the thumb rests. */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 6px) 16px 0;
}

/* ---------- Top bar ---------- */

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 211, 77, 0.4);
}

.credits {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.credits-coin {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 50%, var(--gold-dark));
  box-shadow: 0 0 8px rgba(255, 211, 77, 0.6);
}

.currency {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate {
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 4px;
  white-space: nowrap;
}

.rate strong {
  color: var(--text);
}

.icon-button {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.15rem;
}

/* ---------- Prize tower ---------- */

.tower {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 5px;
  padding: 6px 0;
  overflow: hidden;
}

/* A pagoda roof: a sweeping green eave with a gold edge. */
.roof {
  flex: none;
  height: 16px;
  margin: 0 8%;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: linear-gradient(180deg, #1f8a4c, #0d5a2e);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.jackpots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.plaque {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 6px 4px;
  border-radius: 10px;
  background: linear-gradient(180deg, #4a0010, #22000a);
  border: 2px solid var(--gold-dark);
  line-height: 1.1;
}

.plaque-name {
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.plaque-amount {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.jackpot.grand .plaque-name { color: #ff6ad5; }
.jackpot.major .plaque-name { color: #ff4d4d; }
.jackpot.minor .plaque-name { color: #6ab8ff; }
.jackpot.mini .plaque-name { color: #6dff9e; }

/* Extreme prize, guarded by a dragon on each side. */
.extreme-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.guardian {
  flex: none;
  font-size: 2.2rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 211, 77, 0.7));
}

.guardian.flip {
  transform: scaleX(-1);
}

.extreme.paying ~ .guardian {
  animation: blink 300ms steps(1) infinite;
}

.extreme {
  flex: 1;
  border-color: var(--gold);
  background: linear-gradient(180deg, #ff2d6f, #8a0030);
  box-shadow: 0 0 14px rgba(255, 45, 111, 0.55);
}

.extreme .plaque-name {
  color: var(--gold-light);
}

.extreme .plaque-amount {
  font-size: 1.15rem;
  color: #fff;
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* One meter: orb slots on the left, the prize it pays on the right. */
.meter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid currentColor;
}

.meter.ruby { color: var(--ruby); }
.meter.sapphire { color: var(--sapphire); }
.meter.jade { color: var(--jade); }

.meter.full {
  box-shadow: 0 0 12px currentColor, inset 0 0 10px currentColor;
}

.meter-slots {
  flex: 1;
  display: flex;
  gap: 6px;
}

.meter-label {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.05;
}

.meter-name {
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.meter-amount {
  color: var(--gold);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px dashed currentColor;
  opacity: 0.55;
  color: inherit;
  font-size: 0.6rem;
  font-weight: 900;
}

.slot.filled {
  opacity: 1;
  border: 2px solid var(--gold-light);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.meter.ruby .slot.filled { background: radial-gradient(circle at 35% 30%, #ffb3ba, var(--ruby) 55%, #8a0012); }
.meter.sapphire .slot.filled { background: radial-gradient(circle at 35% 30%, #b8d6ff, var(--sapphire) 55%, #0b3a8a); }
.meter.jade .slot.filled { background: radial-gradient(circle at 35% 30%, #b6ffd2, var(--jade) 55%, #0b6a36); }

.slot.landed {
  animation: slot-land 350ms ease-out;
}

.meter.paying,
.plaque.paying {
  animation: paying 250ms steps(1) 5;
}

.meters.fizzle .slot.filled {
  animation: fizzle 700ms ease-in forwards;
}

.tower-base {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.chests {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--gold-dark);
}

.chest-text {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--gold-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chest-bar {
  height: 8px;
  border-radius: 4px;
  background: #22000a;
  overflow: hidden;
}

.chest-bar.landed {
  animation: slot-land 350ms ease-out;
}

.chest-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-light));
  transition: width 300ms ease;
}

.spin-count {
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 10px;
  background: #0d5a2e;
  border: 2px solid var(--jade);
  font-size: 0.85rem;
  font-weight: 900;
  white-space: nowrap;
}

.spin-count.hot {
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold);
  animation: blink 600ms steps(1) infinite;
}

/* ---------- Reels ---------- */

.grid {
  flex: none;
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  justify-content: center;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: linear-gradient(180deg, #2a0510, #12000a);
  border: 3px solid var(--gold);
  box-shadow: 0 0 18px rgba(255, 211, 77, 0.35), inset 0 0 18px rgba(0, 0, 0, 0.8);
}

.reel {
  height: calc(var(--cell) * 3);
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, #3a1020, #1a0610 50%, #3a1020);
}

.strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.cell {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--cell);
  height: var(--cell);
  font-size: calc(var(--cell) * 0.6);
  line-height: 1;
}

.cell.letter {
  font-weight: 900;
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(var(--cell) * 0.62);
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.4);
}

.letter-A { color: #ff5a5a; }
.letter-K { color: #5ab0ff; }
.letter-Q { color: #4ce08a; }

/* Orbs: a glossy gem with its value on it. The ring is drawn inside the
   cell so orbs and symbols stay the same size in the strip. */
.cell.orb {
  border-radius: 50%;
  color: #fff;
  font-size: calc(var(--cell) * 0.22);
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  box-shadow: inset 0 0 0 2px var(--gold-light), 0 0 8px rgba(255, 255, 255, 0.3);
  transform: scale(0.86);
}

.cell.orb.ruby { background: radial-gradient(circle at 35% 30%, #ffb3ba, var(--ruby) 55%, #8a0012); }
.cell.orb.sapphire { background: radial-gradient(circle at 35% 30%, #b8d6ff, var(--sapphire) 55%, #0b3a8a); }
.cell.orb.jade { background: radial-gradient(circle at 35% 30%, #b6ffd2, var(--jade) 55%, #0b6a36); }

.cell.orb.jp {
  font-size: calc(var(--cell) * 0.17);
}

.slot.jp {
  font-size: 0.5rem;
}

.cell.win {
  animation: win-cell 400ms ease-in-out 3;
  border-radius: 8px;
}

.cell.collected {
  opacity: 0.25;
  transition: opacity 200ms ease;
}

.grid.tease {
  animation: tease 300ms ease-in-out infinite alternate;
}

/* ---------- Controls ---------- */

.controls {
  flex: none;
  padding: 8px 0 calc(env(safe-area-inset-bottom) + 12px);
}

.bet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.bet {
  flex: none;
  display: flex;
  align-items: center;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid var(--gold-dark);
}

.bet-step {
  width: 44px;
  height: 44px;
  color: var(--gold);
  font-size: 1.6rem;
  font-weight: 900;
}

.bet-step:disabled {
  color: #6a4a3a;
  cursor: default;
}

.bet-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  line-height: 1.05;
}

.bet-label {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.bet-value strong {
  color: var(--text);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.bet-value.raised strong {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 211, 77, 0.7);
}

.win-display {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.win-display.hit {
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 211, 77, 0.7);
}

.buttons {
  display: flex;
  gap: 10px;
}

.upgrades-button {
  position: relative;
  flex: none;
  width: 72px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1f8a4c, #0d5a2e);
  border: 2px solid var(--gold);
  font-size: 1.8rem;
}

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--ruby);
  border: 2px solid #fff;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 18px;
  animation: badge 1s ease-in-out infinite alternate;
}

.badge[hidden] {
  display: none;
}

.spin-button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 8px;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 25%, #ff7a7a, var(--red) 50%, var(--red-dark));
  border: 3px solid var(--gold);
  box-shadow: 0 6px 0 #4a000c, 0 8px 18px rgba(0, 0, 0, 0.5);
  color: #fff;
  touch-action: none;
}

.spin-button > * {
  pointer-events: none;
}

#spin-label {
  font-size: clamp(1.6rem, 8vw, 2.1rem);
  font-weight: 900;
  letter-spacing: 0.2em;
  line-height: 1;
  text-shadow: 0 2px 0 #4a000c;
}

.per-spin {
  margin-top: 2px;
  font-size: 0.75rem;
  color: #ffd9d9;
}

.spin-button.pulse {
  animation: press 140ms ease-out;
}


/* ---------- Upgrades sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background 200ms ease;
}

.sheet.open {
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

.sheet-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  max-height: 80dvh;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  border-radius: 20px 20px 0 0;
  background: linear-gradient(180deg, #5a0012, #2a0008);
  border-top: 3px solid var(--gold);
  transform: translateY(105%);
  transition: transform 250ms ease;
}

.sheet.open .sheet-panel {
  transform: translateY(0);
}

.sheet-title {
  margin-bottom: 8px;
  color: var(--gold);
  font-weight: 900;
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
}

.upgrade-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Keep vertical scrolling working with touch-action on the body. */
  touch-action: pan-y;
  padding: 2px 2px 8px;
}

.upgrade {
  flex: none;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "icon name owned"
    "icon effect cost";
  align-items: center;
  gap: 2px 12px;
  width: 100%;
  min-height: 60px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--gold);
  box-shadow: 0 0 10px rgba(255, 211, 77, 0.3);
  text-align: left;
  transition: transform 80ms ease, opacity 120ms ease;
}

.upgrade:active:not(:disabled) {
  transform: scale(0.98);
}

.upgrade:disabled {
  border-color: transparent;
  box-shadow: none;
  opacity: 0.45;
  cursor: default;
}

.upgrade.bought {
  animation: bought 450ms ease-out;
}

.upgrade-icon {
  grid-area: icon;
  font-size: 1.7rem;
  line-height: 1;
}

.upgrade-name {
  grid-area: name;
  font-weight: 700;
}

.upgrade-owned {
  grid-area: owned;
  justify-self: end;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.upgrade-effect {
  grid-area: effect;
  color: var(--jade);
  font-size: 0.85rem;
}

.upgrade-cost {
  grid-area: cost;
  justify-self: end;
  color: var(--gold);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.upgrade-cost::before {
  content: "● ";
  font-size: 0.7em;
  vertical-align: 0.15em;
}

.sheet-close {
  flex: none;
  margin-top: 8px;
  min-height: 52px;
  border-radius: 14px;
  background: var(--red);
  border: 2px solid var(--gold);
  font-weight: 900;
}

/* ---------- Deal bonus ---------- */

/* A treasure chest drawn in CSS: a red box with a gold lid and lock. */
.chest {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 22px;
  border-radius: 5px 5px 3px 3px;
  background: linear-gradient(180deg, #e8b04a 0 32%, #7a1a00 32% 38%, #c8102e 38%);
  border: 2px solid var(--gold);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.chest::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 28%;
  width: 6px;
  height: 7px;
  margin-left: -3px;
  border-radius: 2px;
  background: var(--gold-light);
  border: 1px solid #8a6200;
}

.fly-chest {
  position: fixed;
  z-index: 16;
}

.deal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  background: #0a0003;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

.deal.open {
  opacity: 1;
  pointer-events: auto;
}

.deal-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  height: 100%;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 12px);
  gap: 8px;
  background: radial-gradient(80% 40% at 50% 0%, #8a0a1e, transparent 70%);
}

.deal-title {
  color: var(--gold);
  font-size: clamp(1.4rem, 7vw, 2rem);
  font-weight: 900;
  font-style: italic;
  text-align: center;
  -webkit-text-stroke: 1px var(--red);
  text-shadow: 0 0 14px #ff6a00;
}

.deal-base {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.deal-base strong {
  color: var(--gold);
}

/* Prize board: every multiplier as an amount, smallest first. */
.deal-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-flow: column;
  grid-template-rows: repeat(6, auto);
  gap: 4px;
}

.deal-pill {
  padding: 2px 4px;
  border-radius: 6px;
  background: linear-gradient(180deg, #2a6ad8, #12347a);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: opacity 300ms ease, filter 300ms ease;
}

.deal-pill.high {
  background: linear-gradient(180deg, #ffcf3a, #b8860b);
  color: #3a1a00;
}

.deal-pill.out {
  opacity: 0.25;
  filter: grayscale(1);
  text-decoration: line-through;
}

.deal-boosts {
  min-height: 1.2em;
  color: var(--jade);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.deal-prompt {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
}

.deal-chests {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-content: center;
  gap: 6px;
}

.deal-chest {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 4px 0;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 211, 77, 0.5);
}

.deal-chest .chest {
  width: 30px;
  height: 24px;
}

.deal-chest-label {
  color: var(--gold-light);
  font-size: 0.7rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.deal-chest:disabled {
  cursor: default;
}

.deal-chest.mine {
  border-color: var(--gold);
  background: rgba(255, 211, 77, 0.2);
  box-shadow: 0 0 12px var(--gold);
}

.deal-chest.opened {
  border-color: transparent;
  background: none;
}

.deal-chest.opened .chest {
  opacity: 0.3;
  background: linear-gradient(180deg, #333 0 32%, #111 32% 38%, #444 38%);
  border-color: #666;
}

.deal-chest.opened .deal-chest-label {
  color: #aaa;
}

.deal-chest.mine.opened .deal-chest-label {
  color: var(--gold);
  font-size: 0.85rem;
}

.deal-chest.popping {
  animation: chest-pop 500ms cubic-bezier(0.2, 1.6, 0.4, 1);
}

.deal-bottom {
  flex: none;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.deal-offer {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, #0d5a2e, #06301a);
  border: 2px solid var(--gold);
}

.deal-offer.show {
  display: flex;
  animation: offer-in 400ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

.deal-offer-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.deal-offer-amount {
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: 900;
  text-shadow: 0 0 12px rgba(255, 211, 77, 0.7);
}

.deal-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
}

.deal-yes,
.deal-no,
.deal-collect {
  flex: 1;
  min-height: 56px;
  border-radius: 14px;
  border: 3px solid var(--gold);
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.deal-yes {
  background: radial-gradient(circle at 50% 25%, #7affb0, #1f8a4c 50%, #0d5a2e);
}

.deal-no {
  background: radial-gradient(circle at 50% 25%, #ff7a7a, var(--red) 50%, var(--red-dark));
}

.deal-collect {
  display: none;
  flex: none;
  background: radial-gradient(circle at 50% 25%, var(--gold-light), var(--gold) 50%, var(--gold-dark));
  color: #3a1a00;
}

.deal-collect.show {
  display: block;
}

.float-text.deal-low {
  color: var(--jade);
}

.float-text.deal-high {
  color: var(--ruby);
}

.league-button {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 72px;
  border-radius: 18px;
  background: linear-gradient(180deg, #2a4fa8, #12285e);
  border: 2px solid var(--gold);
  line-height: 1.1;
}

.league-icon {
  font-size: 1.6rem;
}

.league-rank {
  color: var(--gold-light);
  font-size: 0.85rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.league-button.up .league-rank { color: var(--jade); }
.league-button.down .league-rank { color: var(--ruby); }

/* ---------- League sheet ---------- */

.league-tiers {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.league-tier {
  font-size: 1.3rem;
  opacity: 0.35;
  filter: grayscale(1);
}

.league-tier.passed {
  opacity: 0.7;
  filter: none;
}

.league-tier.current {
  opacity: 1;
  filter: drop-shadow(0 0 6px var(--gold));
  transform: scale(1.35);
}

.league-info {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.league-result {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--gold-dark);
  font-size: 0.85rem;
  text-align: center;
}

.league-result.up { border-color: var(--jade); }
.league-result.down { border-color: var(--ruby); }

.league-result[hidden] {
  display: none;
}

.league-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 2px 2px 8px;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.league-row {
  display: grid;
  grid-template-columns: 2.2em 1.8em 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 10px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.league-row:nth-child(odd) {
  background: rgba(0, 0, 0, 0.2);
}

.league-row.up .league-place { color: var(--jade); }
.league-row.down .league-place { color: var(--ruby); }

.league-row.cut-up {
  border-bottom: 2px dashed var(--jade);
  border-radius: 10px 10px 0 0;
}

.league-row.cut-down {
  border-top: 2px dashed var(--ruby);
  border-radius: 0 0 10px 10px;
}

.league-row.you {
  background: linear-gradient(90deg, rgba(255, 211, 77, 0.35), rgba(255, 211, 77, 0.12));
  box-shadow: inset 0 0 0 2px var(--gold);
  font-weight: 900;
}

.league-place {
  color: var(--muted);
  font-weight: 900;
  text-align: right;
}

.league-avatar {
  font-size: 1.3rem;
  text-align: center;
}

.league-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.league-score {
  color: var(--gold);
  font-weight: 700;
}

/* ---------- Effects ---------- */

.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 45;
  overflow: hidden;
  pointer-events: none;
}

.fly-orb {
  position: fixed;
  z-index: 16;
  transform-origin: top left;
}

.float-text {
  position: fixed;
  transform: translate(-50%, -50%);
  color: var(--gold);
  font-size: 1.3rem;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(255, 211, 77, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  animation: float-up 800ms ease-out forwards;
}

.beam {
  position: fixed;
  width: 6px;
  margin-left: -3px;
  transform-origin: top center;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff, var(--gold) 30%, #ff6a00);
  box-shadow: 0 0 12px var(--gold), 0 0 24px #ff6a00;
  animation: beam 600ms ease-out forwards;
}

.coin {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 50%, var(--gold-dark));
  border: 2px solid #8a6200;
  transform: translate(-50%, -50%);
  animation: coin 1300ms cubic-bezier(0.3, 0, 0.7, 1) both;
}

.banner {
  position: fixed;
  left: 50%;
  top: 40%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  opacity: 0;
}

.banner.show {
  animation: banner 1500ms cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

.banner-title {
  font-size: clamp(2.2rem, 12vw, 4rem);
  font-weight: 900;
  font-style: italic;
  color: var(--gold);
  -webkit-text-stroke: 2px var(--red);
  text-shadow: 0 0 20px #ff6a00, 0 0 40px var(--gold);
  white-space: nowrap;
}

.banner.bonus .banner-title {
  color: #b6ffd2;
  -webkit-text-stroke: 2px #0b6a36;
  text-shadow: 0 0 20px var(--jade), 0 0 40px var(--gold);
}

.banner-amount {
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 14px var(--gold), 0 3px 6px rgba(0, 0, 0, 0.8);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 12px);
  width: calc(100% - 32px);
  max-width: 488px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #5a0012;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  font-size: 0.95rem;
  transform: translate(-50%, -150%);
  transition: transform 250ms ease;
  pointer-events: none;
  z-index: 50;
}

.toast.show {
  transform: translate(-50%, 0);
}

/* Short phones (iPhone SE and similar): a tighter tower. */
@media (max-height: 700px) {
  .deal-panel { gap: 5px; }
  .deal-pill { font-size: 0.65rem; padding: 1px 3px; }
  .deal-chest { min-height: 44px; }
  .deal-bottom { min-height: 120px; }
  .tower { gap: 3px; padding: 4px 0; }
  .roof { display: none; }
  .plaque { padding: 1px 6px 2px; }
  .plaque-amount { font-size: 0.85rem; }
  .extreme .plaque-amount { font-size: 0.95rem; }
  .guardian { font-size: 1.6rem; }
  .meter { padding: 2px 8px; }
  .slot { width: 24px; height: 24px; font-size: 0.55rem; }
  .spin-button { padding: 7px 0 5px; }
  .bet-row { margin-bottom: 4px; }
  .bet-step { height: 38px; }
  .controls { padding-top: 4px; }
}

/* ---------- Animations ---------- */

@keyframes blink {
  50% { opacity: 0.45; }
}

@keyframes press {
  50% { transform: translateY(4px); box-shadow: 0 2px 0 #4a000c, 0 4px 10px rgba(0, 0, 0, 0.4); }
}

@keyframes badge {
  to { transform: scale(1.15); }
}

@keyframes bought {
  0% { background: var(--gold); transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes win-cell {
  50% { background: rgba(255, 211, 77, 0.35); filter: brightness(1.4); }
}

@keyframes tease {
  from { box-shadow: 0 0 18px rgba(255, 211, 77, 0.35), inset 0 0 18px rgba(0, 0, 0, 0.8); }
  to { box-shadow: 0 0 34px var(--gold), inset 0 0 18px rgba(0, 0, 0, 0.8); }
}

@keyframes slot-land {
  0% { transform: scale(1.5); filter: brightness(2.5); }
  100% { transform: scale(1); }
}

@keyframes paying {
  0% { filter: brightness(1.8); transform: scale(1.03); }
  50% { filter: brightness(1); transform: scale(1); }
}

@keyframes chest-pop {
  0% { transform: scale(1.4); filter: brightness(2); }
  100% { transform: scale(1); }
}

@keyframes offer-in {
  from { transform: translateY(40px) scale(0.9); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes fizzle {
  to { opacity: 0; transform: scale(0.4); }
}

@keyframes float-up {
  from { opacity: 1; margin-top: 0; }
  to { opacity: 0; margin-top: -60px; }
}

@keyframes beam {
  0% { opacity: 0; clip-path: inset(0 0 100% 0); }
  30% { opacity: 1; clip-path: inset(0 0 0 0); }
  100% { opacity: 0; clip-path: inset(100% 0 0 0); }
}

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(-8deg); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
  25% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1.05); }
}

@keyframes coin {
  0% { opacity: 1; transform: translate(-50%, -50%) rotateY(0); }
  35% { transform: translate(calc(-50% + var(--dx) * 0.5), calc(-50% + var(--up))) rotateY(calc(var(--spin) * 0.4)); }
  100% { opacity: 0.9; transform: translate(calc(-50% + var(--dx)), calc(-50% + 70vh)) rotateY(var(--spin)); }
}

@media (prefers-reduced-motion: reduce) {
  .spin-button.pulse,
  .float-text,
  .upgrade.bought,
  .spin-count.hot,
  .badge,
  .grid.tease,
  .cell.win,
  .deal-chest.popping,
  .deal-offer.show,
  .slot.landed,
  .meter.paying,
  .plaque.paying {
    animation-duration: 1ms;
    animation-iteration-count: 1;
  }
  .banner.show {
    animation: none;
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}
