:root {
  --bg: #0c0f14;
  --panel: #151a22;
  --panel-2: #1b222d;
  --accent: #ffd166;
  --accent-2: #06d6a0;
  --accent-3: #ef476f;
  --text: #e7edf5;
  --muted: #9fb2c8;
  --shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.03);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  /* Simple dark theme background, reduced effects for performance */
  background: #0b0f14;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0)) , rgba(0,0,0,.1);
  border-bottom: 1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(2px);
}

.topbar h1 {
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0;
}

/* Header logo */
.logo-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.logo-link .logo {
  display: block;
  height: 56px; /* default size; adjust as needed */
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.4));
}
@media (max-width: 600px) {
  .logo-link .logo {
    height: 44px;
  }
}

/* Jackpot bar */
/* old jackpot bar styles removed */

.stats {
  display: flex;
  gap: 18px;
  justify-self: center;
}

.stat {
  display: grid;
  gap: 2px;
  text-align: right;
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
}

.stat .value {
  font-weight: 700;
  color: var(--accent);
}

/* Header wallet area on the right */
.header-right {
  justify-self: end;
}
.wallet-controls.compact {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.wallet-status {
  color: var(--muted);
  font-size: 12px;
}

main {
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}

/* Body layout to place leaderboard middle-left */
.body-layout {
  position: relative;
  min-height: 260px;
  padding: 24px;
}
@media (min-width: 900px) {
  .body-layout {
    display: grid;
    grid-template-columns: 1fr;
  }
}

.machine {
  width: min(960px, 95vw);
  display: grid;
  gap: 24px;
  perspective: 1200px; /* enable subtle 3D reel tilt */
}

/* Casino-style Jackpot Marquee */
.jackpot-marquee {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
  margin: 6px auto -2px auto;
  z-index: 5;
  pointer-events: none;
}
.jackpot-marquee .marquee-top-arch {
  width: clamp(260px, 70%, 680px);
  height: 22px;
  border-top-left-radius: 999px;
  border-top-right-radius: 999px;
  background: radial-gradient(120% 200% at 50% 120%, rgba(255, 209, 102, .35), rgba(255,255,255,0)),
              linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,0));
  filter: drop-shadow(0 8px 24px rgba(255, 209, 102, .2));
}
.jackpot-marquee .marquee-body {
  position: relative;
  width: clamp(320px, 80%, 780px);
  padding: 18px 22px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #29160b, #17100b 60%, #1b120a),
              radial-gradient(150% 120% at 50% -20%, rgba(255, 209, 102, .18), transparent 56%);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow:
    0 10px 28px rgba(0,0,0,.45),
    inset 0 0 0 1px rgba(255,255,255,.05),
    inset 0 -14px 30px rgba(0,0,0,.35);
  display: grid;
  justify-items: center;
  row-gap: 4px;
}
.jackpot-marquee .marquee-title {
  pointer-events: none;
  font-weight: 900;
  letter-spacing: 3px;
  font-size: clamp(14px, 2.2vw, 18px);
  color: #ffe4a1;
  text-shadow: 0 1px 0 rgba(0,0,0,.4), 0 0 18px rgba(255, 209, 102, .35);
}
.jackpot-marquee .marquee-amount {
  pointer-events: none;
  font-weight: 900;
  font-size: clamp(28px, 6vw, 56px);
  letter-spacing: 1.5px;
  line-height: 1;
  padding: 6px 14px;
  border-radius: 12px;
  color: #fff7e6;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0));
  border: 1px solid rgba(255,255,255,.10);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.12),
    0 8px 24px rgba(255, 209, 102, .25),
    0 0 0 2px rgba(0,0,0,.25);
  text-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 24px rgba(255, 209, 102, .25);
}
.jackpot-marquee .marquee-lights {
  pointer-events: none;
  margin-top: 8px;
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
  filter: drop-shadow(0 4px 12px rgba(255, 209, 102, .2));
}
.jackpot-marquee .marquee-lights span {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd166, #ff9f1c 60%, #b76e00 100%);
  box-shadow: 0 0 10px rgba(255, 209, 102, .55);
  animation: bulb 1.4s linear infinite;
}
/* create a running lights effect */
.jackpot-marquee .marquee-lights span:nth-child(3n+1) { animation-delay: 0s; }
.jackpot-marquee .marquee-lights span:nth-child(3n+2) { animation-delay: .2s; }
.jackpot-marquee .marquee-lights span:nth-child(3n+3) { animation-delay: .4s; }

