:root {
  --bg: var(--tg-theme-secondary-bg-color);
  --card: var(--tg-theme-secondary-bg-color, #fff);
  --accent: var(--tg-theme-button-color, #1e90ff);
  --muted: var(--tg-theme-hint-color, #9aa3b2);
  --text: var(--tg-theme-text-color);
  --button-text-color: var(--tg-theme-button-text-color);
  --section-bg: var(--tg-theme-section-bg-color);
  --link: var(--tg-theme-link-color);
  --accent-text: var(--tg-theme-accent-text-color);
  --shadow-light: rgba(18, 38, 63, 0.06);
  --shadow-medium: rgba(16, 40, 80, 0.06);
  --shadow-heavy: rgba(12, 34, 80, 0.06);
}

* {
  box-sizing: border-box;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

main {
  max-width: 920px;
  width: 100%;
  padding: 15px;
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.title, .balance-card, .slot-wrap, .preload-box {
  background: var(--section-bg);
  box-shadow: 0 10px 30px var(--shadow-medium);
  border-radius: 10px;
}

.title {
  color: var(--text);
  padding: 18px;
  text-align: center;
  font-weight: 800;
  font-size: 18px;
}

.balance-card {
  color: var(--text);
  padding: 12px;
  height: 45px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 24px rgba(12, 40, 80, 0.04);
}

.slot-wrap {
  padding: 15px;
  border-radius: 14px;
  box-shadow: 0 18px 40px var(--shadow-heavy);
  overflow: hidden;
}

.reels {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  padding: 15px;
}

.reel {
  width: 18vw;
  max-width: 120px;
  aspect-ratio: 2.9 / 7;
  border-radius: 12px;
  padding: 6px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.track {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
}

.cell {
  width: 100%;
  height: 33%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin: 3% 0;
}

.cell img {
  max-height: 80%;
  max-width: 80%;
  display: block;
}

.cell.win-cell img {
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 4px rgba(255, 215, 0, 0.6));
}

.cell.bonus-cell img {
  filter: drop-shadow(0 0 4px rgba(255, 192, 203, 0.8)) drop-shadow(0 0 4px rgba(255, 192, 203, 0.6));
}

.cell.sticky-wild img {
  animation: pulseBonus 1s infinite;
}

.btn-row, .multipliers, .controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-row {
  margin-top: 12px;
}

.input {
  flex: 1;
  background: var(--section-bg);
  color: var(--text);
  padding: 10px;
  border-radius: 8px;
  border: 1.3px solid var(--accent-text);
  font-weight: 600;
  text-align: center;
  font-size: 16px;
}

.multipliers {
  height: 40px;
  margin: 10px 0;
}

.btn-m {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  color: var(--link);
  border: none;
  background: var(--section-bg);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s;
  font-size: 15px;
}

.btn-m:active {
  transform: translateY(2px);
}

.spin-btn {
  width: 100%;
  height: 50px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--button-text-color);
  font-weight: 800;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.12s;
}

.spin-btn:active {
  transform: translateY(2px);
}

.controls {
  margin-top: 10px;
  flex-wrap: wrap;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.controls input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--accent);
  background: var(--section-bg);
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  position: relative;
}

.controls input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.controls input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--button-text-color);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.small {
  font-size: 12px;
  color: var(--text);
}

.loader {
  position: fixed;
  inset: 0;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.preload-box {
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite ease-in-out;
}

@keyframes pulseBonus {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.6); opacity: 0.5; }
}

@media screen and (max-width: 600px) {
  .reels { gap: 8px; padding: 10px; }
  .reel { max-width: 90px; }
  .cell { height: 33%; margin: 2% 0; }
  .cell img { max-height: 75%; max-width: 75%; }
  .btn-row, .multipliers, .controls { gap: 6px; }
  .btn-row { margin-top: 8px; }
  .btn-m { padding: 8px; font-size: 12px; }
  .controls { margin-top: 8px; }
  .preload-box { padding: 12px; }
  .pulse { width: 10px; height: 10px; }
}