:root {
  --wheel-size: min(92vw, 390px);

  --bg-1: #fffaf4;
  --bg-2: #fff1e3;
  --bg-3: #eef8ff;

  --card: rgba(255, 255, 255, 0.58);
  --card-strong: rgba(255, 255, 255, 0.78);
  --line: rgba(18, 21, 28, 0.09);

  --text: #11151c;
  --muted: #6a7280;
  --white: #ffffff;

  --accent: #ff7a1a;
  --accent-2: #ffb000;
  --accent-soft: #ffe4c8;

  --dark: #0e1117;
  --dark-2: #171b23;

  --cyan: #74d8ff;
  --cyan-deep: #29baff;

  --success: #dff9e8;
  --danger: #ffe3e3;

  --shadow-lg: 0 25px 70px rgba(14, 17, 23, 0.12);
  --shadow-md: 0 14px 35px rgba(14, 17, 23, 0.08);
  --shadow-sm: 0 8px 20px rgba(14, 17, 23, 0.06);
}

.sw-game-container {
  display: flex;
  align-items: center;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 10px;
  border-radius: 28px;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  font-family: "Poppins", sans-serif;
  color: var(--text);

  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.76),
    rgba(255, 248, 240, 0.75) 38%,
    rgba(239, 249, 255, 0.8) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.sw-game-container > * {
  position: relative;
  z-index: 2;
}

.sw-game-container::before,
.sw-game-container::after {
  content: "";
  position: absolute;
  inset: auto;
  width: 320px;
  height: 320px;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.75;
  z-index: 0;
  pointer-events: none;
}

.sw-game-container::before {
  top: -80px;
  left: -60px;
  background: radial-gradient(
    circle,
    rgba(255, 122, 26, 0.28) 0%,
    rgba(255, 176, 0, 0.16) 35%,
    rgba(255, 255, 255, 0) 72%
  );
  animation: swBlobFloatA 10s ease-in-out infinite alternate;
}

.sw-game-container::after {
  right: -80px;
  bottom: -90px;
  background: radial-gradient(
    circle,
    rgba(41, 186, 255, 0.22) 0%,
    rgba(116, 216, 255, 0.14) 35%,
    rgba(255, 255, 255, 0) 72%
  );
  animation: swBlobFloatB 12s ease-in-out infinite alternate;
}

@keyframes swBlobFloatA {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(30px, 20px, 0) scale(1.08);
  }
}

@keyframes swBlobFloatB {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(-24px, -18px, 0) scale(1.1);
  }
}

.sw-title {
  font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  text-align: center;
  margin-bottom: 14px;
  color: var(--dark);
  letter-spacing: -0.03em;
  background: linear-gradient(
    90deg,
    var(--dark) 0%,
    var(--accent) 55%,
    var(--accent-2) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sw-ticket-info {
  width: 100%;
  padding: 18px;
  margin-bottom: 18px;
  border-radius: 24px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#sw-ticket-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#sw-tickets {
  margin-top: 4px;
  display: flex;
  overflow-x: auto;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

#sw-tickets::-webkit-scrollbar {
  height: 8px;
}

#sw-tickets::-webkit-scrollbar-thumb {
  background: rgba(17, 21, 28, 0.12);
  border-radius: 999px;
}

.button-container {
  display: flex;
  gap: 10px;
}

.sw-ticket-group {
  flex: 0 0 auto;
  min-width: 150px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow-sm);
}

.sw-ticket-group-label {
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--dark);
  white-space: nowrap;
}

.sw-ticket-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.sw-ticket {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
  border: 1px solid var(--line);
  padding: 7px 10px;
  margin: 2px 4px 2px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  transition: all 0.25s ease;
  white-space: nowrap;
  box-shadow: 0 6px 15px rgba(17, 21, 28, 0.04);
}

.sw-ticket.popped {
  text-decoration: line-through;
  color: #8f97a3;
  opacity: 0.85;
}

