:root {
  --dusk-blue: #4c6085ff;
  --blue-bell: #39a0edff;
  --aquamarine: #36f1cdff;
  --mint-leaf: #13c4a3ff;
  --charcoal-brown: #32322cff;

  --bg-dark: #242424;
  --bg-darker: #0f0f0f;
  --glass-bg: rgba(76, 96, 133, 0.15);
  --glass-border: rgba(54, 241, 205, 0.25);
  --glass-shadow: rgba(54, 241, 205, 0.08);
  --text-primary: #f0f4f8;
  --text-secondary: rgba(240, 244, 248, 0.6);

  --reel-height: clamp(180px, 48vh, 400px);
  --symbol-size: clamp(210px, 25vw, 300px);
  --spin-duration: 2s;
}

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

html, body {
  font-family: 'Montserrat', sans-serif;
  background: #242424;
  color: var(--text-primary);
  overflow: hidden;
  width: 100%;
  height: 100%;
  -webkit-user-select: none;
  user-select: none;
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.machine {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5vh 3vw;
  position: relative;
  background: #242424;
  gap: 1.5vh;
}

/* ===== HEADER ===== */
.machine-header {
  text-align: center;
  z-index: 10;
  flex-shrink: 0;
  margin-bottom: 0.5vh;
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.logo {
  width: clamp(80px, 12vh, 140px);
  height: clamp(80px, 12vh, 140px);
  object-fit: contain;
  filter: drop-shadow(0 0 30px rgba(54, 241, 205, 0.4));
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 30px rgba(54, 241, 205, 0.4)); }
  50% { filter: drop-shadow(0 0 55px rgba(54, 241, 205, 0.65)); }
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.brand-tagline {
  font-size: clamp(9px, 1.2vh, 13px);
  color: var(--text-secondary);
  letter-spacing: 4px;
  text-transform: uppercase;
  font-weight: 400;
}

.machine-header::after {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--aquamarine), transparent);
  margin: 0.8vh auto 0;
  opacity: 0.5;
}

/* ===== REELS ===== */
.reels-container {
  display: flex;
  gap: clamp(10px, 1.5vw, 18px);
  z-index: 10;
  position: relative;
  transition: opacity 0.4s ease, filter 0.4s ease;
  margin-bottom: 0.5vh;
  padding: clamp(8px, 1vh, 12px);
  background: rgba(54, 241, 205, 0.015);
  border-radius: 28px;
  border: 1px solid rgba(54, 241, 205, 0.07);
  flex-shrink: 0;
}

.reels-container::before,
.reels-container::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  z-index: 25;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(54, 241, 205, 0.6));
}

.reels-container::before {
  left: clamp(2px, 0.3vw, 4px);
  border-width: 7px 0 7px 9px;
  border-color: transparent transparent transparent rgba(54, 241, 205, 0.55);
}

.reels-container::after {
  right: clamp(2px, 0.3vw, 4px);
  border-width: 7px 9px 7px 0;
  border-color: transparent rgba(54, 241, 205, 0.55) transparent transparent;
}

.reels-container.hidden-result {
  opacity: 0;
  filter: blur(8px);
  pointer-events: none;
}

.reel {
  width: var(--symbol-size);
  height: var(--reel-height);
  background: linear-gradient(
    160deg,
    rgba(76, 96, 133, 0.28) 0%,
    rgba(50, 50, 44, 0.18) 55%,
    rgba(19, 196, 163, 0.10) 100%
  );
  border: 1px solid rgba(54, 241, 205, 0.22);
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.30),
    0 0 0 1px rgba(54, 241, 205, 0.06),
    0 0 24px rgba(54, 241, 205, 0.07);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.reel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.07) 0%,
    rgba(255, 255, 255, 0.03) 45%,
    transparent 100%
  );
  border-radius: 24px 24px 0 0;
  z-index: 6;
  pointer-events: none;
}

.reel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(8, 8, 10, 0.60) 0%,
    transparent 24%,
    transparent 76%,
    rgba(8, 8, 10, 0.60) 100%
  );
  border-radius: 24px;
  z-index: 4;
  pointer-events: none;
}

.reel.spinning {
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 40px rgba(54, 241, 205, 0.15);
}

.reel.won {
  animation: reelWinPulse 1.5s ease-in-out infinite;
  border-color: var(--aquamarine);
  box-shadow:
    0 0 30px rgba(54, 241, 205, 0.4),
    0 0 60px rgba(54, 241, 205, 0.2),
    inset 0 0 30px rgba(54, 241, 205, 0.1);
}

