/* ============================================================
   RESET & BASE
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: radial-gradient(ellipse at center, #1a0a2e 0%, #080808 70%);
  /* 100dvh = dynamic viewport height: excludes iOS Safari address bar */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  /* flex-start so the page scrolls naturally when content is taller than viewport */
  align-items: flex-start;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
  /* Safe-area insets for notched / Dynamic-Island iPhones */
  padding:
    max(1.25rem, env(safe-area-inset-top))
    max(1rem,    env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1rem,    env(safe-area-inset-left));
  overflow-y: auto;
  overflow-x: hidden;
}

/* Push machine to vertical centre when there is extra room,
   but allow scrolling when the machine is taller than the viewport */
body::before,
body::after {
  content: '';
  display: block;
  flex: 1 0 0;
  min-height: 0.5rem;
}

/* ============================================================
   MACHINE WRAPPER
   ============================================================ */
.machine-wrapper {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, #1e1e1e 0%, #2a2a2a 50%, #1e1e1e 100%);
  border: 3px solid #b8860b;
  border-radius: 22px;
  padding: 20px 20px 24px;
  box-shadow:
    0 0 0 1px #000,
    0 0 40px rgba(255, 180, 0, 0.25),
    0 0 80px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
}

/* Inner gold accent ring */
.machine-wrapper::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 18px;
  border: 1px solid rgba(184, 134, 11, 0.25);
  pointer-events: none;
}

/* ============================================================
   TITLE
   ============================================================ */
.machine-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.machine-title h1 {
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 5px;
  color: #ffb400;
  text-shadow:
    0 0 8px rgba(255, 180, 0, 0.9),
    0 0 20px rgba(255, 180, 0, 0.5),
    0 0 40px rgba(255, 140, 0, 0.3);
}

.title-icon {
  font-size: 22px;
}

/* ============================================================
   LIGHT STRIP (decorative blinking dots)
   ============================================================ */
.light-strip {
  display: flex;
  justify-content: space-around;
  margin-bottom: 14px;
}

.light-strip span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffb400;
  box-shadow: 0 0 6px rgba(255, 180, 0, 0.8);
  animation: blink 1.2s infinite;
}

.light-strip span:nth-child(even) {
  background: #ff4444;
  box-shadow: 0 0 6px rgba(255, 68, 68, 0.8);
  animation-delay: 0.6s;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

/* ============================================================
   STATS BAR — Credits / Bet / Winner Paid
   ============================================================ */
.stats-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  flex: 1;
  background: #080808;
  border: 2px solid #2a2a2a;
  border-radius: 8px;
  padding: 7px 8px 8px;
  text-align: center;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

.stat-label {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1.5px;
  color: #fff;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.stat-display {
  font-size: 22px;
  font-weight: bold;
  color: #ff3333;
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255, 51, 51, 0.7);
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

/* Bet box gets gold colour */
.bet-box .stat-display {
  color: #ffb400;
  text-shadow: 0 0 10px rgba(255, 180, 0, 0.7);
}

/* Credits bump animation on win */
@keyframes creditsBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.2); color: #ffd700; text-shadow: 0 0 14px rgba(255, 215, 0, 0.9); }
  100% { transform: scale(1); }
}

.credits-bump {
  animation: creditsBump 0.35s ease-out;
}

/* ============================================================
   REELS CONTAINER
   ============================================================ */
.reels-container {
  background: #0a0a0a;
  border: 4px inset #444;
  border-radius: 14px;
  padding: 16px 14px;
  margin-bottom: 14px;
  box-shadow: inset 0 6px 24px rgba(0, 0, 0, 0.9);
  position: relative;
  overflow: hidden;
}

/* CRT scanline overlay */
.reels-container::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.07) 3px,
    rgba(0, 0, 0, 0.07) 4px
  );
  pointer-events: none;
  border-radius: 10px;
}

.reels {
  display: flex;
  justify-content: space-around;
  gap: 10px;
}

/* ============================================================
   INDIVIDUAL REEL
   ============================================================ */
.reel {
  flex: 1;
  aspect-ratio: 1;
  max-width: 96px;
  background: #fff;
  border-radius: 12px;
  border: 3px solid #555;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 50px;
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: box-shadow 0.15s;
  position: relative;
  user-select: none;
}

/* Glow while spinning */
.reel.spinning {
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.35),
    0 0 18px rgba(255, 180, 0, 0.5),
    0 0 4px rgba(255, 180, 0, 0.3);
}

/* Win flash */
.reel.win-flash {
  animation: reelWinFlash 0.45s ease-in-out 3;
}

@keyframes reelWinFlash {
  0%   { box-shadow: inset 0 3px 10px rgba(0,0,0,0.35), 0 0 0px rgba(255,215,0,0); }
  50%  { box-shadow: inset 0 3px 10px rgba(0,0,0,0.35), 0 0 30px rgba(255,215,0,1), 0 0 60px rgba(255,165,0,0.6); }
  100% { box-shadow: inset 0 3px 10px rgba(0,0,0,0.35), 0 0 0px rgba(255,215,0,0); }
}

