:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #07111f;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

#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: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(26, 99, 163, 0.35), transparent 60%),
    linear-gradient(180deg, #0d2238 0%, #081527 100%);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#left-meta {
  position: absolute;
  left: 23.5%;
  bottom: 4.2%;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 4;
}

#hud {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 240px;
}

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

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

.rules-mini-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-width: 2px;
  font-size: 30px;
  font-style: italic;
  line-height: 1;
  --btn-y: 0px;
  background: radial-gradient(circle at 34% 26%, #6b4f2a 0%, #3a2a18 60%, #21170e 100%);
  border-color: rgba(248, 235, 197, 0.95);
}

.hud-value {
  color: #f4f8ff;
  font-size: clamp(28px, 2vw, 42px);
  line-height: 1;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.hidden-win {
  display: none;
}

#recent-wins-panel {
  position: absolute;
  left: 1.4%;
  top: 21.5%;
  width: 16.5%;
  padding: 10px 10px 8px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, rgba(11, 44, 79, 0.46), rgba(5, 25, 47, 0.42));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(215, 242, 255, 0.12);
  z-index: 4;
}

.recent-title {
  color: #d7f0ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 7px;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recent-item {
  border-radius: 8px;
  padding: 7px 8px 6px;
  background: linear-gradient(180deg, rgba(130, 205, 255, 0.16), rgba(86, 161, 208, 0.08));
  border: none;
  color: #ecf9ff;
  font-size: 12px;
  line-height: 1.25;
  box-shadow: inset 0 1px 0 rgba(219, 244, 255, 0.16), 0 2px 8px rgba(0, 0, 0, 0.15);
}

.recent-item-enter {
  animation: recent-entry 420ms ease;
}

@keyframes recent-entry {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    filter: brightness(1.2);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

.recent-combo {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.combo-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 5px 1px 3px;
  border-radius: 999px;
  background: rgba(10, 45, 77, 0.6);
  border: none;
  box-shadow: inset 0 1px 0 rgba(205, 242, 255, 0.14);
}

.combo-count {
  font-weight: 800;
  color: #e0f5ff;
  font-size: 11px;
}

.combo-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}

.combo-plus {
  color: rgba(214, 245, 255, 0.9);
  font-weight: 700;
  margin-right: 1px;
}

.combo-mult {
  margin-left: 3px;
  font-size: 11px;
  color: #ffe7a8;
  font-weight: 800;
}

.recent-amount {
  margin-top: 4px;
  color: #fff6cf;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

#bottom-ui {
  position: absolute;
  left: 58%;
  right: 2.4%;
  bottom: 3.8%;
  display: flex;
  justify-content: flex-end;
  z-index: 4;
}

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

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

.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;
}

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

.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: 16px;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.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;
}

.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: 5;
}

.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);
}

#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: 30;
}

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

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

.rules-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1040px, 92%);
  max-height: 84%;
  overflow: auto;
  border-radius: 16px;
  border: 2px solid rgba(159, 217, 255, 0.6);
  background: linear-gradient(180deg, rgba(6, 25, 48, 0.97), rgba(4, 17, 34, 0.98));
  padding: 16px 16px 12px;
}

.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: #f1f8ff;
  background: transparent;
  cursor: pointer;
}

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

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

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

.pay-item {
  border: 1px solid rgba(159, 217, 255, 0.35);
  border-radius: 12px;
  background: rgba(128, 198, 240, 0.08);
  padding: 8px;
  text-align: center;
  color: #e6f5ff;
  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: #d9f0ff;
  font-size: 16px;
}

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

#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;
}

#dev-note {
  position: absolute;
  left: 18px;
  bottom: 14px;
  color: rgba(200, 233, 255, 0.85);
  font-size: 13px;
  letter-spacing: 0.04em;
  z-index: 1;
}

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

  #game-shell {
    width: 98vw;
  }

  #hud {
    min-width: 160px;
    gap: 2px;
  }

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

  .rules-mini-btn {
    width: 34px;
    height: 34px;
    font-size: 24px;
  }

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

  #left-meta {
    left: 1.3%;
    bottom: 4.1%;
    gap: 8px;
  }

  #recent-wins-panel {
    left: 1.1%;
    top: 20%;
    width: 20.5%;
    padding: 8px;
  }

  .recent-title {
    font-size: 10px;
    margin-bottom: 5px;
  }

  .recent-item {
    font-size: 10px;
    padding: 5px 6px;
  }

  .combo-icon {
    width: 18px;
    height: 18px;
  }

  .recent-amount {
    font-size: 11px;
  }

  #bottom-ui {
    left: 52%;
    right: 2.5%;
    bottom: 3.3%;
  }

  .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;
  }

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