* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 10%, #1f2b48 0%, #0a0f1d 55%, #05070f 100%);
  color: #181a20;
  padding: clamp(10px, 2.8vw, 24px);
}

body.isSpinning .spinBtn,
body.isSpinning .multiplierPill,
body.isSpinning .quickBetBtn,
body.isSpinning input,
body.isSpinning button {
  opacity: 0.6;
}

.modal {
  --wheel-size: min(52vw, 42vh, 420px);
  width: min(920px, 100%);
  background: #f4f5f9;
  border-radius: 28px;
  padding: clamp(12px, 2.4vw, 28px) clamp(12px, 2.8vw, 30px)
    max(clamp(12px, 2.2vw, 24px), env(safe-area-inset-bottom));
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.35);
  height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: clamp(8px, 1.8vh, 16px);
}

.topBar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.footerBar {
  margin-top: 0;
  grid-row: 4;
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #eef1f5;
  align-items: center;
  flex-wrap: nowrap;
}

.footerGroup {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.footerLabel {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
}

.footerInput,
.footerSelect {
  border: 0;
  border-radius: 10px;
  padding: 6px 8px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  color: #222833;
}

.footerGroup:last-child {
  max-width: 140px;
  flex: 0 0 140px;
}

.footerInput.alignRight {
  text-align: right;
}

.footerSelect {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #6b7280 50%),
    linear-gradient(135deg, #6b7280 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 10px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 52px);
  letter-spacing: -0.03em;
}

.closeBtn {
  border: 0;
  background: transparent;
  color: #8790a0;
  font-size: 52px;
  line-height: 1;
  cursor: pointer;
}

.wheelCard {
  position: relative;
  width: var(--wheel-size);
  margin: 0 auto;
  display: grid;
  place-items: center;
  overflow: visible;
}

#pointer {
  position: absolute;
  top: -16px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 22px solid #2c84ff;
  z-index: 30;
  transform-origin: 50% 2px;
  filter: none;
}

#pointer::after {
  content: none;
}

#pointer.tick {
  animation: pointerKick var(--kick-ms, 62ms) cubic-bezier(0.12, 0.95, 0.2, 1);
}

@keyframes pointerKick {
  0% {
    transform: rotate(0deg) translateY(0) scaleY(1);
    filter: none;
  }
  55% {
    transform: rotate(var(--kick-angle, -14deg)) translateY(1px) scaleY(0.985);
    filter: none;
  }
  100% {
    transform: rotate(0deg) translateY(0) scaleY(1);
    filter: none;
  }
}

#wheel {
  width: 100%;
  aspect-ratio: 1;
  transition: transform 7.6s cubic-bezier(0.08, 0.9, 0.14, 1);
}

.centerReadout {
  position: absolute;
  text-align: center;
  pointer-events: none;
  width: 66%;
}

.centerReadout p {
  margin: 0;
  font-size: clamp(18px, 3vh, 30px);
  color: #636b77;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: grid;
  gap: 4px;
}

.centerReadout strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(18px, calc(var(--wheel-size) * 0.12), 44px);
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.centerBet {
  display: block;
  margin-top: 8px;
  font-size: clamp(12px, 1.8vw, 15px);
  font-weight: 700;
  color: #8a94a6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.centerSpin {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  --center-btn-size: min(120px, calc(var(--wheel-size) * 0.32));
  width: var(--center-btn-size);
  height: var(--center-btn-size);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  border: 0;
  display: grid;
  place-items: center;
  box-shadow: none;
  padding: 0;
}

.centerSpin:hover {
  filter: brightness(1.05);
}

.centerSpin:active {
  transform: translate(-50%, -50%) scale(0.98);
}

.spinSvg {
  width: 100%;
  height: 100%;
}

.spinRing {
  transition: fill 120ms ease, stroke 120ms ease;
}

.spinArc {
  transition: stroke 120ms ease;
}

.spinArrow {
  transition: stroke 120ms ease;
}

.spinLabel {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.14em;
  fill: #ffffff;
}

.centerSpin:active .spinArc {
  stroke: #2c84ff;
}

.centerSpin:active .spinArrow {
  stroke: #ffffff;
}

