/*
 * style.css — Firecracker slot UI.
 * Bao Zhu Zhao Fu (Chinese New Year firecracker) aesthetic: deep red + gold,
 * black machine frame, festive typography. Desktop-first (min 1024px target).
 */

:root {
  --red: #8B0000;
  --red-bright: #c81f1f;
  --gold: #FFD700;
  --gold-soft: #f5c542;
  --black: #111111;
  --panel: #1c0606;
  --panel-2: #2a0a0a;
  --text: #fff7e6;
  --muted: #d9b36b;
  --cell: #240808;
  --win: #00e676;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Noto Sans", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 50% -10%, #5a0000 0%, var(--black) 60%) fixed,
    var(--black);
  color: var(--text);
  position: relative;
  overflow-x: hidden;
}

/* ---------- Top bar + jackpot ticker ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px;
  background: linear-gradient(180deg, #3a0606, #1a0303);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.brand-glyph { font-size: 34px; }
.brand-name {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}
.brand-sub {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 2px;
}

.jackpot-ticker {
  display: flex;
  gap: 14px;
}
.jp {
  min-width: 120px;
  text-align: center;
  padding: 8px 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, #2a0808, #160404);
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 12px rgba(255, 215, 0, 0.15);
}
.jp-label {
  display: block;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
}
.jp-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}
.jp-grand { border-color: #ff3b3b; }
.jp-grand .jp-value { color: #ffec8b; }
.jp.flash { animation: jp-flash 0.9s ease; }
@keyframes jp-flash {
  0%, 100% { box-shadow: inset 0 0 12px rgba(255, 215, 0, 0.15); }
  50% { box-shadow: 0 0 28px rgba(255, 215, 0, 0.9); transform: scale(1.04); }
}

/* ---------- Stage / machine ---------- */
.stage {
  max-width: 1080px;
  margin: 28px auto;
  padding: 0 24px 48px;
}

.machine {
  position: relative;
  background: linear-gradient(180deg, #4a0a0a, #200505);
  border: 6px solid var(--gold);
  border-radius: 22px;
  padding: 28px;
  box-shadow:
    0 0 0 4px #5a0000,
    0 18px 48px rgba(0, 0, 0, 0.7),
    inset 0 0 40px rgba(0, 0, 0, 0.5);
}

.machine-lights {
  position: absolute;
  inset: 10px;
  border-radius: 16px;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg,
      rgba(255, 215, 0, 0.25) 0 6px,
      transparent 6px 26px);
  opacity: 0.35;
  mix-blend-mode: screen;
}

.reels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
  border: 3px solid #6b0d0d;
}

.reel {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
}

.cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(40px, 6vw, 72px);
  background: radial-gradient(circle at 50% 35%, #3a0c0c, var(--cell));
  border: 2px solid #7a1414;
  border-radius: 12px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  user-select: none;
}

/* Symbol emoji rendered as text (never as background-image / img) */
.symbol-emoji {
  font-size: clamp(40px, 6vw, 56px);
  line-height: 1;
  display: block;
  text-align: center;
  /* Ensure the platform colour-emoji font is used so glyphs never fall back
     to a broken/placeholder image. */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
    "Segoe UI Symbol", "Twemoji Mozilla", sans-serif;
  -webkit-font-smoothing: antialiased;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
  transition: transform 0.18s ease, filter 0.18s ease;
}

/* Per-symbol accent styling */
.cell[data-symbol="GRAND_FIRECRACKER"] { border-color: #ff3b3b; box-shadow: inset 0 0 18px rgba(255,59,59,.5); }
.cell[data-symbol="WILD"]   { border-color: var(--gold); box-shadow: inset 0 0 18px rgba(255,215,0,.45); }
.cell[data-symbol="SCATTER"]{ border-color: #ffd24d; }
.cell[data-symbol="DRUM"]   { border-color: #d98324; }
.cell[data-symbol="DRAGON"] { border-color: #2eb872; }
.cell[data-symbol="GOLD_COIN"] { border-color: #e6b800; }

/* ---------- Reel spin animation (slot-machine style) ---------- */
/* While a reel is spinning the emoji scrolls fast vertically with motion blur. */
.cell.spinning { overflow: hidden; }
.cell.spinning .symbol-emoji {
  animation: reel-scroll 0.16s linear infinite;
  filter: blur(2px) drop-shadow(0 2px 4px rgba(0,0,0,.55));
}
@keyframes reel-scroll {
  0%   { transform: translateY(-130%); }
  100% { transform: translateY(130%); }
}

/* When a reel stops it overshoots and settles (bounce). */
.cell.settling .symbol-emoji {
  animation: reel-settle 0.42s cubic-bezier(.18,.9,.32,1.45);
}
@keyframes reel-settle {
  0%   { transform: translateY(-46%); filter: blur(1.4px); }
  55%  { transform: translateY(14%);  filter: blur(0); }
  78%  { transform: translateY(-6%); }
  100% { transform: translateY(0);     filter: blur(0); }
}

/* Winning cells: gold border glow with a pulsing box-shadow. */
.cell.win {
  border-color: var(--gold);
  z-index: 2;
  animation: win-glow 0.75s ease-in-out infinite;
}
@keyframes win-glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.55), inset 0 0 8px rgba(255, 215, 0, 0.35);
    transform: scale(1.02);
  }
  50% {
    box-shadow: 0 0 30px rgba(255, 215, 0, 1), 0 0 48px rgba(255, 215, 0, 0.6), inset 0 0 18px rgba(255, 215, 0, 0.7);
    transform: scale(1.07);
  }
}
.cell.win .symbol-emoji {
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.9));
}

