:root { color-scheme: dark; }
* { box-sizing: border-box; }

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

#app {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 1.4vw, 18px);
}

#game-shell {
  position: relative;
  width: min(1360px, 94vw, calc(94vh * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: 94vh;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #12393c 0%, #0a2028 100%);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.58);
}

#game-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  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);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.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 {
  width: 0%;
  height: 100%;
  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;
}

#left-meta {
  position: absolute;
  left: 18.5%;
  bottom: 2.2%;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 8px 12px 9px;
  border-radius: 14px;
  border: 1px solid rgba(224, 194, 132, 0.28);
  background: linear-gradient(180deg, rgba(20, 15, 14, 0.42), rgba(7, 6, 8, 0.56));
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(2px);
  z-index: 5;
}

#hud {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-width: 440px;
}

.hud-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-col-right {
  padding-left: 14px;
  border-left: 1px solid rgba(236, 211, 160, 0.2);
}

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

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

.hud-value {
  color: #f8fcff;
  font-size: clamp(16px, 1.65vw, 32px);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.74);
}

#chain-val {
  font-size: clamp(24px, 1.8vw, 36px);
}

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

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

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

.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-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.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: 999px;
  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(1080px, 94%);
  max-height: 90%;
  border-radius: 16px;
  border: 2px solid rgba(220, 180, 100, 0.45);
  background: linear-gradient(180deg, rgba(8, 12, 18, 0.97), rgba(3, 7, 12, 0.97));
  padding: 16px 16px 10px;
  overflow: hidden;
}

.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: 30px;
  font-weight: 800;
  color: #eaf3ff;
  text-align: center;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}

.rules-content {
  margin-top: 10px;
  height: min(66vh, 560px);
  overflow-y: auto;
  padding: 8px 12px 10px;
}

.rules-content::-webkit-scrollbar {
  width: 8px;
}

.rules-content::-webkit-scrollbar-thumb {
  background: rgba(233, 212, 154, 0.32);
  border-radius: 999px;
}

.rules-lead {
  margin: 2px 0 10px;
  color: #eef4ff;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
}

.rules-paragraph {
  margin: 8px 0;
  color: #eef3ff;
  font-size: 21px;
  line-height: 1.22;
  text-align: left;
}

.rules-subheading {
  margin: 12px 0 8px;
  color: #f2f7ff;
  font-size: 22px;
  font-weight: 800;
  text-align: left;
}

.rules-note {
  color: #d6e3fb;
  font-size: 20px;
  line-height: 1.24;
  text-align: left;
}

.rules-page {
  border: 1px solid rgba(217, 178, 109, 0.22);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(9, 15, 24, 0.86), rgba(7, 11, 18, 0.86));
  padding: 10px 12px;
}

.rules-step {
  color: #eff4ff;
  font-size: 21px;
  line-height: 1.3;
  margin: 8px 0;
}

.rules-symbol-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.rules-symbol-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(237, 209, 144, 0.28);
  border-radius: 10px;
  padding: 9px 11px;
  background: rgba(10, 16, 24, 0.88);
}

.rules-symbol-pill span {
  color: #f6f8ff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.rules-symbol-pill em {
  margin-left: auto;
  color: #ffd88a;
  font-size: 19px;
  font-style: normal;
  font-weight: 800;
}

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

.rules-symbol-card {
  border: 1px solid rgba(243, 220, 166, 0.26);
  border-radius: 10px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(15, 23, 36, 0.88), rgba(8, 14, 22, 0.88));
}

.rules-symbol-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rules-symbol-icon {
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.rules-symbol-name {
  color: #f3f5ff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.rules-pays {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  row-gap: 2px;
}

.rules-pays-size {
  color: #d6dff0;
  font-size: 17px;
}

.rules-pays-value {
  color: #ffe39a;
  font-size: 17px;
  font-weight: 700;
}

.rules-feature-box {
  border: 1px solid rgba(233, 210, 153, 0.25);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(10, 17, 27, 0.78);
  margin: 8px 0;
}

.rules-nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 8px;
}

.rules-nav-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(220, 255, 174, 0.92);
  background: radial-gradient(circle at 35% 25%, #6dbf1f 0%, #377f11 72%);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
}

.rules-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.rules-page-indicator {
  margin-left: auto;
  color: #f1f5ff;
  font-size: 16px;
  font-weight: 700;
}

@media (orientation: portrait), (max-width: 900px) {
  #game-shell {
    width: min(98vw, calc(96vh * 16 / 9));
    max-height: 96vh;
    border-radius: 14px;
  }

  #left-meta {
    left: 3%;
    bottom: 2%;
    padding: 6px 8px;
    gap: 8px;
    transform: scale(0.9);
    transform-origin: left bottom;
  }

  #bottom-ui {
    right: 1.6%;
    bottom: 2.2%;
  }

  #right-controls {
    gap: 8px;
    transform: scale(0.9);
    transform-origin: right bottom;
  }

  .sound-corner-btn {
    top: 1.2%;
    right: 1.2%;
    min-width: 86px;
    height: 34px;
    font-size: 12px;
  }

  .rules-dialog {
    width: min(98%, 980px);
    max-height: 94%;
    padding: 12px 10px 8px;
  }

  .rules-content {
    height: min(68vh, 560px);
    padding: 6px;
  }

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

  .rules-symbol-name {
    font-size: 18px;
  }

  .rules-note,
  .rules-paragraph {
    font-size: 16px;
  }

  .rules-step {
    font-size: 16px;
  }

  .rules-symbol-grid {
    grid-template-columns: 1fr;
  }

  .rules-symbol-icon {
    width: 54px;
    height: 54px;
  }

  .rules-symbol-pill span {
    font-size: 16px;
  }

  .rules-symbol-pill em {
    font-size: 17px;
  }
}