/* Jackpot reel pulse */
.reel.jackpot-flash {
  animation: reelJackpotFlash 0.3s ease-in-out 6;
}

@keyframes reelJackpotFlash {
  0%   { box-shadow: inset 0 3px 10px rgba(0,0,0,0.35), 0 0 0px rgba(255,0,255,0); }
  50%  { box-shadow: inset 0 3px 10px rgba(0,0,0,0.35), 0 0 40px rgba(255,215,0,1), 0 0 80px rgba(255,100,0,0.8); }
  100% { box-shadow: inset 0 3px 10px rgba(0,0,0,0.35), 0 0 0px rgba(255,0,255,0); }
}

/* ============================================================
   RESULT TEXT
   ============================================================ */
.result-area {
  min-height: 38px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.result-text {
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.4;
  transition: color 0.3s;
}

.result-text.win {
  color: #ffd700;
  font-size: 15px;
  font-weight: bold;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
  animation: resultPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-text.jackpot {
  color: #fff;
  font-size: 17px;
  font-weight: bold;
  text-shadow:
    0 0 10px rgba(255, 215, 0, 1),
    0 0 25px rgba(255, 165, 0, 0.9),
    0 0 50px rgba(255, 69, 0, 0.7);
  animation: jackpotPulse 0.6s ease-in-out infinite alternate, resultPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-text.loss {
  color: #fff;
  font-size: 18px;
}

@keyframes resultPop {
  0%   { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

@keyframes jackpotPulse {
  from { text-shadow: 0 0 10px rgba(255,215,0,1), 0 0 25px rgba(255,165,0,0.8); }
  to   { text-shadow: 0 0 20px rgba(255,215,0,1), 0 0 50px rgba(255,165,0,1), 0 0 80px rgba(255,69,0,0.9); }
}

/* ============================================================
   BET + SPIN BUTTON ROW (Vegas-style chunky buttons)
   ============================================================ */
.button-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

/* Shared chunky button base */
.bet-btn,
.spin-btn {
  padding: 18px 10px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
}

/* BET button — red casino lever feel, square-ish */
.bet-btn {
  flex: 0 0 34%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: linear-gradient(180deg, #ff3838 0%, #a10e0e 100%);
  color: #fff;
  letter-spacing: 1.5px;
  box-shadow:
    0 5px 0 #4d0000,
    0 7px 14px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.bet-btn-label {
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.9;
}

.bet-btn-value {
  font-size: 22px;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.bet-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #ff5656 0%, #c01818 100%);
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #4d0000, 0 9px 16px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.3);
}

.bet-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #4d0000, 0 3px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}

.bet-btn:disabled {
  background: linear-gradient(180deg, #484848 0%, #383838 100%);
  color: #777;
  cursor: not-allowed;
  box-shadow: 0 4px 0 #1a1a1a, 0 6px 12px rgba(0, 0, 0, 0.5);
  transform: none;
}

/* SPIN button — gold, takes the remaining width */
.spin-btn {
  flex: 1;
  font-size: 20px;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #ffd000 0%, #ff9500 100%);
  color: #000;
  box-shadow:
    0 5px 0 #8a5500,
    0 7px 14px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.spin-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe040 0%, #ffaa10 100%);
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #8a5500, 0 9px 16px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.35);
}

.spin-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #8a5500, 0 3px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.25);
}

.spin-btn:disabled {
  background: linear-gradient(180deg, #484848 0%, #383838 100%);
  color: #777;
  cursor: not-allowed;
  box-shadow: 0 4px 0 #1a1a1a, 0 6px 12px rgba(0, 0, 0, 0.5);
  transform: none;
}

/* ============================================================
   PRIZE BOARD BUTTON
   ============================================================ */
.prize-btn {
  width: 100%;
  padding: 13px;
  font-size: 16px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: transparent;
  border: 2px solid #555;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.prize-btn:hover {
  border-color: #b8860b;
  color: #ffb400;
}

/* ============================================================
   PRIZE BOARD MODAL (slide-up sheet)
   ============================================================ */
.prize-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.prize-overlay[hidden] {
  display: none;
}

.prize-modal {
  width: 100%;
  max-width: 440px;
  max-height: 82vh;
  background: #181818;
  border: 2px solid #b8860b;
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px 24px;
  overflow-y: auto;
  animation: slideUp 0.28s cubic-bezier(0.34, 1.1, 0.64, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.prize-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.prize-modal-header h2 {
  color: #ffb400;
  font-size: 15px;
  letter-spacing: 3px;
  text-shadow: 0 0 8px rgba(255, 180, 0, 0.5);
}

.prize-subhead {
  font-size: 13px;
  color: #fff;
  letter-spacing: 0.4px;
  margin-bottom: 14px;
  border-bottom: 1px solid #333;
  padding-bottom: 12px;
  opacity: 0.85;
}

.close-btn {
  background: none;
  border: 1px solid #444;
  color: #777;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}

.close-btn:hover {
  border-color: #ff4444;
  color: #ff4444;
}

/* ============================================================
   PRIZE LIST ROWS
   ============================================================ */
.prize-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.prize-row {
  display: flex;
  align-items: center;
  background: #0f0f0f;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 8px 11px;
  gap: 8px;
}

.prize-row.top-prize {
  background: #130f00;
  border-color: #5a3e00;
}

.prize-emojis {
  font-size: 17px;
  min-width: 72px;
  line-height: 1.3;
}

.prize-name {
  flex: 1;
  font-size: 13px;
  color: #ddd;
  letter-spacing: 0.2px;
}

.prize-credits {
  font-size: 15px;
  font-weight: bold;
  color: #ff5555;
  text-shadow: 0 0 6px rgba(255, 60, 60, 0.5);
  text-align: right;
  min-width: 36px;
  letter-spacing: 1px;
}

.prize-row.top-prize .prize-credits {
  font-size: 16px;
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.7);
}

/* ============================================================
   FULL-SCREEN WIN FLASH
   ============================================================ */
.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  animation: screenFlashFade 0.7s ease-out forwards;
}

.screen-flash.small { background: rgba(255, 215, 0, 0.08); }
.screen-flash.big   { background: rgba(255, 215, 0, 0.14); }
.screen-flash.mega  { background: rgba(255, 165, 0, 0.22); }

@keyframes screenFlashFade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================================================
   RESPONSIVE TWEAKS
   ============================================================ */

/* Medium-small phones (≤ 420px) */
@media (max-width: 420px) {
  .machine-wrapper {
    padding: 16px 14px 20px;
    border-radius: 18px;
  }

  .machine-title h1 {
    font-size: 20px;
    letter-spacing: 3px;
  }

  .reel {
    font-size: 40px;
    max-width: 88px;
  }

  .bet-btn,
  .spin-btn {
    padding: 15px 8px;
  }

  .spin-btn {
    font-size: 17px;
    letter-spacing: 3px;
  }

  .bet-btn-label { font-size: 10px; }
  .bet-btn-value { font-size: 19px; }

  .stat-display {
    font-size: 19px;
  }

  .stat-label {
    font-size: 11px;
    letter-spacing: 1px;
  }

  .result-text {
    font-size: 16px;
  }

  .result-text.win    { font-size: 17px; }
  .result-text.jackpot{ font-size: 18px; }
  .result-text.loss   { font-size: 16px; }
}

/* Small phones (≤ 360px — iPhone SE, Galaxy A series) */
@media (max-width: 360px) {
  .machine-wrapper {
    padding: 12px 10px 16px;
  }

  .machine-title h1 {
    font-size: 17px;
    letter-spacing: 2px;
  }

  .title-icon {
    font-size: 18px;
  }

  .reel {
    font-size: 34px;
    max-width: 76px;
    border-radius: 9px;
  }

  .stat-display {
    font-size: 16px;
  }

  .stat-label {
    font-size: 10px;
  }

  .bet-btn,
  .spin-btn {
    padding: 13px 6px;
  }

  .spin-btn {
    font-size: 15px;
    letter-spacing: 2px;
  }

  .bet-btn-label { font-size: 9px; }
  .bet-btn-value { font-size: 17px; }

  .prize-btn {
    font-size: 14px;
    padding: 11px;
  }

  .light-strip {
    margin-bottom: 10px;
  }

  .result-area {
    min-height: 32px;
    margin-bottom: 10px;
  }
}

/* ============================================================
   🤪 CRAZY COMBO EFFECTS
   ============================================================ */

/* Individual emoji that flies outward from the reels */
.emoji-burst {
  position: fixed;
  font-size: 26px;
  pointer-events: none;
  z-index: 400;
  transform-origin: center center;
  animation: emojiBurst 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes emojiBurst {
  0%   {
    transform: translate(-50%, -50%) scale(1.4) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)))
               scale(0.05) rotate(600deg);
    opacity: 0;
  }
}

/* Machine body shakes left-right on a crazy win */
.machine-shake {
  animation: machineShake 0.55s ease-in-out;
}

@keyframes machineShake {
  0%,  100% { transform: translateX(0)     rotate(0deg);    }
  12%        { transform: translateX(-11px) rotate(-1.8deg); }
  25%        { transform: translateX( 11px) rotate( 1.8deg); }
  37%        { transform: translateX( -8px) rotate(-1.2deg); }
  50%        { transform: translateX(  8px) rotate( 1.2deg); }
  62%        { transform: translateX( -5px) rotate(-0.6deg); }
  75%        { transform: translateX(  5px) rotate( 0.6deg); }
  87%        { transform: translateX( -2px); }
}

/* Prize board: highlight the crazy combo rows */
.prize-row.crazy-prize {
  background: #120800;
  border-color: #6b3300;
}

.prize-row.crazy-prize .prize-emojis {
  filter: saturate(1.4);
}

.prize-row.crazy-prize .prize-credits {
  color: #ff8c00;
  text-shadow: 0 0 8px rgba(255, 140, 0, 0.6);
}
