body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: linear-gradient(to bottom, rgba(46, 125, 50, 0.7), rgba(129, 199, 132, 0.7)), url('') center/cover no-repeat fixed;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  transition: background-image 1s ease-in-out;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  box-sizing: border-box;
}

.slot-machine {
  background-color: transparent;
  padding: 20px;
  border-radius: 15px;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

.game-title {
  font-family: 'Bangers', cursive;
  font-size: 3.5rem;
  color: #39ff14;
  -webkit-text-stroke: 2px #000;
  text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000,
               0 0 10px #39ff14, 0 0 20px #39ff14, 0 0 30px #00ff00;
  transform: rotate(-5deg);
  z-index: 2;
  position: relative;
  text-align: center;
  margin-bottom: 20px;
}

.paytable {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background-color: #f5f5dc;
  border: 3px solid #4a2c0b;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.paytable h2 {
  color: #333;
}

.paytable li img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.hidden {
  display: none;
}

.reels-container {
  position: relative;
  width: 620px;
  height: 460px;
  margin: 0 auto;
  z-index: 1;
  background: #f5f5dc;
  border: 3px solid #4a2c0b;
  border-radius: 10px;
  overflow: hidden;
  padding: 10px;
  box-sizing: border-box;
  max-width: 100%;
}

.reel {
  width: 110px;
  height: 440px;
  position: absolute;
  z-index: 1;
  overflow: hidden;
}

#reel1 { left: 0px; top: 10px; }
#reel2 { left: 122.5px; top: 10px; }
#reel3 { left: 245px; top: 10px; }
#reel4 { left: 367.5px; top: 10px; }
#reel5 { left: 490px; top: 10px; }

.reel-strip {
  position: absolute;
  width: 100%;
  display: flex;
  flex-direction: column;
  top: 0;
}

.grid-row {
  display: flex;
  width: 100%;
  height: 110px;
  flex-shrink: 0;
}

.grid-cell {
  width: 100%;
  height: 110px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  border: none;
}

.grid-cell img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.grid-cell img.blocker {
  border: none;
}

.reel-strip.spinning {
  animation: spin 0.5s linear infinite;
}

@keyframes spin {
  0% { transform: translateY(-5280px); }
  100% { transform: translateY(0); }
}

.control-panel {
  background: #4a2c0b;
  padding: 10px;
  border-radius: 10px;
  border: 2px solid #fff;
  max-width: 620px;
  margin: 0 auto;
  box-sizing: border-box;
}

.control-panel label {
  color: #fff;
  font-weight: bold;
}

.control-panel input {
  background: #fff;
  border: 2px solid #4a2c0b;
  color: #333;
}

.control-panel p {
  color: #fff;
  font-weight: bold;
}

.btn-primary {
  background-color: #ab47bc;
  border-color: #ab47bc;
  color: #fff;
  font-weight: bold;
  border-radius: 20px;
  padding: 10px 20px;
}

.btn-primary:hover {
  background-color: #8e24aa;
  border-color: #8e24aa;
}

.btn-success {
  background-color: #2e7d32;
  border-color: #2e7d32;
  color: #fff;
  font-weight: bold;
  border-radius: 20px;
  padding: 10px 20px;
}

.btn-success:hover {
  background-color: #1b5e20;
  border-color: #1b5e20;
}

.btn-danger {
  background-color: #d81b60;
  border-color: #d81b60;
  color: #fff;
  font-weight: bold;
  border-radius: 20px;
  padding: 10px 20px;
}

.btn-danger:hover {
  background-color: #b71c1c;
  border-color: #b71c1c;
}

.btn-secondary {
  background-color: #4a2c0b;
  border-color: #4a2c0b;
  color: #fff;
  font-weight: bold;
  border-radius: 20px;
  padding: 10px 20px;
}

.btn-secondary:hover {
  background-color: #3a2209;
  border-color: #3a2209;
}

#spin-button {
  touch-action: manipulation;
  z-index: 10;
}

#result {
  color: #fff;
  text-shadow: 1px 1px 2px #000;
  z-index: 2;
  position: relative;
}