@keyframes reelWinPulse {
  0%, 100% { box-shadow: 0 0 30px rgba(54, 241, 205, 0.4), 0 0 60px rgba(54, 241, 205, 0.2); }
  50% { box-shadow: 0 0 50px rgba(54, 241, 205, 0.6), 0 0 90px rgba(54, 241, 205, 0.3); }
}

.reel-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform var(--spin-duration) cubic-bezier(0.15, 0.85, 0.3, 1);
  will-change: transform;
}

.symbol {
  width: var(--symbol-size);
  height: var(--reel-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  flex-shrink: 0;
}

.symbol img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease;
}

.reel-glow {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: radial-gradient(ellipse at center, rgba(54, 241, 205, 0.2), transparent 70%);
  z-index: 7;
}

.reel.won .reel-glow {
  opacity: 1;
  animation: glowPulse 1.5s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.reel.lost {
  animation: reelShake 0.5s ease-out;
}

@keyframes reelShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-4px); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-1px); }
}

/* ===== STATUS PANEL ===== */
.status-panel {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 20px);
  background: rgba(10, 15, 10, 0.7);
  border: 1px solid rgba(54, 241, 205, 0.15);
  border-radius: 14px;
  padding: clamp(10px, 1.5vh, 18px) clamp(20px, 3vw, 32px);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  margin-bottom: 0.5vh;
  min-width: 0;
  flex-shrink: 0;
}

.status-led {
  width: clamp(16px, 2vw, 24px);
  height: clamp(16px, 2vw, 24px);
  border-radius: 50%;
  background: #1a2e28;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
  flex-shrink: 0;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.status-led.on {
  background: #00ff41;
  box-shadow: 0 0 8px #00ff41, 0 0 16px rgba(0, 255, 65, 0.35);
}

.status-led.spinning {
  background: #ff2a2a;
  box-shadow: 0 0 8px #ff2a2a, 0 0 16px rgba(255, 42, 42, 0.4);
  animation: statusBlink 0.4s ease-in-out infinite alternate;
}

.status-led.warning {
  background: #ffaa00;
  box-shadow: 0 0 8px #ffaa00, 0 0 16px rgba(255, 170, 0, 0.4);
  animation: statusBlink 0.8s ease-in-out infinite alternate;
}

@keyframes statusBlink {
  from { opacity: 1; }
  to { opacity: 0.5; }
}

.status-display {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 16px);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  flex: 1;
  min-width: 0;
}

.status-row {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  min-width: 0;
}

.status-label {
  font-size: clamp(11px, 1.4vh, 15px);
  color: rgba(54, 241, 205, 0.55);
  letter-spacing: 2px;
  flex-shrink: 0;
}

.status-value {
  font-size: clamp(16px, 2.2vh, 22px);
  color: var(--aquamarine);
  text-shadow: 0 0 10px rgba(54, 241, 205, 0.4);
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-sep {
  width: 1px;
  height: clamp(20px, 2.5vh, 28px);
  background: rgba(54, 241, 205, 0.15);
  flex-shrink: 0;
}

/* ===== SPIN ACTION ===== */
.spin-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 0.5vh, 8px);
  z-index: 10;
  flex-shrink: 0;
  margin-top: auto;
  padding-bottom: 1vh;
}

.spin-text {
  font-size: clamp(11px, 1.4vh, 14px);
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--aquamarine);
  text-shadow: 0 0 10px rgba(54, 241, 205, 0.45);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.spin-text.visible {
  opacity: 1;
  transform: translateY(0);
  animation: spinTextPulse 1.6s ease-in-out infinite;
}

@keyframes spinTextPulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 10px rgba(54, 241, 205, 0.45); }
  50% { opacity: 0.6; text-shadow: 0 0 18px rgba(54, 241, 205, 0.7); }
}