/* Hold-and-Spin: pulsing gold glow on held cells */
.cell.held {
  border-color: var(--gold);
  animation: held-pulse 1s ease-in-out infinite;
}
@keyframes held-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255,215,0,.4), inset 0 0 8px rgba(255,215,0,.3); }
  50% { box-shadow: 0 0 28px rgba(255,215,0,1), inset 0 0 18px rgba(255,215,0,.7); transform: scale(1.05); }
}

/* ---------- Win banner ---------- */
.win-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  border: 4px solid var(--gold);
  border-radius: 18px;
  padding: 20px 48px;
  text-align: center;
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
.win-banner.show {
  animation: win-pop 0.5s cubic-bezier(.2,.9,.3,1.4) forwards;
}
@keyframes win-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.win-banner-label {
  display: block;
  font-size: 22px;
  letter-spacing: 6px;
  color: var(--gold);
}
.win-banner-amount {
  display: block;
  font-size: 44px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 12px rgba(255,215,0,.8);
}

/* ---------- Hold overlay ---------- */
.hold-overlay {
  position: absolute;
  inset: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  pointer-events: none;
  z-index: 5;
}
.hold-text {
  background: rgba(17,17,17,.7);
  border: 3px solid var(--gold);
  color: var(--gold);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 6px;
  padding: 8px 28px;
  border-radius: 12px;
  animation: held-pulse 1.1s ease-in-out infinite;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 24px;
  padding: 18px 22px;
  background: linear-gradient(180deg, #2a0808, #170404);
  border: 3px solid var(--gold);
  border-radius: 16px;
  flex-wrap: wrap;
}

.balance, .bet-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}
.balance-label, .bet-label, .bet-unit { color: var(--muted); font-size: 14px; letter-spacing: 1px; }
.balance-value { font-size: 22px; font-weight: 800; color: var(--gold); }

