:root {
  color-scheme: dark;
  --bg: #070d14;
  --ink: #edf3f8;
  --muted: #8fa3b5;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #2aabee;
  --accent-2: #1dd1a1;
  --gold: #f0d56a;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Unbounded", "Manrope", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(820px 480px at 50% -12%, rgba(42, 171, 238, 0.28), transparent 58%),
    radial-gradient(640px 380px at 100% 55%, rgba(29, 209, 161, 0.1), transparent 55%),
    radial-gradient(560px 340px at 0% 90%, rgba(240, 213, 106, 0.07), transparent 50%),
    linear-gradient(180deg, #050a10 0%, #0a1219 48%, #0c1822 100%);
}

.fx {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.page {
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding:
    max(12px, var(--safe-t))
    max(16px, var(--safe-r))
    max(14px, var(--safe-b))
    max(16px, var(--safe-l));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  row-gap: clamp(8px, 1.6vh, 18px);
  overflow: hidden;
  padding-top: max(14px, var(--safe-t));
}

.hero {
  text-align: center;
  width: 100%;
  min-width: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
}

.title-plate {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 22px 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(22, 36, 50, 0.95), rgba(12, 20, 30, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  max-width: min(420px, 100%);
  overflow: visible;
  z-index: 6;
}

.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.45rem, 5vh, 2.35rem);
  letter-spacing: 0.04em;
  line-height: 1.05;
  background: linear-gradient(110deg, #fff 18%, #2aabee 52%, #1dd1a1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(0.9rem, 2.2vh, 1.25rem);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.lead {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: clamp(0.74rem, 1.7vh, 0.9rem);
  line-height: 1.3;
}

.pointer-arm {
  position: absolute;
  left: 50%;
  top: calc(100% - 6px);
  transform: translateX(-50%);
  width: 56px;
  height: 110px;
  display: flex;
  justify-content: center;
  z-index: 8;
  pointer-events: none;
}

.pointer {
  display: block;
  width: 56px;
  height: 110px;
  transform-origin: 28px 12px;
  transform: rotate(0deg);
  transition: transform 28ms linear;
  will-change: transform;
}

.wheel-stage {
  position: relative;
  width: min(100%, 494px, calc(100dvh - 320px), 78vw);
  aspect-ratio: 1;
  max-height: 100%;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: visible;
  isolation: isolate;
  /* tip digs into rim/pegs — pixel contact */
  margin: 38px 0 14px;
  z-index: 0;
}

.wheel-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  padding: 0;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.14), transparent 42%),
    #0b1520;
  box-shadow:
    0 0 0 3px rgba(240, 213, 106, 0.35),
    0 0 0 7px rgba(255, 255, 255, 0.06),
    0 18px 36px rgba(0, 0, 0, 0.5);
}

#wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: transform 0s;
  will-change: transform;
  cursor: grab;
  touch-action: none;
}

#wheel.is-dragging,
#wheel:active {
  cursor: grabbing;
}

#wheel.is-spinning {
  transition-timing-function: cubic-bezier(0.12, 0.75, 0.08, 1);
}

.hub {
  --hub: clamp(52px, 13vw, 78px);
  position: absolute;
  inset: 50%;
  width: var(--hub);
  height: var(--hub);
  margin: calc(var(--hub) / -2) 0 0 calc(var(--hub) / -2);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 35% 28%, #2a3d52, #0b1520 70%);
  border: 3px solid rgba(240, 213, 106, 0.45);
  box-shadow:
    inset 0 0 18px rgba(0, 0, 0, 0.45),
    0 8px 22px rgba(0, 0, 0, 0.45);
  z-index: 2;
  pointer-events: none;
}

.hub span {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.05rem, 3.4vw, 1.45rem);
  color: var(--accent);
  text-shadow: 0 0 18px rgba(42, 171, 238, 0.45);
}

.controls {
  position: relative;
  z-index: 2;
  width: min(420px, 100%);
  text-align: center;
  align-self: end;
  padding-top: 2px;
  background: linear-gradient(180deg, transparent, rgba(7, 13, 20, 0.55) 30%);
}

.btn-spin {
  width: 100%;
  border: 0;
  border-radius: clamp(14px, 3vw, 18px);
  padding: clamp(14px, 2.4vh, 18px) 18px;
  cursor: pointer;
  color: #041018;
  background: linear-gradient(135deg, #2aabee 0%, #1dd1a1 100%);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1rem, 2.4vh, 1.15rem);
  letter-spacing: 0.03em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 12px 28px rgba(42, 171, 238, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-spin:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-spin:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-spin:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-hint {
  font-family: var(--font);
  font-weight: 600;
  font-size: clamp(0.68rem, 1.5vh, 0.78rem);
  letter-spacing: 0;
  opacity: 0.75;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: max(16px, var(--safe-t)) 16px max(16px, var(--safe-b));
  background: rgba(4, 10, 16, 0.72);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(400px, 100%);
  background: linear-gradient(180deg, #152637, #0d1722);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: clamp(22px, 3.2vh, 30px) 20px 18px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.2, 1);
  overflow: hidden;
}

.modal-card.is-win {
  border-color: rgba(125, 255, 196, 0.35);
  box-shadow:
    0 0 0 1px rgba(125, 255, 196, 0.15),
    0 0 48px rgba(42, 171, 238, 0.28),
    0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.2, 1), win-pulse 1.6s ease-in-out infinite;
}

.win-burst {
  display: none;
  position: absolute;
  inset: -40%;
  background:
    conic-gradient(from 0deg, transparent 0 8%, rgba(240, 213, 106, 0.12) 8% 10%, transparent 10% 20%, rgba(42, 171, 238, 0.1) 20% 22%, transparent 22% 100%);
  animation: burst-spin 8s linear infinite;
  pointer-events: none;
}

.modal-card.is-win .win-burst {
  display: block;
}

@keyframes burst-spin {
  to { transform: rotate(360deg); }
}

@keyframes win-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.modal-kicker {
  position: relative;
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.modal-card h2 {
  position: relative;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 3.8vh, 1.7rem);
  font-weight: 800;
}

.modal-text {
  position: relative;
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.4;
  font-size: clamp(0.85rem, 2vh, 0.98rem);
}

.btn-close {
  position: relative;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1rem;
  color: #041018;
  background: linear-gradient(135deg, #2aabee, #1dd1a1);
  -webkit-tap-highlight-color: transparent;
}

.modal-card.is-win h2 {
  color: #7dffc4;
  text-shadow: 0 0 24px rgba(125, 255, 196, 0.35);
}

.modal-card.is-lose h2 {
  color: #ff9b9b;
}

@media (max-height: 640px) {
  .lead { display: none; }
  .btn-hint { display: none; }
  .page { row-gap: 14px; }
  .wheel-stage { width: min(100%, calc(100dvh - 220px), 76vw); }
}

@media (max-height: 520px) {
  .hero h1 { display: none; }
  .brand { font-size: clamp(1.2rem, 5vh, 1.6rem); }
}
