body {
  background: linear-gradient(135deg, #181818 0%, #2c2c2c 100%);
  color: #fff;
  font-family: 'Anton', sans-serif;
  text-align: center;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
}

h1 {
  font-size: 50px;
  color: #e5c100;
  margin-top: 20px;
  text-shadow: 0 2px 8px #000, 0 0 2px #b30000;
  letter-spacing: 2px;
}

.machine {
  background: linear-gradient(160deg, #232323 60%, #b30000 100%);
  border: 8px solid #e5c100;
  border-radius: 28px;
  padding: 24px;
  width: 800px;
  margin: 50px auto;
  box-shadow: 0 8px 32px #000a, 0 2px 16px #e5c10044 inset;
  position: relative;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
  will-change: transform;
  transform: translateZ(0);
}

.machine::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
  background-size: 200% 200%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.machine.shake {
  animation: 
    shakeMachine 0.5s cubic-bezier(0.36, 0, 0.66, -0.56),
    machineGlow 1s infinite,
    machineIntensity 0.5s infinite;
  border-color: #b30000 !important;
  box-shadow: 0 0 18px #b30000, 0 0 10px #e5c10055 inset;
  background: linear-gradient(160deg, #232323 60%, #b30000 100%);
}

.machine.shake::before {
  opacity: 1;
  animation: gradientSlide 1s infinite linear;
}

.machine.win-glow {
  animation: 
    winGlow 0.6s,
    machineJump 0.3s ease-in-out;
}

@keyframes winGlow {
  0% { 
    box-shadow: 0 0 30px #ff0000;
    border-color: #ff0000;
  }
  20% { 
    box-shadow: 0 0 30px #ff7f00;
    border-color: #ff7f00;
  }
  40% { 
    box-shadow: 0 0 30px #ffff00;
    border-color: #ffff00;
  }
  60% { 
    box-shadow: 0 0 30px #7fff7f;
    border-color: #7fff7f;
  }
  80% { 
    box-shadow: 0 0 30px #e5c100;
    border-color: #e5c100;
  }
  100% { 
    box-shadow: 0 0 30px #ff0000;
    border-color: #ff0000;
  }
}

@keyframes machineIntensity {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

@keyframes shakeMachine {
  0%, 100% { 
    transform: rotate(0deg) scale(1);
  }
  20% { 
    transform: rotate(-1deg) scale(0.98);
  }
  40% { 
    transform: rotate(1deg) scale(1.01);
  }
  60% { 
    transform: rotate(-0.5deg) scale(0.99);
  }
  80% { 
    transform: rotate(0.5deg) scale(1.005);
  }
}

@keyframes gradientSlide {
  0% { background-position: -200% -200%; }
  100% { background-position: 200% 200%; }
}

@keyframes machineJump {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.tray {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, 100px);
  gap: 10px;
  margin: 20px 0;
  border: 4px solid #e5c100;
  border-radius: 13px;
  background: #181818;
  padding: 10px;
  box-shadow: 0 2px 12px #0008 inset, 0 1px 0 #fff2 inset;
  transition: border-color 0.3s, box-shadow 0.3s;
  position: relative;
}

.slot {
  background: linear-gradient(180deg, #232323 60%, #b30000 100%);
  border: 2px solid #e5c100;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 40px;
  box-shadow: 0 2px 8px #0008 inset, 0 1px 0 #fff1 inset;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s;
  animation: symbolAppear 0.3s ease-out;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.slot.win {
  animation: 
    winShine 2s linear infinite,
    winPulse 0.5s ease-in-out infinite;
  border-color: #7fff7f;
  box-shadow: 0 0 12px #7fff7f;
  background: linear-gradient(90deg, 
    transparent, rgba(255, 255, 255, 0.2), transparent);
  background-size: 200% 100%;
}

.slot.spinning {
  animation: slotSpin 0.1s infinite linear;
  transform-style: preserve-3d;
  perspective: 1000px;
}

@keyframes spinEffectCol {
  0% { transform: translateY(-2px); }
  50% { transform: translateY(2px); }
  100% { transform: translateY(-2px); }
}

@keyframes slotSpin {
  0% { 
    transform: rotateX(-90deg) translateY(-50px);
    opacity: 0.2;
  }
  100% { 
    transform: rotateX(0deg) translateY(0);
    opacity: 1;
  }
}

@keyframes symbolAppear {
  from {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes winPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.win-line {
  position: absolute;
  height: 12px;
  background: linear-gradient(90deg, 
    rgba(127,255,127,0), 
    #7fff7f 20%, 
    #ffffff 50%,
    #7fff7f 80%,
    rgba(127,255,127,0)
  );
  border-radius: 6px;
  box-shadow: 
    0 0 15px #7fff7f,
    0 0 30px #7fff7f,
    0 0 45px rgba(127,255,127,0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  animation: 
    glowLine 1.2s ease-in-out forwards,
    lineGlow 1s linear infinite,
    linePulse 2s ease-in-out infinite;
}

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

@keyframes linePulse {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.5); }
}

@keyframes glowLine {
  0% {
    opacity: 0;
    filter: blur(5px);
  }
  50% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 0.8;
    filter: blur(2px);
  }
}

.win-line.diagonal {
  transform-origin: 0 0;
}

.money-particle {
  position: fixed;
  pointer-events: none;
  font-size: 48px;
  animation: moneyFly 2s cubic-bezier(0.4, 0, 0.2, 1), moneyGlow 0.5s infinite;
  z-index: 9999;
  text-shadow: 
    0 0 20px #7fff7f,
    0 0 40px #fff,
    0 0 60px #7fff7f;
  filter: brightness(1.5);
  will-change: transform, opacity;
}

@keyframes moneyFly {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: scale(1.5) rotate(180deg);
  }
  100% {
    transform: 
      translate(var(--tx), var(--ty)) 
      scale(0) 
      rotate(var(--rot));
    opacity: 0;
  }
}

@keyframes moneyGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5); }
}

.tray.win-glow {
  animation: winGlowTray 0.6s;
}

@keyframes winGlowTray {
  0% { box-shadow: 0 0 24px 8px #7fff7f, 0 0 24px 8px #7fff7f33 inset; border-color: #7fff7f; }
  80% { box-shadow: 0 0 24px 8px #7fff7f, 0 0 24px 8px #7fff7f33 inset; border-color: #7fff7f; }
  100% { box-shadow: 0 2px 12px #0008 inset, 0 1px 0 #fff2 inset; border-color: #e5c100; }
}

.controls {
  margin-top: 20px;
  font-size: 24px;
}

button {
  background: linear-gradient(to bottom, #b30000, #e5c100);
  border: 2px solid #e5c100;
  border-radius: 10px;
  color: #fff;
  font-size: 1.2em;
  padding: 10px 30px;
  margin: 0 10px;
  cursor: pointer;
  transition: all 0.3s;
  min-height: 44px;
  min-width: 44px;
}

button:hover:not(:disabled) {
  background: linear-gradient(to bottom, #e5c100, #b30000);
  border-color: #b30000;
  transform: scale(1.05);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:active {
  transform: scale(0.98);
}

.spin-button {
  background: #b30000;
  border: 3px solid #e5c100;
  border-radius: 8px;
  color: white;
  padding: 15px 40px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  margin: 10px;
  font-family: 'Anton', sans-serif;
}

.spin-button:hover:not(:disabled) {
  background: #cc0000;
}

.spin-button:active:not(:disabled) {
  background: #990000;
}

.spin-button:disabled {
  background: #666666;
  border-color: #999999;
  cursor: not-allowed;
  opacity: 0.7;
}

@keyframes buttonPulse {
  0% { 
    box-shadow: 0 0 0 0 rgba(229, 193, 0, 0.7);
  }
  50% { 
    box-shadow: 0 0 0 15px rgba(229, 193, 0, 0);
  }
  100% { 
    box-shadow: 0 0 0 0 rgba(229, 193, 0, 0);
  }
}

.balance {
  font-size: 24px;
  margin-top: 10px;
  color: #e5c100;
  text-shadow: 0 0 4px #b30000;
}

.splash-win {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  color: #7fff7f;
  text-shadow: 0 0 20px #7fff7f, 0 0 40px #fff;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transform-style: preserve-3d;
  perspective: 1000px;
  will-change: transform, opacity;
}

.win-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: #7fff7f;
  text-shadow: 0 0 20px #7fff7f, 0 0 40px #fff;
}

.layer-0 { transform: translateZ(0px); }
.layer-1 { transform: translateZ(20px); opacity: 0.6; }
.layer-2 { transform: translateZ(40px); opacity: 0.3; }

@keyframes splashPop {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(-10deg);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2) rotate(5deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(0);
    opacity: 0;
  }
}

@keyframes splashPopBig {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(-20deg);
    opacity: 0;
  }
  10% {
    transform: translate(-50%, -50%) scale(1.5) rotate(10deg);
    opacity: 1;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.2) rotate(-5deg);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.3) rotate(0);
  }
  100% {
    transform: translate(-50%, -50%) scale(1) translateY(-100vh);
    opacity: 0;
  }
}

.big-win-text {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 120px;
  color: transparent;
  text-shadow: 0 0 10px rgba(255,255,255,0.8);
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  animation: 
    bigWinRainbow 2s linear infinite,
    bigWinPulse 0.5s ease-in-out infinite,
    bigWinFloat 3s ease-in-out infinite;
  background-clip: text;
  -webkit-background-clip: text;
  will-change: transform, opacity;
}

@keyframes bigWinRainbow {
  0% { background: linear-gradient(45deg, #ff0000, #ff7f00); }
  20% { background: linear-gradient(45deg, #ff7f00, #ffff00); }
  40% { background: linear-gradient(45deg, #ffff00, #00ff00); }
  60% { background: linear-gradient(45deg, #00ff00, #0000ff); }
  80% { background: linear-gradient(45deg, #0000ff, #4b0082); }
  100% { background: linear-gradient(45deg, #4b0082, #ff0000); }
}

@keyframes bigWinPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes bigWinFloat {
  0%, 100% { transform: translate(-50%, -50%); }
  50% { transform: translate(-50%, -60%); }
}

.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
}

.login-box {
  background: #232323;
  padding: 30px;
  border-radius: 20px;
  border: 4px solid #e5c100;
  box-shadow: 0 0 24px #000;
  text-align: center;
}

.login-box h2 {
  color: #e5c100;
  margin: 0 0 20px 0;
  font-size: 2em;
}

.login-box input {
  border: 2px solid #b30000;
  margin-bottom: 20px;
  outline: none;
  width: 220px;
  background: #181818;
  color: #fff;
  transition: border-color 0.2s;
}

.login-box input:focus {
  border-color: #e5c100;
}

.login-box input[type="password"] {
  margin-bottom: 12px;
}

.login-box button {
  background: linear-gradient(to bottom, #b30000, #e5c100);
  border: 2px solid #e5c100;
  border-radius: 10px;
  color: #fff;
  font-size: 1.2em;
  padding: 10px 30px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 0 8px #e5c100;
}

.login-box button:hover {
  background: linear-gradient(to bottom, #e5c100, #b30000);
  border-color: #b30000;
  color: #000;
}

.user-info {
  position: absolute;
  top: 18px;
  right: 40px;
  color: #e5c100;
  font-size: 1.1em;
  letter-spacing: 1px;
  z-index: 10;
  background: #232323cc;
  padding: 6px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 8px #0004;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stay-logged-in {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: #e5c100;
}

.stay-logged-in input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: #e5c100;
}

.stay-logged-in label {
  cursor: pointer;
  user-select: none;
}

.login-notice {
  color: #ff9900;
  font-size: 0.9em;
  margin-bottom: 10px;
  text-align: center;
  padding: 5px;
  background: rgba(255, 153, 0, 0.1);
  border-radius: 4px;
}

.disabled-field {
  text-decoration: line-through;
  opacity: 0.5;
  pointer-events: none;
}

.leaderboard-toggle {
  position: fixed;
  right: 20px;
  top: 20px;
  background: #e5c100;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s;
  z-index: 1000;
}

.leaderboard-toggle:hover {
  transform: scale(1.1);
}

.leaderboard {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh;
  background: linear-gradient(135deg, #232323 0%, #1a1a1a 100%);
  padding: 20px;
  box-shadow: -2px 0 10px rgba(0,0,0,0.5);
  transition: right 0.3s ease-in-out;
  z-index: 999;
  overflow-y: auto;
}

.leaderboard h3 {
  color: #e5c100;
  margin: 0 0 20px 0;
  font-size: 24px;
  text-align: center;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  margin-bottom: 5px;
  background: rgba(255,255,255,0.05);
  border-radius: 5px;
  transition: background 0.2s;
}

.leaderboard-list li:hover {
  background: rgba(255,255,255,0.1);
}

.leaderboard-list .user {
  color: #fff;
}

.leaderboard-list .balance {
  color: #e5c100;
  font-weight: bold;
}

@media (max-width: 1200px) {
  .leaderboard {
    transform: translateX(100%);
    border-radius: 18px 0 0 18px;
  }
  
  .leaderboard.show {
    transform: translateX(0);
  }

  .leaderboard-toggle {
    display: block;
  }
}

@media (max-width: 600px) {
  .leaderboard {
    width: 100%;
    right: -100%;
  }
  
  .leaderboard-toggle {
    right: 10px;
    top: 10px;
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .machine {
    width: 95%;
    margin: 20px auto;
    padding: 12px;
  }

  .tray {
    gap: 5px;
    padding: 5px;
  }

  .slot {
    font-size: 30px;
  }
}

@media (max-width: 768px) {
  .money-particle {
    display: none;
  }
  
  .win-line {
    animation: simpleGlow 0.8s ease-out forwards;
  }
  
  @keyframes simpleGlow {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
  }
}

/* Basic mobile styles */
@media (max-width: 800px) {
  .machine {
    width: 90%;
    max-width: 800px;
    margin: 20px auto;
    padding: 16px;
  }
}

/* Enhanced animations */
@keyframes floatingSymbols {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.symbol-float {
  animation: floatingSymbols 2s ease-in-out infinite;
}

@keyframes machineGlow {
  0% { box-shadow: 0 0 20px #e5c100; }
  50% { box-shadow: 0 0 40px #ff4d4d; }
  100% { box-shadow: 0 0 20px #e5c100; }
}

/* Mobile and touch device optimizations */
@media (max-width: 800px) {
    .leaderboard {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #232323 0%, #1a1a1a 100%);
        padding: 20px;
        box-shadow: -2px 0 10px rgba(0,0,0,0.5);
        transition: transform 0.3s ease-in-out;
        z-index: 999;
        overflow-y: auto;
        transform: translateX(100%);
    }

    .leaderboard.visible {
        transform: translateX(0);
    }

    .leaderboard-toggle {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        user-select: none;
        position: fixed;
        right: 10px;
        top: 10px;
        background: #e5c100;
        border: none;
        border-radius: 50%;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 24px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        transition: all 0.2s ease;
        z-index: 1000;
    }

    .leaderboard-toggle:active {
        transform: scale(0.95);
        background: #cc9900;
    }

    /* Prevent scrolling when leaderboard is open */
    body.leaderboard-open {
        overflow: hidden;
    }

    /* Larger touch targets for mobile */
    .leaderboard-list li {
        padding: 15px;
        margin-bottom: 8px;
    }
}

/* Fix iOS touch handling */
@media (hover: none) and (pointer: coarse) {
    .leaderboard-toggle:hover {
        transform: none;
    }

    .leaderboard-toggle:active {
        transform: scale(0.95);
        background: #cc9900;
    }
}