.sw-ticket.win {
  background: var(--success);
  color: #0b7c4a;
  border-color: rgba(11, 124, 74, 0.18);
}

.sw-ticket.nowin {
  background: var(--danger);
  color: #b54444;
  border-color: rgba(181, 68, 68, 0.16);
}

#sw-toggle-spin,
#sw-toggle-spin-all,
.spin-btn {
  position: relative;
  overflow: hidden;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    opacity 0.22s ease,
    background 0.22s ease;
  text-align: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 10px 24px rgba(14, 17, 23, 0.08);
}

#sw-toggle-spin,
.spin-btn {
  width: 50%;
  min-width: 130px;
  color: var(--white);
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
}

#sw-toggle-spin-all {
  width: 50%;
  min-width: 130px;
  color: var(--white);
  background: linear-gradient(90deg, var(--dark) 0%, var(--dark-2) 100%);
}

.spin-btn {
  width: auto;
  border: none;
}

#sw-toggle-spin:hover,
#sw-toggle-spin-all:hover,
.spin-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(14, 17, 23, 0.12);
}

#sw-toggle-spin::before,
#sw-toggle-spin::after,
.spin-btn::before,
.spin-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  transform: translate(-50%, -50%) scale(0.1);
  opacity: 0;
  mix-blend-mode: screen;
  animation: swRipple 2s ease-out infinite;
}

#sw-toggle-spin::after,
.spin-btn::after {
  animation-delay: 1s;
}

@keyframes swRipple {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0.8;
  }
  70% {
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}

#sw-wrapper {
  width: var(--wheel-size);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* WHEEL */
#wheel {
  width: var(--wheel-size);
  height: var(--wheel-size);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.78),
    rgba(255, 255, 255, 0.45)
  );
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.45),
    0 24px 55px rgba(14, 17, 23, 0.12),
    0 0 0 10px rgba(255, 255, 255, 0.18);
  transition:
    box-shadow 0.3s ease,
    transform 0.3s ease,
    filter 0.3s ease;
}

#wheel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, 0.16),
    inset 0 0 35px rgba(255, 122, 26, 0.08);
  z-index: 2;
  pointer-events: none;
}

#wheel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 28% 24%,
    rgba(255, 255, 255, 0.42),
    rgba(255, 255, 255, 0) 34%
  );
  z-index: 2;
  pointer-events: none;
}

#inner-wheel {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 6s cubic-bezier(0, 0.99, 0.44, 0.99);
}

/* Triangular slices */
#wheel .sec {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 200px 83px 0;
  border-color: #ff7a1a transparent;
  transform-origin: 83px 200px;
  left: calc(50% - 83px);
  top: calc(50% - 200px);
  filter: drop-shadow(0 4px 12px rgba(17, 21, 28, 0.12));
}

#wheel .sec .label {
  position: relative;
  display: block;
  margin-top: -142px;
  margin-left: -42px;
  width: 84px;
  text-align: center;
  font-weight: 800;
  font-size: clamp(10px, 2.4vw, 13px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #ffffff;
  user-select: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  word-break: break-word;
}

#wheel .sec:nth-child(1) {
  transform: rotate(45deg);
  border-color: #ff7a1a transparent;
}
#wheel .sec:nth-child(2) {
  transform: rotate(90deg);
  border-color: #0f1115 transparent;
}
#wheel .sec:nth-child(3) {
  transform: rotate(135deg);
  border-color: #70d7ff transparent;
}
#wheel .sec:nth-child(4) {
  transform: rotate(180deg);
  border-color: #ffc24d transparent;
}
#wheel .sec:nth-child(5) {
  transform: rotate(225deg);
  border-color: #ff9a66 transparent;
}
#wheel .sec:nth-child(6) {
  transform: rotate(270deg);
  border-color: #1c2430 transparent;
}
#wheel .sec:nth-child(7) {
  transform: rotate(315deg);
  border-color: #ffb000 transparent;
}
#wheel .sec:nth-child(8) {
  transform: rotate(360deg);
  border-color: #b9ecff transparent;
}

