:root {
  color-scheme: dark;
  font-family: Inter, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 50% 25%, #2b1747 0%, #10071d 65%, #090510 100%);
  overflow: hidden;
}

#app {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

#game-shell {
  position: relative;
  width: min(1360px, 94vw);
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #1d0f33;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.52);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#loader-screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(circle at 50% 30%, rgba(51, 27, 77, 0.96), rgba(12, 7, 22, 0.98));
}

#loader-screen.hidden {
  display: none;
}

#loader-logo {
  width: min(520px, 62%);
  max-height: 260px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
}

.loader-title {
  color: #ffe7a6;
  font-size: clamp(18px, 1.4vw, 24px);
  letter-spacing: 0.08em;
  font-weight: 800;
}

.loader-bar {
  width: min(540px, 68%);
  height: 20px;
  border-radius: 999px;
  border: 2px solid rgba(253, 221, 146, 0.9);
  background: rgba(20, 8, 30, 0.82);
  overflow: hidden;
}

.loader-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd974, #f0ac2a);
  box-shadow: inset 0 1px 0 rgba(255, 251, 205, 0.5);
  transition: width 120ms linear;
}

.loader-percent {
  color: #fff0bf;
  font-size: clamp(16px, 1.2vw, 22px);
  font-weight: 700;
  letter-spacing: 0.05em;
}

#top-win {
  position: absolute;
  top: 1.2%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  text-align: center;
  padding: 10px 20px;
  border-radius: 999px;
  border: 2px solid rgba(255, 212, 110, 0.9);
  background: linear-gradient(180deg, rgba(117, 23, 23, 0.85), rgba(73, 9, 9, 0.85));
  color: #ffe59f;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

#left-frames {
  position: absolute;
  left: 1.1%;
  top: 14.8%;
  width: 13.2%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 3;
}

.side-frame {
  width: 100%;
  border: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  color: #ffe8ad;
  text-align: center;
  display: grid;
  place-items: center;
  padding: 10% 12%;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.promo-frame {
  aspect-ratio: 1024 / 564;
  background-image: url("./assets/ui/side_panel_top.png");
}

.x2-frame {
  aspect-ratio: 728 / 810;
  background-image: url("./assets/ui/side_panel_mid.png");
}

.meter-frame {
  aspect-ratio: 960 / 1014;
  background-image: url("./assets/ui/side_panel_bottom.png");
  align-content: center;
}

.side-small {
  font-size: clamp(10px, 0.62vw, 12px);
  line-height: 1.1;
  opacity: 0.95;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.side-big {
  margin-top: 4px;
  font-size: clamp(22px, 1.55vw, 31px);
  font-weight: 900;
  color: #ffd35d;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.side-win {
  margin-top: 10px;
  font-size: clamp(26px, 1.8vw, 34px);
  color: #fff0ba;
}

#bottom-ui {
  position: absolute;
  left: 58%;
  right: 4.5%;
  bottom: 3.8%;
  height: auto;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  z-index: 2;
  overflow: visible;
}

#left-meta {
  position: absolute;
  left: 21.1%;
  bottom: 5.4%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  z-index: 3;
}