.spinAmount {
  font-size: clamp(12px, 2.1vw, 16px);
  font-weight: 800;
  color: #2c84ff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.centerBetValue {
  position: absolute;
  left: 50%;
  top: calc(50% + min(82px, 22%));
  transform: translateX(-50%);
  z-index: 12;
  font-size: clamp(12px, 2.2vw, 16px);
  font-weight: 800;
  color: #2c84ff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.controls {
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.betLabel {
  display: block;
  margin-bottom: 6px;
  color: #4f5665;
  font-size: clamp(15px, 2.1vw, 21px);
}

.betRow {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #e7e9ef;
  border-radius: 14px;
}

input {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: clamp(16px, 2.8vw, 24px);
  font-weight: 700;
  color: #181a20;
  padding: 8px 10px;
  min-width: 0;
}

input:focus {
  outline: none;
}

.linkBtn {
  border: 0;
  background: transparent;
  color: #2c84ff;
  font-size: clamp(15px, 2.5vw, 20px);
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.multiplierGrid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(70px, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.multiplierPill,
.spinBtn {
  border: 0;
  border-radius: 14px;
  padding: 10px 8px;
  font-size: clamp(15px, 2.5vw, 24px);
  font-weight: 700;
  cursor: pointer;
}

.multiplierPill {
  background: #e7e9ef;
  color: #17191f;
}

.multiplierPill.selected {
  background: #ffffff;
  box-shadow: inset 0 0 0 2px #2c84ff;
}

.multiplierPill.win {
  background: #fff;
  box-shadow: inset 0 0 0 2px #2c84ff;
}

.spinBtn {
  background: linear-gradient(120deg, #8fb6ff, #6b9dff);
  color: #fff;
}

.altBtn {
  background: linear-gradient(120deg, #3cc590, #1f9f6d);
}

.ghostBtn {
  background: #d9dfec;
  color: #2c84ff;
}

.playerStatsRow {
  margin: 10px 0 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  font-size: 12px;
  color: #4f5665;
}

.playerStatsRow div {
  background: #e7e9ef;
  border-radius: 10px;
  padding: 8px 10px;
}

.fsRow {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.progressWrap {
  margin: 8px 0 10px;
}

.progressLabel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #4f5665;
  margin-bottom: 6px;
}

.progressTrack {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #dde1ea;
  overflow: hidden;
}

.progressFill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #35c58f, #2c84ff);
  transition: width 220ms ease;
}

.levelBox {
  margin: 10px 0 12px;
  background: #ebedf3;
  border-radius: 12px;
  padding: 12px;
}

.levelHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #3b4250;
  margin-bottom: 8px;
}

.levelBar {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}

.levelDot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: #d7dbe4;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #697184;
  position: relative;
  overflow: hidden;
}

.levelLabel {
  position: relative;
  z-index: 1;
}

.levelDot.active {
  color: #fff;
}

.levelDot.current {
  box-shadow: 0 0 0 2px #1f6fff, 0 0 12px rgba(31, 111, 255, 0.4);
}

.levelDot.disabled {
  background: #e3e6ee;
  color: #9aa2b2;
}

.levelFill {
  position: absolute;
  inset: auto 0 0 0;
  height: var(--fill, 0%);
  background: linear-gradient(180deg, #2c84ff, #35c58f);
  opacity: 0.9;
  z-index: 0;
}

.levelDot.disabled .levelFill {
  opacity: 0.25;
}

.quickBetRow {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.quickBetBtn {
  border: 0;
  border-radius: 10px;
  background: #d9deea;
  color: #233043;
  font-weight: 800;
  font-size: 14px;
  padding: 8px 6px;
  cursor: pointer;
}

.spinBtn:disabled {
  opacity: 0.65;
  cursor: wait;
}

button:disabled,
input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.fairBox {
  margin-top: 10px;
  background: #ebedf3;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: clamp(12px, 1.8vw, 14px);
}


.verifyBox {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #dfe3eb;
}

.verifyBox strong {
  display: block;
  margin-bottom: 6px;
}

.verifyBtn {
  margin-top: 8px;
  border: 0;
  border-radius: 10px;
  background: #2c84ff;
  color: #fff;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

.verifyStatus {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
  color: #3d4350;
  word-break: break-word;
}

.verifyStatus.ok {
  color: #117a42;
}

.verifyStatus.bad {
  color: #b33131;
}

.hashLine {
  margin-top: 8px;
}

.hashLine code {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-all;
}

.fairBox summary {
  cursor: pointer;
  color: #3b4250;
  font-weight: 700;
}

.fairBox label {
  display: block;
  margin-top: 10px;
  color: #4f5665;
}

.rtpLine {
  margin-top: 8px;
  color: #4f5665;
}

.hashLine {
  margin-top: 10px;
}

.hashLine code,
.result code {
  display: block;
  word-break: break-all;
  font-size: 12px;
  margin-top: 4px;
}

.result {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #3d4350;
}

.historyCard {
  margin-top: 18px;
  background: #eef1f5;
  border-radius: 20px;
  padding: 16px 18px;
}

.historyHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.historyHeader h3 {
  margin: 0;
  font-size: 18px;
}

.historyTabs {
  display: flex;
  gap: 8px;
}

.historyTab {
  border: 1px solid transparent;
  background: #e0e5ec;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  font-size: 12px;
  color: #3b4657;
  cursor: pointer;
}

.historyTab.active {
  background: #ffffff;
  border-color: #2c84ff;
  color: #1f67d2;
}

.historyTable {
  display: grid;
  gap: 10px;
}

.historyRow {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f6f8fb;
  border-radius: 14px;
  font-size: 13px;
}

.historyRow.historyHead {
  background: transparent;
  font-weight: 700;
  padding: 0 4px 4px;
}

.historyRow .historyDate {
  display: block;
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
}

.historyBody {
  display: grid;
  gap: 8px;
}

.historyEmpty {
  text-align: center;
  font-size: 13px;
  color: #6a7280;
  padding: 8px 0 2px;
}

.historyPager {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.historyPagerBtn {
  border: 0;
  border-radius: 10px;
  padding: 6px 10px;
  background: #e2e6ef;
  font-weight: 700;
  font-size: 12px;
  color: #394150;
  cursor: pointer;
}

.historyPagerBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.historyPagerInfo {
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
}

.historyDetail {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(44, 132, 255, 0.18);
  font-size: 12px;
  color: #3d4350;
}

.historyDetail.open {
  display: grid;
}

.historyDetail strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 4px;
}

.historyDetail code {
  display: block;
  word-break: break-all;
  font-size: 12px;
  color: #1f2a44;
}

.historyStatus {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef1f5;
  font-size: 12px;
  font-weight: 700;
  color: #4b5563;
}

.historyStatus.ok {
  background: rgba(22, 163, 74, 0.15);
  color: #15803d;
}

.historyStatus.bad {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

@media (max-width: 720px) {
  .historyRow {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: auto;
  }
  .historyRow > :nth-child(3),
  .historyRow > :nth-child(4) {
    justify-self: start;
  }
  .historyDetail {
    grid-template-columns: 1fr;
  }
}

.winOverlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
  z-index: 26;
  overflow: visible;
}

.winOverlay.show {
  opacity: 1;
}

.winCard {
  min-width: min(86%, 360px);
  background: rgba(12, 18, 35, 0.92);
  border: 2px solid rgba(255, 215, 80, 0.75);
  border-radius: 18px;
  color: #fff;
  text-align: center;
  padding: 16px 18px 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  position: relative;
  overflow: visible;
  animation: winPulse 900ms ease-out;
}

.winOverlay.tier-big .winCard {
  border-color: rgba(114, 217, 255, 0.92);
  box-shadow: 0 0 0 2px rgba(114, 217, 255, 0.35), 0 18px 40px rgba(0, 0, 0, 0.45);
}

.winOverlay.tier-super .winCard {
  border-color: rgba(124, 255, 176, 0.94);
  box-shadow: 0 0 0 2px rgba(124, 255, 176, 0.45), 0 18px 40px rgba(0, 0, 0, 0.45);
}

.winOverlay.tier-mega .winCard {
  border-color: rgba(255, 141, 141, 0.98);
  box-shadow: 0 0 0 3px rgba(255, 141, 141, 0.5), 0 18px 40px rgba(0, 0, 0, 0.45);
  animation: winPulse 900ms ease-out, megaShake 220ms ease-in-out 2;
}

.winBadge {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #ffd166;
  font-weight: 800;
}

.winCard h2 {
  margin: 8px 0 4px;
  font-size: clamp(22px, 4vw, 34px);
  line-height: 1.1;
}

.winCard strong {
  font-size: clamp(26px, 5vw, 42px);
  color: #ffdf6e;
}

.coinBurst {
  position: absolute;
  inset: -30% -30% -20%;
  pointer-events: none;
  overflow: hidden;
  z-index: 27;
}

.coin {
  position: absolute;
  top: -26px;
  left: var(--l, 50%);
  width: var(--s, 18px);
  height: var(--s, 18px);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff7cb, #ffd24d 48%, #d2a324 100%);
  box-shadow: 0 0 10px rgba(255, 208, 76, 0.9);
  animation: coinFall 2000ms ease-in forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes coinFall {
  0% {
    transform: translateX(0) translateY(0) scale(0.75);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translateX(var(--x, 0px)) translateY(calc(var(--wheel-size) * 1.8)) scale(1.05);
    opacity: 0;
  }
}

@keyframes winPulse {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes megaShake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (max-width: 760px) {
  .modal {
    --wheel-size: min(76vw, 32vh, 300px);
    border-radius: 22px;
    height: 100vh;
    padding: 14px 12px;
  }

  .closeBtn {
    font-size: 32px;
  }

  .footerBar {
    flex-wrap: nowrap;
  }

  .langNav a {
    padding: 5px 8px;
  }

  .footerBar {
    grid-template-columns: 1fr;
  }

  .betLabel,
  .linkBtn,
  .multiplierPill,
  .spinBtn {
    font-size: clamp(14px, 3.6vw, 18px);
  }

  .multiplierGrid {
    grid-template-columns: repeat(3, minmax(80px, 1fr));
  }

  .playerStatsRow {
    grid-template-columns: 1fr;
  }

  .betRow {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  body {
    padding: 0;
  }

  .modal {
    --wheel-size: min(74vw, 28vh, 240px);
    min-height: 100vh;
    border-radius: 0;
    height: 100vh;
    padding: 16px 12px;
  }

  .topBar {
    gap: 10px;
  }

  h1 {
    font-size: clamp(28px, 10vw, 38px);
  }

  .closeBtn {
    font-size: 34px;
  }

  .centerReadout strong {
    font-size: clamp(14px, calc(var(--wheel-size) * 0.12), 22px);
  }
}

@media (max-height: 780px) {
  .modal {
    --wheel-size: min(64vw, 26vh, 220px);
    gap: 8px;
  }

  h1 {
    font-size: clamp(22px, 5vw, 30px);
  }

  .closeBtn {
    font-size: 28px;
  }

  .fairBox {
    margin-top: 8px;
    padding: 8px 10px;
  }
}