@keyframes bulb {
  0%, 100% { filter: brightness(1); transform: translateY(0); }
  50% { filter: brightness(1.4); transform: translateY(-1px) scale(1.05); }
}

.jackpot-marquee .marquee-bottom {
  width: clamp(300px, 76%, 740px);
  height: 10px;
  border-bottom-left-radius: 999px;
  border-bottom-right-radius: 999px;
  background: radial-gradient(120% 180% at 50% -20%, rgba(255, 209, 102, .22), rgba(255,255,255,0)),
              linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.06));
  box-shadow: 0 6px 18px rgba(0,0,0,.6);
}
/* Pulse the whole marquee when jackpot updates */
#jackpotMarquee.pulse .marquee-amount {
  animation: jpFlash 1.2s ease-in-out 1;
}
@keyframes jpFlash {
  0%, 100% { box-shadow:
    inset 0 1px 0 rgba(255,255,255,.12),
    0 8px 24px rgba(255, 209, 102, .25),
    0 0 0 2px rgba(0,0,0,.25); }
  50% { box-shadow:
    inset 0 1px 0 rgba(255,255,255,.18),
    0 14px 36px rgba(255, 209, 102, .45),
    0 0 0 2px rgba(0,0,0,.25); }
}

.bezel {
  position: relative;
  padding: 22px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: 16px;
  box-shadow: var(--shadow), 0 0 40px rgba(6,214,160,.06), inset 0 0 60px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.06);
  isolation: isolate;
}
.bezel::before,
.bezel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}
.bezel::before {
  background: radial-gradient(120% 80% at 50% -10%, rgba(6,214,160,.12), transparent 60%),
              radial-gradient(120% 80% at 50% 110%, rgba(239,71,111,.08), transparent 60%);
  mix-blend-mode: screen;
  z-index: 0;
}
.bezel::after {
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
  z-index: 1;
}