/* ===== RESULT OVERLAY ===== */
.result-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: radial-gradient(ellipse at center, rgba(15, 15, 15, 0.94) 0%, rgba(15, 15, 15, 0.88) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.result-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.result-content {
  text-align: center;
  transform: scale(0.6);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-overlay.visible .result-content {
  transform: scale(1);
  opacity: 1;
}

.result-text {
  font-size: clamp(48px, 10vh, 110px);
  font-weight: 900;
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-bottom: 12px;
  line-height: 1.1;
}

.result-text.win {
  background: linear-gradient(135deg, var(--aquamarine), var(--blue-bell), var(--aquamarine));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 2s ease-in-out infinite;
  filter: drop-shadow(0 0 40px rgba(54, 241, 205, 0.5));
}

.result-text.lose {
  background: linear-gradient(135deg, var(--blue-bell), var(--dusk-blue), #8b7ec8, var(--blue-bell));
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: clamp(38px, 8vh, 88px);
  animation: gradientShift 3s ease-in-out infinite;
  filter: drop-shadow(0 0 40px rgba(57, 160, 237, 0.4));
}

.result-sub {
  font-size: clamp(14px, 2vh, 22px);
  color: var(--text-secondary);
  letter-spacing: 3px;
  font-weight: 400;
  text-transform: uppercase;
}

.result-overlay.visible .result-sub.win-sub {
  color: var(--aquamarine);
}

.result-overlay.visible .result-sub.lose-sub {
  color: var(--blue-bell);
}

.result-win-logo {
  width: clamp(240px, 32vh, 400px);
  height: clamp(240px, 32vh, 400px);
  margin: 0 auto 20px;
  animation: winLogoBounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 0 40px rgba(54, 241, 205, 0.5));
}

@keyframes winLogoBounce {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.result-lose-icon {
  font-size: clamp(56px, 9vh, 100px);
  margin-bottom: 16px;
  color: var(--blue-bell);
  filter: drop-shadow(0 0 30px rgba(57, 160, 237, 0.5));
  animation: loseIconBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes loseIconBounce {
  0% { transform: scale(0) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.result-overlay.visible.lose-overlay::before,
.result-overlay.visible.lose-overlay::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 2px solid rgba(57, 160, 237, 0.2);
  pointer-events: none;
}

.result-overlay.visible.lose-overlay::before {
  width: 350px;
  height: 350px;
  transform: translate(-50%, -50%);
  animation: losePulseRing 2.5s ease-out infinite;
}

.result-overlay.visible.lose-overlay::after {
  width: 500px;
  height: 500px;
  transform: translate(-50%, -50%);
  animation: losePulseRing 2.5s ease-out 0.5s infinite;
}

@keyframes losePulseRing {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}

/* ===== SYMBOL ANIMATIONS ===== */
.symbol.winning-symbol img {
  animation: symbolWin 0.6s ease-out;
}

@keyframes symbolWin {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.symbol.losing-symbol img {
  animation: symbolLose 0.8s ease-out forwards;
}

@keyframes symbolLose {
  0% { opacity: 1; transform: scale(1); }
  30% { opacity: 0.6; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

/* ===== CANVAS BACKGROUND PARTICLES ===== */
.bg-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.15;
  z-index: 1;
}

/* ===== WIN/LOSE BACKGROUND OVERLAYS ===== */
.machine.win-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(54, 241, 205, 0.12) 0%, transparent 70%);
  animation: winBgPulse 1.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 5;
}

@keyframes winBgPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.machine.lose-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(57, 160, 237, 0.08) 0%, transparent 70%);
  animation: loseBgPulse 2s ease-out forwards;
  pointer-events: none;
  z-index: 5;
}

@keyframes loseBgPulse {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes particleFloat {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.15;
  }
  90% {
    opacity: 0.15;
  }
  100% {
    transform: translateY(-100vh) translateX(50px);
    opacity: 0;
  }
}

/* ===== SCANLINES ===== */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.04;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.25) 0px,
    rgba(0, 0, 0, 0.25) 1px,
    transparent 1px,
    transparent 4px
  );
}

/* ===== RESPONSIVE ===== */
@media (max-height: 620px) {
  :root {
    --reel-height: clamp(140px, 40vh, 200px);
    --symbol-size: clamp(140px, 20vw, 190px);
  }
  .logo { width: 60px !important; height: 60px !important; }
}

@media (max-width: 780px) {
  :root {
    --reel-height: clamp(140px, 40vh, 200px);
    --symbol-size: clamp(140px, 22vw, 190px);
  }
}

/* Galaxy Tab A11+ landscape and similar large tablets */
@media (min-width: 1024px) and (min-height: 700px) {
  :root {
    --reel-height: clamp(220px, 52vh, 500px);
    --symbol-size: clamp(210px, 18vw, 320px);
  }
  .logo {
    width: clamp(90px, 10vh, 130px) !important;
    height: clamp(90px, 10vh, 130px) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