.hud-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.hud-label {
  font-size: 13px;
  letter-spacing: 0.06em;
  color: #e8b85a;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.hud-value {
  margin-top: 0;
  font-size: clamp(22px, 1.65vw, 34px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

#right-controls {
  margin-left: auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.slot-circle-btn {
  --btn-y: 0px;
  border: 4px solid rgba(247, 246, 243, 0.96);
  background: radial-gradient(circle at 35% 25%, #3a3c4e 0%, #1e1a2a 72%);
  color: #ffffff;
  cursor: pointer;
  font-weight: 900;
  border-radius: 50%;
  position: relative;
  transform: translateY(var(--btn-y)) scale(1);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.2), 0 6px 12px rgba(0, 0, 0, 0.38);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.slot-circle-btn:disabled,
.slot-pill-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.minor-btn {
  width: 46px;
  height: 46px;
  font-size: 30px;
  line-height: 0.9;
  --btn-y: -10px;
}

.sound-corner-btn {
  position: absolute;
  top: 1.8%;
  right: 1.6%;
  min-width: 100px;
  height: 38px;
  border-width: 2px;
  font-size: 14px;
  letter-spacing: 0.04em;
  padding: 0 12px;
  z-index: 4;
}

.rules-mini-btn {
  position: absolute;
  left: 16.2%;
  bottom: 5.8%;
  width: 42px;
  height: 42px;
  font-size: 30px;
  font-style: italic;
  border-width: 3px;
  z-index: 4;
}

.spin-btn {
  width: 106px;
  height: 106px;
  padding: 0;
  background: radial-gradient(circle at 34% 26%, #5d637d 0%, #313149 42%, #161627 78%);
  border-color: rgba(247, 246, 243, 0.98);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.2), inset 0 -8px 14px rgba(0, 0, 0, 0.3), 0 6px 12px rgba(0, 0, 0, 0.38);
  --btn-y: -18px;
}

.spin-btn::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.spin-icon {
  width: 58px;
  height: 58px;
  display: block;
  margin: 0 auto;
  stroke: #f4f4f2;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.28));
}

.slot-pill-btn {
  min-width: 130px;
  height: 46px;
  border-radius: 999px;
  border: 3px solid rgba(247, 246, 243, 0.95);
  background: linear-gradient(180deg, #30273b 0%, #1b1424 100%);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.15), 0 6px 12px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  padding: 0 18px;
  font-size: 19px;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.slot-circle-btn:active,
.slot-circle-btn.pressed,
.slot-pill-btn:active,
.slot-pill-btn.pressed {
  transform: translateY(calc(var(--btn-y, 0px) + 2px)) scale(0.97);
  filter: brightness(0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 5px rgba(0, 0, 0, 0.42);
}

#spin-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.autoplay-pill {
  position: relative;
  margin-top: -6px;
  min-width: 120px;
  height: 34px;
  border-width: 3px;
  font-size: 13px;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #121117 0%, #050508 100%);
  z-index: 5;
}

#autoplay-btn.active,
#sound-btn.active {
  box-shadow: 0 0 0 3px rgba(119, 250, 170, 0.78), inset 0 2px 0 rgba(255, 255, 255, 0.15), 0 6px 12px rgba(0, 0, 0, 0.35);
}

.rules-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.rules-modal.hidden {
  display: none;
}

.rules-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
}

.rules-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1080px, 92%);
  max-height: 84%;
  overflow: auto;
  border-radius: 16px;
  border: 2px solid rgba(255, 215, 128, 0.85);
  background: linear-gradient(180deg, rgba(16, 12, 25, 0.97), rgba(7, 5, 12, 0.98));
  padding: 18px 18px 14px;
}

.rules-close-btn {
  position: absolute;
  right: 10px;
  top: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
  color: #fff2c7;
  background: transparent;
  cursor: pointer;
}

.rules-title {
  font-size: 28px;
  font-weight: 800;
  color: #fff2b8;
  text-align: center;
}

.rules-subtitle {
  margin-top: 4px;
  color: #e9d8a5;
  text-align: center;
  font-size: 14px;
}

.paytable-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.pay-item {
  border: 1px solid rgba(255, 208, 120, 0.35);
  border-radius: 12px;
  background: rgba(255, 204, 108, 0.06);
  padding: 8px;
  text-align: center;
  color: #f0e1b6;
  font-size: 14px;
  line-height: 1.2;
}

.pay-item img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  margin: 0 auto 6px;
}

.scatter-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f2e6c8;
  font-size: 16px;
}

.scatter-row img {
  width: 120px;
  height: 80px;
  object-fit: contain;
}

@media (max-width: 960px) {
  #app {
    padding: 8px;
  }

  #game-shell {
    width: 98vw;
  }

  #top-win {
    min-width: 180px;
    font-size: 14px;
    padding: 8px 12px;
  }

  #left-frames {
    width: 18.5%;
    top: 15.2%;
    left: 1.2%;
    gap: 5px;
  }

  .side-small {
    font-size: 9px;
  }

  .side-big {
    font-size: 20px;
  }

  #bottom-ui {
    left: 51%;
    right: 3%;
    height: auto;
    bottom: 3.6%;
    gap: 6px;
  }

  #left-meta {
    left: 15.2%;
    bottom: 6%;
    gap: 2px;
  }

  .hud-line {
    gap: 7px;
  }

  .hud-label {
    font-size: 11px;
  }

  .hud-value {
    font-size: 20px;
  }

  .minor-btn {
    width: 42px;
    height: 42px;
    font-size: 28px;
    --btn-y: -8px;
  }

  .spin-btn {
    width: 88px;
    height: 88px;
    --btn-y: -13px;
  }

  .spin-icon {
    width: 46px;
    height: 46px;
  }

  .slot-pill-btn {
    min-width: 104px;
    height: 38px;
    font-size: 13px;
  }

  .autoplay-pill {
    min-width: 100px;
    height: 32px;
    margin-top: -4px;
    font-size: 11px;
  }

  .sound-corner-btn {
    top: 1.4%;
    right: 1.2%;
    min-width: 86px;
    height: 32px;
    font-size: 12px;
    padding: 0 8px;
  }

  .rules-mini-btn {
    left: 10.5%;
    bottom: 6.3%;
    width: 34px;
    height: 34px;
    font-size: 24px;
  }

  .paytable-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