#wheel .sec:nth-child(3) .label,
#wheel .sec:nth-child(4) .label,
#wheel .sec:nth-child(7) .label,
#wheel .sec:nth-child(8) .label {
  color: #11151c;
  text-shadow: none;
}

#wheel .sec.sec-no-win {
  filter: saturate(0.9) brightness(0.96);
}

#wheel .sec.sec-no-win .label {
  opacity: 0.9;
}

/* Center spin button */
#spin {
  width: 76px;
  height: 76px;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -38px 0 0 -38px;
  border-radius: 50%;
  z-index: 4;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    0 18px 35px rgba(14, 17, 23, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  user-select: none;
  display: grid;
  place-items: center;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease;
  cursor: pointer;
}

#spin:hover {
  transform: scale(1.04);
}

#spin span {
  position: relative;
  z-index: 2;
  font-size: 22px;
  font-weight: 800;
  color: var(--dark);
}

#spin::before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-radius: 99px;
  border-width: 0 16px 24px 16px;
  border-color: transparent transparent var(--accent) transparent;
  top: -16px;
  left: 22px;
  filter: drop-shadow(0 5px 10px rgba(255, 122, 26, 0.28));
}

#inner-spin {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.96),
    rgba(255, 238, 223, 0.96)
  );
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.96),
    inset 0 -3px 10px rgba(255, 176, 0, 0.14),
    0 0 10px rgba(255, 122, 26, 0.08);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* subtle sheen */
#shine {
  width: 76%;
  height: 76%;
  position: absolute;
  top: 0;
  left: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.68) 0%,
    rgba(255, 255, 255, 0) 64%
  );
  opacity: 0.18;
  pointer-events: none;
}

/* result area */
#result {
  width: 100%;
  min-height: 56px;
  text-align: center;
  margin-top: 14px;
  padding: 15px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: clamp(14px, 3.2vw, 18px);
  color: var(--dark);
  white-space: pre-line;
}

#result.is-win {
  color: #0b7c4a;
}

#result.is-loss {
  color: #c24d4d;
}

#result.is-pop {
  animation: swResultPop 0.35s ease;
}

@keyframes swResultPop {
  0% {
    transform: scale(0.97);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* existing ticker animation */
@keyframes ticker-rattle {
  0% {
    transform: rotate(0deg) translateY(0);
  }
  30% {
    transform: rotate(-3deg) translateY(-1px);
  }
  60% {
    transform: rotate(2deg) translateY(1px);
  }
  100% {
    transform: rotate(0deg) translateY(0);
  }
}

#spin.tick::before {
  animation: ticker-rattle 120ms ease-out;
}

/* state effects */
.sw-game-container.is-spinning #wheel {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.45),
    0 24px 60px rgba(14, 17, 23, 0.12),
    0 0 28px rgba(255, 122, 26, 0.16),
    0 0 46px rgba(41, 186, 255, 0.14);
}

.sw-game-container.is-winning #wheel {
  animation: swWinPulse 0.9s ease 2;
}

.sw-game-container.is-losing #wheel {
  filter: saturate(0.95);
}

@keyframes swWinPulse {
  0% {
    transform: scale(1);
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.45),
      0 24px 55px rgba(14, 17, 23, 0.12);
  }
  50% {
    transform: scale(1.015);
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.45),
      0 24px 55px rgba(14, 17, 23, 0.12),
      0 0 38px rgba(255, 122, 26, 0.22),
      0 0 58px rgba(255, 176, 0, 0.16);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 640px) {
  .button-container {
    flex-direction: column;
  }

  #sw-toggle-spin,
  #sw-toggle-spin-all {
    width: 100%;
  }

  .sw-ticket-group {
    min-width: 130px;
  }

  #wheel .sec .label {
    font-size: 10px;
    width: 76px;
    margin-left: -38px;
  }
}
