*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-deep: #0d0618;
  --bg-mid: #1a0a2e;
  --accent: #ff2d7a;
  --accent-glow: rgba(255, 45, 122, 0.45);
  --accent-soft: #ff6b9d;
  --gold: #ffd166;
  --gold-glow: rgba(255, 209, 102, 0.6);
  --text: #f8f0ff;
  --text-muted: rgba(248, 240, 255, 0.55);
  --bar-bg: rgba(0, 0, 0, 0.55);
  --reel-item-w: 108px;
  --reel-gap: 4px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: "Outfit", system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(255, 45, 122, 0.18), transparent),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(120, 40, 200, 0.15), transparent),
    linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 0 calc(24px + var(--safe-bottom));
}

.header {
  text-align: center;
  padding: 8px 20px 4px;
  flex-shrink: 0;
}

.title {
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent-soft));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-top: 2px;
}

.deck-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 10px;
  min-height: 1.2em;
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  min-height: 0;
  width: 100%;
  position: relative;
}

.idle-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(280px, calc(100% - 40px));
  aspect-ratio: 2.5 / 3.5;
  margin: 0 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: 16px;
}

.idle-view.hidden {
  display: none;
}

.placeholder-icon {
  font-size: 3rem;
  opacity: 0.45;
}

.idle-view p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* CS2-style spinner bar */
.spinner {
  width: 100%;
  padding: 0 0 8px;
}

.spinner.hidden {
  display: none;
}

.spinner-bar {
  position: relative;
  width: 100%;
  background: var(--bar-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.6),
    0 8px 32px rgba(0, 0, 0, 0.4);
}

.spinner-window {
  width: 100%;
  height: calc(var(--reel-item-w) * 1.45 + 24px);
  overflow: hidden;
  position: relative;
}

.spinner-reel {
  display: flex;
  align-items: center;
  gap: var(--reel-gap);
  height: 100%;
  padding: 12px 0;
  will-change: transform;
}

.spinner-item {
  flex-shrink: 0;
  width: var(--reel-item-w);
  height: calc(var(--reel-item-w) * 1.45);
  border-radius: 6px;
  overflow: hidden;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.spinner-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0a0a0a;
  pointer-events: none;
}

.spinner-marker {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 14px;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
  z-index: 3;
  pointer-events: none;
}

.spinner-marker--top {
  top: 0;
}

.spinner-marker--bottom {
  bottom: 0;
}

.spinner-marker::before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: linear-gradient(180deg, var(--gold), rgba(255, 209, 102, 0.15));
}

.spinner-marker--top::before {
  top: 14px;
  height: calc(var(--reel-item-w) * 1.45 + 12px);
}

.spinner-marker--bottom::before {
  bottom: 14px;
  height: calc(var(--reel-item-w) * 1.45 + 12px);
  background: linear-gradient(0deg, var(--gold), rgba(255, 209, 102, 0.15));
}

.spinner.is-blurring .spinner-reel {
  filter: blur(1.5px);
}

/* Big card reveal */
.reveal {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 16px;
}

.reveal.hidden {
  display: none;
}

.reveal-card {
  width: min(92vw, 380px);
  max-height: min(58dvh, 520px);
  object-fit: contain;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 209, 102, 0.35);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 50px var(--gold-glow),
    0 24px 60px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: scale(0.55);
}

.reveal.is-visible .reveal-card {
  animation: cardReveal 0.65s cubic-bezier(0.22, 1.15, 0.36, 1) forwards;
}

@keyframes cardReveal {
  0% {
    opacity: 0;
    transform: scale(0.55);
  }
  60% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.controls {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 20px 0;
}

.btn-draw {
  width: 100%;
  padding: 18px 24px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  background: linear-gradient(135deg, var(--accent) 0%, #c9185a 100%);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow:
    0 4px 24px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
}

.btn-draw:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-draw:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-reset {
  width: 100%;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(255, 209, 102, 0.08);
  border: 1px solid rgba(255, 209, 102, 0.25);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  -webkit-appearance: none;
}

.btn-reset:active {
  transform: scale(0.97);
  background: rgba(255, 209, 102, 0.15);
}

.hidden {
  display: none !important;
}

@media (min-width: 481px) {
  .app {
    padding-top: 32px;
  }

  :root {
    --reel-item-w: 120px;
  }
}
