:root {
  --bg0: #1a0000;
  --bg1: #3a0503;
  --bg2: #4a0705;
  --gold: #ffb020;
  --gold-2: #ffe066;
  --flame-1: #ff4d1c;
  --flame-2: #ff8c1a;
  --panel: #0f0d12;
  --muted: #a89b9b;
  --cell-dark: #10131f;
  --cell-dark-2: #070810;
  --red: #d6001d;
  --black: #1a1a1a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: #f5f5f5;
  background:
    linear-gradient(160deg, rgba(26, 0, 0, 0.55), rgba(74, 7, 5, 0.65)),
    url("/assets/fire-texture.png") center/cover no-repeat scroll;
}

.layout {
  width: min(1080px, 96vw);
  margin: 1rem auto;
  padding: 1rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(120, 20, 10, 0.12), rgba(0, 0, 0, 0.3));
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0 0.2rem;
}

/* In-flow, not absolute: as a flex item it can never overlap the logo,
   the language toggle, or the demo chip (the old absolute pin sat on top
   of whichever control the 100%-wide logo row pushed to the right edge). */
.balance-pill {
  position: static;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4.5vw, 2.6rem);
  color: var(--gold);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 0 #6f2900, 0 0 15px rgba(255, 208, 102, 0.35);
}

.brand-logo {
  width: clamp(210px, 66vw, 660px);
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 14px rgba(255, 100, 20, 0.5)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

/* flex-basis instead of width:100% so the mode chip and language toggle
   share the header row instead of being pushed past the right edge. */
.logo-wrap { position: relative; display: flex; justify-content: center; flex: 1 1 300px; width: auto; min-width: 0; }

.sprinkle-zone {
  position: absolute;
  inset: -50% -30%;
  pointer-events: none;
  overflow: visible;
}

.sprinkle-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  object-fit: cover;
  filter: drop-shadow(0 0 8px rgba(255, 210, 90, 0.95));
  animation: sprinkle-fly 900ms ease-out forwards;
}

@keyframes sprinkle-fly {
  0% { transform: translate(0, 0) scale(0.3) rotate(0deg); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); opacity: 0; }
}

h2 { margin: 0 0 0.5rem; color: var(--gold-2); font-size: 1rem; }

.meta { display: flex; gap: 0.5rem; }

.pill {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  background: rgba(0, 0, 0, 0.28);
}

.stage { margin-top: 0.8rem; }

.scatter-rule {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0.5rem 0 0;
}

/* The ornate cabinet-frame.png overlay dictates the box's proportions (it
   has its own painted border/gold trim); the reels sit in its hollow
   center window via the matching percentage inset below. */
.slot-frame {
  position: relative;
  aspect-ratio: 1408 / 768;
  width: 100%;
}

.cabinet-frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.reels-wrap {
  position: absolute;
  left: 12.5%;
  right: 12.65%;
  top: 24.9%;
  bottom: 22.15%;
  overflow: hidden;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cell-dark-2);
}

.reels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  width: 100%;
  height: 100%;
  background: var(--cell-dark-2);
}

.reel-col {
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--cell-dark), var(--cell-dark-2));
  border-right: 3px solid var(--gold);
}

.reel-col:last-child { border-right: 0; }

.reel-strip { will-change: transform; transform-origin: 50% 50%; }
.reel-strip.spinning { filter: saturate(1.1); }

.cell {
  /* height is set inline by JS (measured from the actual rendered window,
     since the frame overlay now drives responsive sizing) so scroll math
     always matches what's on screen. */
  display: grid;
  place-items: center;
  border-bottom: 1px solid rgba(224, 172, 46, 0.16);
}

.cell img {
  width: 70%;
  height: 70%;
  object-fit: cover;
  border-radius: 50%;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55));
}

.cell.win { animation: pulse 560ms ease-in-out 2; }
.cell.scatter-win img { filter: drop-shadow(0 0 10px rgba(255, 221, 90, 0.9)); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.controls {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr repeat(5, auto);
  gap: 0.6rem;
  align-items: stretch;
}

.control-block {
  background: rgba(0, 0, 0, 0.36);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
}

.control-block label { display: block; color: var(--muted); font-size: 0.78rem; }

.control-block input,
.control-block select {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem;
  color: #f1f1f1;
  background: #2a2020;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.spin {
  background-image: url("/assets/button-gold.png");
  color: #4a1c00;
  text-shadow: 0 1px 0 rgba(255, 230, 180, 0.6);
  border: 0;
  min-width: 130px;
}

.alt {
  background-image: url("/assets/button-red.png");
  color: #fff3e0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  border: 0;
}
.alt:disabled { opacity: 0.5; cursor: not-allowed; }

.verify-link {
  display: block;
  margin: 0.7rem auto 0;
  background: none;
  border: 1px solid rgba(255, 176, 32, 0.4);
  color: var(--gold-2);
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  border-radius: 8px;
}
.verify-link:disabled { opacity: 0.45; cursor: not-allowed; }

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(122, 13, 13, 0.95);
  color: #fff5e6;
  border: 1px solid rgba(255, 220, 160, 0.4);
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  z-index: 60;
  max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 4, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
  overflow: auto;
}