/* Overlay to draw winning lines */
.win-lines {
  position: absolute;
  /* Anchor to the reels box to keep proportions correct */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  display: block;
}
.win-lines polyline {
  fill: none;
  stroke: rgba(255,255,255,.65);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(255,255,255,.25));
}
.win-lines polyline.line-0 { stroke: #06d6a0; }
.win-lines polyline.line-1 { stroke: #ffd166; }
.win-lines polyline.line-2 { stroke: #ef476f; }
.win-lines polyline.line-3 { stroke: #8ecae6; }
.win-lines polyline.line-4 { stroke: #ff6b6b; }
.win-lines polyline.line-5 { stroke: #c77dff; }
.win-lines polyline.line-6 { stroke: #72efdd; }

.payline-indicator {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 2px;
}

.reels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  height: clamp(200px, 40vw, 320px);
  background: radial-gradient(120% 100% at 50% 50%, #0b0f14 0%, #070a0d 65%, #05080a 100%);
  padding: 14px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 6px 30px rgba(0,0,0,.45), inset 0 0 80px rgba(6,214,160,.05);
  transform-style: preserve-3d;
}
/* remove glossy highlight for simpler, faster background */
.reels::before { content: none; }

.reel {
  position: relative;
  background: linear-gradient(180deg, #0e141b, #0a0f14 60%, #0e141b);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.5),
              inset 0 -22px 44px rgba(0,0,0,.45),
              0 10px 22px rgba(0,0,0,.35);
  transform: translateZ(0);
}
.reel::after {
  /* inner neon rim */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 16px rgba(6,214,160,.08), inset 0 0 36px rgba(239,71,111,.04);
}
.spinning .reel {
  transform: rotateX(2deg) rotateY(-2deg);
  transition: transform .2s ease;
}

.strip {
  position: absolute;
  left: 0;
  right: 0;
  top: -100%;
  display: grid;
  gap: 8px;
  padding: 8px;
}

.symbol {
  position: relative;
  display: grid;
  place-items: center;
  /* 5 visible rows per reel */
  height: calc(100% / 5 - 6px);
  min-height: 44px;
  border-radius: 10px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.10), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
  border: 1px solid rgba(255,255,255,.08);
  outline: 1px solid rgba(0,0,0,.55);
  font-weight: 900;
  font-size: clamp(16px, 3.2vw, 24px);
  letter-spacing: 1.2px;
  text-shadow: 0 2px 8px rgba(0,0,0,.6), 0 0 22px rgba(0,0,0,.35);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 -10px 18px rgba(0,0,0,.35),
    0 6px 16px rgba(0,0,0,.35);
  backdrop-filter: saturate(1.1);
}
.symbol::before {
  /* neon edge */
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 14px rgba(6,214,160,.05), 0 0 28px rgba(239,71,111,.05);
}
.symbol.mid {
  /* subtle emphasis for center row */
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 -12px 20px rgba(0,0,0,.4),
    0 8px 20px rgba(0,0,0,.4);
}
.symbol.win {
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.16), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,0));
  transform: scale(1.04);
  box-shadow: 0 0 24px rgba(255,255,255,.18), 0 0 36px rgba(6,214,160,.22), inset 0 0 32px rgba(6,214,160,.12);
  border-color: rgba(255,255,255,.45);
}

/* Futuristic palette per symbol */
.symbol.cherry { color: #ff6b6b; text-shadow: 0 0 14px rgba(255,107,107,.35); }
.symbol.lemon { color: #ffee88; text-shadow: 0 0 14px rgba(255,238,136,.25); }
.symbol.orange { color: #ffb86c; text-shadow: 0 0 14px rgba(255,184,108,.25); }
.symbol.bell { color: #ffd166; text-shadow: 0 0 14px rgba(255,209,102,.35); }
.symbol.bar { color: #8ecae6; text-shadow: 0 0 14px rgba(142,202,230,.35); }
.symbol.seven { color: #ff006e; filter: drop-shadow(0 0 12px rgba(255,0,110,.45)); }
.symbol.diamond { color: #06d6a0; text-shadow: 0 0 14px rgba(6,214,160,.45); }
.symbol.thunder { color: #72efdd; text-shadow: 0 0 14px rgba(114,239,221,.45); }
.symbol.star { color: #ffd166; text-shadow: 0 0 14px rgba(255,209,102,.35); }

.payline {
  position: absolute;
  left: 10px; right: 10px;
  top: 50%;
  transform: translateY(-50%);
  height: 0;
  border-top: 2px dashed rgba(255,255,255,.18);
  box-shadow: 0 0 8px rgba(255,255,255,.08);
  pointer-events: none;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.bet-controls {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

#betInput {
  width: 120px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.25);
  color: var(--text);
  font-weight: 700;
  text-align: center;
}

.actions {
  display: inline-flex;
  gap: 10px;
}

.btn {
  appearance: none;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,0));
  color: var(--text);
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease, filter .2s ease;
  box-shadow: var(--shadow);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); filter: brightness(.95); }

.btn.primary {
  background: linear-gradient(180deg, #2b9348, #12743d);
  border-color: rgba(0,0,0,.5);
  color: #eafff5;
  box-shadow: 0 8px 24px rgba(6,214,160,.35), inset 0 0 0 1px rgba(255,255,255,.12);
}

.btn.secondary {
  background: linear-gradient(180deg, #2a3a4b, #1d2a37);
}

/* Auto mode active states for AUTO/STOP buttons */
#autoSpin.auto-active,
#stopAuto.auto-active {
  position: relative;
  box-shadow: 0 8px 24px rgba(255, 209, 102, 0.35), inset 0 0 0 1px rgba(255,255,255,.12);
  border-color: rgba(255, 209, 102, 0.65);
  background: linear-gradient(180deg, #3a2f10, #2b250e);
  color: #ffe9a6;
}
#autoSpin.auto-active::after {
  content: "AUTO ON";
  position: absolute;
  top: -9px;
  right: 10px;
  font-size: 10px;
  color: #ffd166;
  letter-spacing: .6px;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
#autoSpin.auto-active,
#stopAuto.auto-active {
  animation: autoPulse 1.3s ease-in-out infinite;
}
@keyframes autoPulse {
  0%, 100% { filter: brightness(1); box-shadow: 0 8px 24px rgba(255, 209, 102, 0.25), inset 0 0 0 1px rgba(255,255,255,.12); }
  50%      { filter: brightness(1.05); box-shadow: 0 12px 32px rgba(255, 209, 102, 0.45), inset 0 0 0 1px rgba(255,255,255,.18); }
}
/* Hover cues */
#autoSpin:not(.auto-active):hover {
  box-shadow: 0 8px 24px rgba(255,255,255,.15), inset 0 0 0 1px rgba(255,255,255,.12);
}
#stopAuto:not(:disabled):hover {
  box-shadow: 0 8px 24px rgba(239, 71, 111, .25), inset 0 0 0 1px rgba(255,255,255,.12);
}
/* Make STOP more “danger” colored when enabled/active */
#stopAuto:not(:disabled),
#stopAuto.auto-active {
  background: linear-gradient(180deg, #4a1f2a, #33141c);
  border-color: rgba(239, 71, 111, .6);
  color: #ffd9e1;
}

.payouts {
  margin-top: 4px;
  padding: 14px 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  color: var(--muted);
}

.payouts h3 {
  margin: 0 0 8px;
  color: var(--text);
}

.payouts ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px 12px;
  font-size: 14px;
}

.footer {
  padding: 14px 22px 24px;
  color: var(--muted);
  text-align: center;
}

/* Leaderboard UI */
.leaderboard.card {
  position: absolute;
  /* Middle-left positioning relative to body section */
  top: 50%;
  left: 24px;
  transform: translateY(-50%);
  width: min(380px, 92vw);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.03);
  padding: 12px;
}
.lb-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 10px;
}
.lb-header h3 {
  margin: 0;
  font-size: 18px;
}
.lb-sub {
  color: var(--muted);
  font-size: 12px;
}
.lb-table {
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  overflow: hidden;
}
.lb-row {
  display: grid;
  grid-template-columns: 44px 1fr 110px;
  gap: 0;
  align-items: center;
}
.lb-row.lb-head {
  background: rgba(255,255,255,.04);
  color: var(--text);
  font-weight: 700;
  letter-spacing: .3px;
}
.lb-rows {
  max-height: 360px;
  overflow: auto;
  background: rgba(0,0,0,.15);
}
.lb-rows .lb-row:nth-child(odd) {
  background: rgba(255,255,255,.02);
}
.lb-rows .lb-row:hover {
  background: rgba(255,255,255,.05);
}
.lb-col {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 14px;
}
.lb-head .lb-col {
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.lb-col.rank { text-align: right; color: var(--muted); font-weight: 700; }
.lb-col.player { font-weight: 700; }
.lb-col.score { text-align: right; color: var(--accent); font-weight: 800; }

/* Responsive: move leaderboard below on small screens */
@media (max-width: 920px) {
  .leaderboard.card {
    position: static;
    transform: none;
    width: 100%;
    margin: 0 0 16px 0;
  }
  .body-layout {
    padding: 16px;
  }
}

/* Wallet modal */
.wallet-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.wallet-modal.hidden { display: none; }
.wallet-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}
.wallet-modal-content {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.03);
  padding: 18px;
}
.wallet-modal-content h3 {
  margin: 0 0 12px;
  text-align: center;
  letter-spacing: .5px;
}

/* Warning modal specifics */
.warn-message {
  margin: 8px 0 14px;
  color: var(--text);
  text-align: center;
}
.warn-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}
.wallet-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 6px 2px 2px;
}
.wallet-btn {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
  color: var(--text);
  cursor: pointer;
  transition: transform .06s ease, background .2s ease, box-shadow .2s ease;
}
.wallet-btn:hover { transform: translateY(-1px); }
.wallet-btn .icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  display: grid; place-items: center;
  font-size: 18px;
}
.wallet-btn .name { font-weight: 700; }
.wallet-btn .status {
  color: var(--muted);
  font-size: 12px;
}
.close-btn {
  margin-top: 12px;
  width: 100%;
}

/* Animations */
.spinning .reel {
  outline: 2px solid rgba(255,255,255,.06);
}

.win-flash {
  animation: flash 800ms ease-in-out 0s 1;
}
@keyframes flash {
  0%, 100% { box-shadow: 0 0 0 rgba(255,255,255,0); }
  50% { box-shadow: 0 0 0 6px rgba(255,255,255,.12), 0 0 60px rgba(6,214,160,.18); }
}

/* Symbol glow when on the payline and part of a win */
.symbol.win {
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,0));
  transform: scale(1.03);
  box-shadow: 0 0 24px rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.35);
}

/* Utilities for hiding text during spin */
.hide-during-spin {
  transition: opacity .2s ease;
}
.spinning .hide-during-spin { opacity: 0.35; }

/* removed 3D canvas styles */
