:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-strong: #172033;
  --line: rgba(148, 163, 184, 0.22);
  --text: #f8fafc;
  --muted: #94a3b8;
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.18);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.16);
  --cyan: #06b6d4;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 50% -10%, rgba(34, 197, 94, 0.18), transparent 36rem),
    linear-gradient(180deg, #0b1120 0%, var(--bg) 48%, #050816 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 31rem);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

.top-panel,
.game-panel,
.install-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.94), rgba(15, 23, 42, 0.9));
  box-shadow: var(--shadow);
}

.top-panel {
  padding: 1rem;
  border-radius: 8px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.coin-mark {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 0 18px rgba(34, 197, 94, 0.55));
}

.coin-mark svg {
  width: 100%;
  height: 100%;
}

.eyebrow {
  margin: 0 0 0.1rem;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.05;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.stat-row > div {
  min-width: 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.stat-row span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.stat-row strong {
  display: block;
  margin-top: 0.25rem;
  color: var(--green);
  font-size: clamp(1rem, 5vw, 1.35rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.progress-track {
  height: 0.72rem;
  margin-top: 1rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.5);
  transition: width 500ms ease;
}

.gap-text {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.game-panel {
  padding: 1rem;
  border-radius: 8px;
}

.prize-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.48rem, 2vw, 0.72rem);
  aspect-ratio: 1;
}

.prize-cell,
.spin-button {
  min-width: 0;
  border-radius: 8px;
  color: var(--text);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.prize-cell {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background:
    radial-gradient(circle at 50% 34%, rgba(251, 191, 36, 0.13), transparent 2.5rem),
    linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.prize-cell span {
  color: var(--gold);
  font-size: clamp(2rem, 11vw, 3.2rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 22px rgba(251, 191, 36, 0.42);
}

.prize-cell small {
  color: rgba(148, 163, 184, 0.72);
  font-size: 0.68rem;
  font-weight: 800;
}

.prize-cell.is-active {
  transform: translateY(-2px) scale(1.03);
  border-color: rgba(251, 191, 36, 0.92);
  background: linear-gradient(145deg, rgba(251, 191, 36, 0.28), rgba(34, 197, 94, 0.22));
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.2), 0 0 28px rgba(251, 191, 36, 0.42);
}

.spin-button {
  background: radial-gradient(circle at 50% 20%, #fde68a, var(--gold) 46%, #b45309 100%);
  color: #1f1300;
  font-weight: 1000;
  font-size: clamp(1rem, 5vw, 1.45rem);
  box-shadow: 0 0 28px rgba(251, 191, 36, 0.38);
  animation: pulseGlow 1.6s ease-in-out infinite;
}

.spin-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.6);
  opacity: 0.62;
  animation: none;
}

.spin-button::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.55), transparent 62%);
  transform: translateX(-60%) rotate(8deg);
  animation: shine 2.4s ease-in-out infinite;
  z-index: -1;
}

.countdown-panel {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 8px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.28);
  text-align: center;
}

.countdown-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.countdown-panel strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--cyan);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.install-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: 8px;
}

.install-card strong,
.install-card span {
  display: block;
}

.install-card strong {
  color: var(--gold);
  font-size: 0.9rem;
}

.install-card span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.primary-button,
.secondary-button {
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 8px;
  font-weight: 900;
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #02130b;
  box-shadow: 0 12px 34px rgba(34, 197, 94, 0.25);
}

.secondary-button {
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.82);
  color: var(--text);
}

.icon-button {
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
}

.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(12px);
  transition: opacity 180ms ease;
}

.modal {
  width: min(100%, 26rem);
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: 8px;
  padding: 1rem;
  background: linear-gradient(180deg, #172033, #0f172a);
  box-shadow: var(--shadow), 0 0 64px rgba(251, 191, 36, 0.14);
  transform: translateY(0) scale(1);
  animation: modalIn 220ms ease both;
  position: relative;
}

.modal .icon-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}

.modal-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 0.8rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #1f1300;
  font-size: 2rem;
  font-weight: 1000;
  box-shadow: 0 0 36px rgba(251, 191, 36, 0.38);
}

.modal h2 {
  margin: 0;
  padding-right: 2.5rem;
  text-align: center;
  font-size: clamp(1.35rem, 7vw, 2rem);
}

.modal p {
  margin: 0.75rem 0 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.wallet-field {
  display: block;
  margin-top: 1rem;
}

.wallet-field span {
  display: block;
  margin-bottom: 0.42rem;
  color: var(--gold);
  font-size: 0.84rem;
  font-weight: 900;
}

.wallet-field input {
  width: 100%;
  min-height: 3rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 0 0.8rem;
  background: rgba(2, 6, 23, 0.58);
  color: var(--text);
  outline: none;
}

.wallet-field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-top: 1rem;
}

.install-prompt {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 45;
  width: min(calc(100% - 2rem), 34rem);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  border: 1px solid rgba(34, 197, 94, 0.36);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: var(--shadow);
}

.install-prompt.is-ios {
  grid-template-columns: auto 1fr auto;
  align-items: start;
}

.install-prompt strong {
  display: block;
  color: var(--green);
  font-size: 0.9rem;
}

.install-prompt p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.phone-hint {
  width: 2.3rem;
  height: 3rem;
  border: 2px solid var(--gold);
  border-radius: 0.5rem;
  display: grid;
  place-items: end center;
  padding-bottom: 0.3rem;
  animation: phoneNudge 1.2s ease-in-out infinite;
}

.phone-hint span {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--gold);
}

.ios-install-steps {
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.ios-install-steps li {
  display: grid;
  grid-template-columns: 1.8rem 1fr;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  color: var(--text);
  font-size: 0.82rem;
}

.share-icon,
.plus-icon,
.check-icon {
  width: 1.8rem;
  height: 1.8rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.14);
  color: var(--gold);
  font-weight: 1000;
}

.share-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}

.check-icon {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.install-prompt.is-ios .primary-button {
  display: none;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

@keyframes pulseGlow {
  0%,
  100% {
    box-shadow: 0 0 22px rgba(251, 191, 36, 0.34), 0 0 0 0 rgba(251, 191, 36, 0.26);
  }
  50% {
    box-shadow: 0 0 34px rgba(251, 191, 36, 0.56), 0 0 0 10px rgba(251, 191, 36, 0);
  }
}

@keyframes shine {
  0%,
  30% {
    transform: translateX(-70%) rotate(8deg);
  }
  70%,
  100% {
    transform: translateX(70%) rotate(8deg);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(0.8rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes phoneNudge {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-0.25rem);
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 0.75rem;
  }

  .install-prompt {
    grid-template-columns: auto 1fr auto;
  }

  .install-prompt .icon-button {
    grid-column: 3;
  }

  .install-prompt .primary-button {
    grid-column: 2 / 4;
    width: 100%;
  }
}

@media (min-width: 760px) {
  .app-shell {
    width: min(100%, 58rem);
    display: grid;
    grid-template-columns: 0.88fr 1.12fr;
    align-content: center;
  }

  .install-card {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