.modal-overlay[hidden] { display: none; }

.modal-card {
  margin: auto;
  background: linear-gradient(180deg, #2a1704, #1a0f02);
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 1.4rem 1.6rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 176, 32, 0.25);
}

.modal-card h2 { margin-bottom: 0.2rem; }
.modal-card p { margin: 0.2rem 0; color: var(--muted); }
.modal-card strong { color: var(--gold); }

.playing-card {
  width: 120px;
  height: 168px;
  margin: 1rem auto;
  perspective: 800px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s ease;
  transform-style: preserve-3d;
}

.card-inner.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 800;
  border: 3px solid var(--gold-2);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.card-back {
  background: repeating-linear-gradient(45deg, #7a0d0d, #7a0d0d 10px, #5c0a0a 10px, #5c0a0a 20px);
  color: var(--gold-2);
}

.card-front {
  transform: rotateY(180deg);
  color: #fff;
  background: #333;
}

.card-front.red { background: linear-gradient(180deg, #e5162f, #7a0012); }
.card-front.black { background: linear-gradient(180deg, #3a3a3a, #0a0a0a); }

.gamble-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.card-btn { min-width: 100px; color: #fff; }
.card-btn.red { background: linear-gradient(180deg, var(--red), #7a0012); }
.card-btn.black { background: linear-gradient(180deg, #3a3a3a, var(--black)); }
.collect { background: linear-gradient(180deg, #2e7d32, #1b5e20); color: #fff; }

.gamble-result { min-height: 1.2rem; color: var(--gold-2) !important; font-weight: 600; }

/* Keeps the whole modal (incl. its buttons) reachable in short windows. */
@media (max-height: 620px) {
  .modal-card { padding: 0.9rem 1.1rem; }
  .playing-card { width: 76px; height: 106px; margin: 0.5rem auto; }
  .card-face { font-size: 1.9rem; }
  .card-btn { min-width: 78px; }
}

.results {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.results div {
  background: linear-gradient(180deg, rgba(58, 20, 4, 0.6), rgba(0, 0, 0, 0.5));
  border: 1px solid rgba(255, 176, 32, 0.3);
  border-radius: 10px;
  padding: 0.55rem;
}
.results span { display: block; color: var(--muted); font-size: 0.76rem; }
.results strong { display: block; margin-top: 0.25rem; font-size: 0.95rem; color: var(--gold-2); overflow-wrap: anywhere; }

.panels {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.panel th, .panel td { text-align: left; padding: 0.3rem 0.4rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.panel th { color: var(--muted); font-weight: 600; }

.panel ul { margin: 0; padding-left: 1.1rem; color: #e6e6e6; }
.panel ul li { margin: 0.2rem 0; }

.embers {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.embers span {
  position: absolute;
  bottom: -20px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe08a, #ff7a1a 70%, transparent);
  box-shadow: 0 0 6px 2px rgba(255, 140, 20, 0.6);
  animation: ember-rise linear infinite;
  opacity: 0;
}

.embers span:nth-child(1) { left: 6%; animation-duration: 9s; animation-delay: 0s; }
.embers span:nth-child(2) { left: 18%; animation-duration: 12s; animation-delay: 1.5s; }
.embers span:nth-child(3) { left: 30%; animation-duration: 8s; animation-delay: 3s; }
.embers span:nth-child(4) { left: 47%; animation-duration: 11s; animation-delay: 0.8s; }
.embers span:nth-child(5) { left: 61%; animation-duration: 10s; animation-delay: 2.4s; }
.embers span:nth-child(6) { left: 74%; animation-duration: 13s; animation-delay: 4s; }
.embers span:nth-child(7) { left: 85%; animation-duration: 9.5s; animation-delay: 1s; }
.embers span:nth-child(8) { left: 93%; animation-duration: 11.5s; animation-delay: 3.6s; }

@keyframes ember-rise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  8% { opacity: 0.9; }
  100% { transform: translateY(-100vh) translateX(18px); opacity: 0; }
}

.layout { position: relative; z-index: 1; }

.big-win-banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 0.2rem;
  background: rgba(10, 5, 0, 0.55);
  animation: bigwin-fade 2.2s ease-out forwards;
  pointer-events: none;
}

.big-win-text {
  font-size: clamp(1.8rem, 6vw, 3.2rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--gold-2);
  text-shadow: 0 0 18px rgba(255, 221, 118, 0.9), 0 3px 0 #6f2900;
  animation: bigwin-pop 0.5s ease-out;
}

.big-win-amount {
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 200, 80, 0.8);
}

@keyframes bigwin-pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes bigwin-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

.slot-frame.win-flash { animation: win-flash 560ms ease-in-out 2; }

@keyframes win-flash {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(0, 0, 0, 0.7), 0 0 18px rgba(224, 172, 46, 0.3); }
  50% { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(0, 0, 0, 0.5), 0 0 40px 8px rgba(255, 221, 118, 0.85); }
}

.spin {
  animation: spin-breathe 2.4s ease-in-out infinite;
}

.spin:active { transform: scale(0.94); }
.spin:disabled { animation: none; }

@keyframes spin-breathe {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 221, 118, 0); }
  50% { box-shadow: 0 0 14px 2px rgba(255, 221, 118, 0.55); }
}

@media (prefers-reduced-motion: reduce) {
  .cell.win { animation: none; }
  .marquee span, .embers span, .spin, .slot-frame.win-flash, .big-win-text { animation: none; }
  .embers { display: none; }
  .sprinkle-icon { animation: none; display: none; }
}

@media (max-width: 720px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .results { grid-template-columns: 1fr 1fr; }
  /* Paytable panels (the scatter table has 6 columns) were crushed into
     ~170px halves on phones; stack them full-width instead. */
  .panels { grid-template-columns: 1fr; }
}

/* ---- profit-practices presentation layer (display only) ---- */

.wins-ticker {
  margin-top: 0.55rem;
  min-height: 1.2em;
  text-align: center;
  font-size: 0.92rem;
  color: var(--gold-2);
  text-shadow: 0 0 8px rgba(255, 176, 32, 0.5);
}

.bet-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.chip-bet {
  background: #1c0f0c;
  color: #f5f5f5;
  border: 1px solid rgba(255, 176, 32, 0.35);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  font-weight: 700;
  cursor: pointer;
}

.chip-bet.active { background: var(--flame-1); border-color: var(--gold); color: #fff; }

.chip-bet.anchor {
  border-color: var(--gold);
  color: var(--gold-2);
  font-size: 1.02rem;
  padding: 0.35rem 0.85rem;
  box-shadow: 0 0 10px rgba(255, 176, 32, 0.45);
}

.chip-bet.anchor.active { background: var(--gold); color: #241a00; }

.auto-count {
  background: #1c0f0c;
  color: #f5f5f5;
  border: 1px solid rgba(255, 176, 32, 0.35);
  border-radius: 10px;
  padding: 0 0.4rem;
}

.almost-banner {
  position: absolute;
  left: 50%;
  top: 9%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--gold-2);
  text-shadow: 0 0 16px rgba(255, 221, 118, 0.95), 0 3px 0 #6f2900;
  pointer-events: none;
  animation: bigwin-pop 0.45s ease-out;
}

.cell.near {
  animation: pulse 500ms ease-in-out 3;
  background: radial-gradient(circle, rgba(255, 224, 102, 0.35), transparent 70%);
}

.cell.near img { filter: drop-shadow(0 0 10px rgba(255, 224, 102, 0.95)); }

.slot-frame.tease { animation: tease-pulse 0.5s ease-in-out infinite; }

@keyframes tease-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(255, 77, 28, 0.35); }
  50% { box-shadow: 0 0 44px 8px rgba(255, 176, 32, 0.85); }
}

.big-win-banner.tier-ldw { animation-duration: 1.3s; background: rgba(10, 5, 0, 0.4); }
.big-win-banner.tier-ldw .big-win-text { font-size: clamp(1.2rem, 4vw, 1.8rem); }
.big-win-banner.tier-big { animation-duration: 2.6s; }
.big-win-banner.tier-mega { animation-duration: 3.4s; }
.big-win-banner.tier-mega .big-win-text { color: #ffd76a; font-size: clamp(2rem, 7vw, 3.6rem); }
.big-win-banner.tier-epic { animation-duration: 4.2s; background: rgba(40, 0, 30, 0.6); }
.big-win-banner.tier-epic .big-win-text { color: #ff9df3; font-size: clamp(2.3rem, 8vw, 4.2rem); }

.recent-results {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.recent-strip { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.recent-chip {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 176, 32, 0.2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.85rem;
}

.recent-chip.won { color: var(--gold-2); border-color: rgba(255, 176, 32, 0.6); }

@media (prefers-reduced-motion: reduce) {
  .almost-banner, .cell.near, .slot-frame.tease { animation: none; }
}

/* Money-phase additions: mode chip, language toggle, gamble fairness line. */
.mode-chip {
  background: #4a2a85;
  color: #ffd968;
  border: 1px solid #f5b921;
}
.lang-btn {
  cursor: pointer;
  font: inherit;
}
.gamble-fair {
  font-size: 0.78rem;
  opacity: 0.75;
  word-break: break-all;
}