@media (max-width: 768px) {
  .game-title {
    font-size: 2.5rem;
    -webkit-text-stroke: 1.5px #000;
    text-shadow: 1.5px 1.5px 0 #000, -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000,
                 0 0 8px #39ff14, 0 0 15px #39ff14, 0 0 25px #00ff00;
  }

  .reels-container {
    width: 450px;
    height: 344px;
    padding: 8px;
  }

  .reel {
    width: 82px;
    height: 328px;
  }

  #reel1 { left: 0px; top: 7.5px; }
  #reel2 { left: 91.5px; top: 7.5px; }
  #reel3 { left: 183px; top: 7.5px; }
  #reel4 { left: 274.5px; top: 7.5px; }
  #reel5 { left: 366px; top: 7.5px; }

  .reel-strip { height: 328px; }
  .grid-row, .grid-cell { height: 82px; }

  .grid-cell img {
    width: 75px;
    height: 75px;
  }

  @keyframes spin {
    0% { transform: translateY(-3936px); }
    100% { transform: translateY(0); }
  }

  .control-panel {
    max-width: 450px;
  }
}

@media (max-width: 576px) {
  .game-title {
    font-size: 2rem;
    -webkit-text-stroke: 1px #000;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
                 0 0 5px #39ff14, 0 0 10px #39ff14, 0 0 20px #00ff00;
  }

  .reels-container {
    width: 300px;
    height: 228px;
    padding: 6px;
  }

  .reel {
    width: 54px;
    height: 216px;
  }

  #reel1 { left: 0px; top: 5px; }
  #reel2 { left: 61px; top: 5px; }
  #reel3 { left: 122px; top: 5px; }
  #reel4 { left: 183px; top: 5px; }
  #reel5 { left: 244px; top: 5px; }

  .reel-strip { height: 216px; }
  .grid-row, .grid-cell { height: 54px; }

  .grid-cell img {
    width: 50px;
    height: 50px;
  }

  @keyframes spin {
    0% { transform: translateY(-2592px); }
    100% { transform: translateY(0); }
  }

  .control-panel {
    max-width: 300px;
  }

  .bet-buttons {
    flex-wrap: wrap;
    justify-content: center;
  }

  .bet-btn {
    min-width: 60px;
    padding: 6px 10px;
  }
}

@media (max-height: 450px) and (orientation: landscape) {
  .slot-machine {
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    justify-content: space-between;
  }

  .game-title {
    font-size: 1.5rem;
    -webkit-text-stroke: 1px #000;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
                 0 0 5px #39ff14, 0 0 10px #39ff14, 0 0 15px #00ff00;
    margin-bottom: 5px;
  }

  #paytable-button {
    display: none;
  }

  .reels-container {
    width: 350px;
    height: 266px;
    padding: 6px;
  }

  .reel {
    width: 63.5px;
    height: 254px;
  }

  #reel1 { left: 0px; top: 6px; }
  #reel2 { left: 70.75px; top: 6px; }
  #reel3 { left: 141.5px; top: 6px; }
  #reel4 { left: 212.25px; top: 6px; }
  #reel5 { left: 283px; top: 6px; }

  .reel-strip { height: 254px; }
  .grid-row, .grid-cell { height: 63.5px; }

  .grid-cell img {
    width: 58px;
    height: 58px;
  }

  @keyframes spin {
    0% { transform: translateY(-3048px); }
    100% { transform: translateY(0); }
  }

  .control-panel {
    background: transparent;
    border: none;
    padding: 0;
    position: fixed;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 200px;
  }

  .control-panel label,
  .control-panel input,
  .control-panel p {
    display: none;
  }

  #result {
    display: none;
  }

  .btn-success {
    padding: 8px 16px;
  }

  .bet-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .bet-btn {
    padding: 4px 8px;
    font-size: 0.9rem;
    border-radius: 8px;
  }
}

.sound-toggle {
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: 2px solid;
  border-radius: 5px;
  font-size: 24px;
  width: 50px;
  height: 50px;
}

.sound-off { border-color: #ff0000; }
.sound-on { border-color: #00ff00; }
.sound-toggle:hover { background: rgba(255, 255, 255, 0.2); }

.bet-buttons {
  display: flex;
  gap: 5px;
}

.bet-btn {
  background-color: #ab47bc;
  border: 2px solid #ab47bc;
  color: #fff;
  font-weight: bold;
  border-radius: 10px;
  padding: 5px 10px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.bet-btn:hover {
  background-color: #8e24aa;
  border-color: #8e24aa;
}

.bet-btn.active {
  background-color: #2e7d32;
  border-color: #2e7d32;
}

.bet-btn.active:hover {
  background-color: #1b5e20;
  border-color: #1b5e20;
}