.bet-buttons { display: flex; gap: 8px; }
.bet-btn {
  background: #3a0a0a;
  color: var(--text);
  border: 2px solid #7a1414;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.bet-btn:hover { border-color: var(--gold); }
.bet-btn.is-active {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: var(--black);
  border-color: #fff;
  box-shadow: 0 0 14px rgba(255,215,0,.6);
}

/* Bright red / gold SPIN button — high-contrast and prominent. */
.spin-btn {
  position: relative;
  min-width: 160px;
  min-height: 64px;
  padding: 16px 44px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--gold);
  background: linear-gradient(180deg, #e60000 0%, #CC0000 55%, #990000 100%);
  border: 3px solid var(--gold);
  border-radius: 14px;
  cursor: pointer;
  text-shadow: 0 2px 4px rgba(0,0,0,.7), 0 0 10px rgba(255,215,0,.4);
  box-shadow:
    0 6px 0 #6e0000,
    0 12px 26px rgba(0,0,0,.6),
    inset 0 0 16px rgba(255,215,0,.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.spin-btn:hover:not(:disabled) {
  transform: scale(1.05);
  filter: brightness(1.15);
  box-shadow:
    0 8px 0 #6e0000,
    0 16px 34px rgba(0,0,0,.65),
    0 0 26px rgba(255,215,0,.55),
    inset 0 0 22px rgba(255,215,0,.4);
}
.spin-btn:active:not(:disabled) {
  transform: translateY(4px) scale(1.0);
  box-shadow: 0 2px 0 #6e0000, inset 0 0 16px rgba(255,215,0,.3);
}
.spin-btn:disabled { cursor: not-allowed; filter: saturate(0.7) brightness(0.85); }
.spin-btn.loading { cursor: progress; }
.spin-btn.loading .spin-btn-text { visibility: hidden; }

/* Gold rotating ring shown while spinning. */
.spin-btn-spinner {
  display: none;
  position: absolute;
  left: 50%; top: 50%;
  width: 30px; height: 30px;
  margin: -15px 0 0 -15px;
  border: 4px solid rgba(255, 215, 0, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
  animation: spin 0.7s linear infinite;
}
.spin-btn.loading .spin-btn-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Fairness panel ---------- */
.fairness {
  margin-top: 26px;
  padding: 20px 24px;
  background: linear-gradient(180deg, #1e0606, #120303);
  border: 2px solid #6b0d0d;
  border-radius: 16px;
}
.fairness-title {
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--gold);
  letter-spacing: 1px;
}
.fairness-tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--muted);
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 8px;
  vertical-align: middle;
}
.fairness-grid { display: grid; gap: 8px; }
.fairness-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  align-items: baseline;
}
.fairness-key { color: var(--muted); font-size: 13px; }
.fairness-val {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
  background: #0c0202;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #3a0a0a;
}
.fairness-actions { margin-top: 14px; display: flex; align-items: center; gap: 14px; }
.verify-btn {
  background: #3a0a0a;
  color: var(--gold);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 8px 18px;
  font-weight: 700;
  cursor: pointer;
}
.verify-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.verify-result { font-weight: 700; }
.verify-result.ok { color: var(--win); }
.verify-result.bad { color: #ff5252; }
.fairness-note { margin-top: 12px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid #3a0a0a;
}

/* ---------- Confetti / firecracker ---------- */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}
.confetti {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  opacity: 0.95;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotateZ(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotateZ(720deg); opacity: 0.2; }
}
.spark {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  animation: spark-burst 0.9s ease-out forwards;
}
@keyframes spark-burst {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* ---------- P6: Visual polish ---------- */

/* TN10 TESTNET badge in the header */
.net-badge {
  margin-left: 12px;
  align-self: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #0c0202;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: 1px solid #fff3c0;
  border-radius: 999px;
  padding: 3px 12px;
  text-transform: uppercase;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.55);
  animation: badge-pulse 2.4s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }
  50% { box-shadow: 0 0 18px rgba(255, 215, 0, 0.85); }
}

/* Slow-drifting lantern / firecracker background (CSS only) */
.lantern-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.lantern {
  position: absolute;
  top: -12vh;
  left: var(--x, 50vw);
  font-size: 40px;
  opacity: 0.16;
  filter: drop-shadow(0 0 14px rgba(200, 31, 31, 0.6));
  animation: lantern-drift var(--dur, 30s) linear infinite;
  animation-delay: var(--delay, 0s);
  will-change: transform;
}
@keyframes lantern-drift {
  0%   { transform: translateY(0) translateX(0) rotate(-4deg); }
  50%  { transform: translateY(60vh) translateX(3vw) rotate(4deg); }
  100% { transform: translateY(120vh) translateX(0) rotate(-4deg); }
}
/* Keep interactive content above the drift layer. */
.topbar, .stage, .footer { position: relative; z-index: 1; }

/* Blinking gold light strip along the machine top edge */
.light-strip {
  position: absolute;
  top: -4px;
  left: 24px;
  right: 24px;
  height: 10px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 3;
  background-image: radial-gradient(circle, var(--gold) 0 3px, transparent 3px);
  background-size: 22px 10px;
  background-repeat: repeat-x;
  background-position: 0 50%;
  animation: strip-blink 1s steps(2, end) infinite;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
}
@keyframes strip-blink {
  0%   { background-position: 0 50%; opacity: 1; }
  50%  { background-position: 11px 50%; opacity: 0.4; }
  100% { background-position: 0 50%; opacity: 1; }
}

/* Symbol cells: subtle inner glow on hover */
.cell:hover {
  box-shadow: inset 0 0 22px rgba(255, 215, 0, 0.35), 0 0 14px rgba(255, 215, 0, 0.25);
  border-color: var(--gold-soft);
}
.cell:hover .symbol-emoji {
  transform: scale(1.08);
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.7));
}

/* Grand jackpot value pulses gold when it crosses a round number */
.jp-value.round-pulse {
  animation: grand-round-pulse 1.1s ease-in-out;
}
@keyframes grand-round-pulse {
  0%, 100% { transform: scale(1); text-shadow: 0 0 8px rgba(255, 215, 0, 0.5); color: #ffec8b; }
  50% { transform: scale(1.18); text-shadow: 0 0 22px rgba(255, 215, 0, 1), 0 0 40px rgba(255, 215, 0, 0.7); color: #fff3c0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .jackpot-ticker { flex-wrap: wrap; }
  .controls { flex-direction: column; align-items: stretch; }
  .fairness-row { grid-template-columns: 1fr; }
}
