:root {
  color-scheme: dark;
  --bg: #070b16;
  --bg-soft: #0d1324;
  --panel: rgba(12, 18, 35, 0.88);
  --panel-border: rgba(142, 162, 255, 0.18);
  --text: #f4f7ff;
  --muted: #95a1c3;
  --accent: #6d5cff;
  --accent-2: #39b8ff;
  --gold: #ffce63;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  --card-width: clamp(132px, 18vw, 156px);
  --card-height: clamp(278px, 36vw, 346px);
  --gap: 16px;
  --track-offset: 0px;
  --media-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(74, 98, 255, 0.2), transparent 28%),
    radial-gradient(circle at bottom right, rgba(39, 184, 255, 0.14), transparent 24%),
    linear-gradient(180deg, #07101e 0%, #070b16 55%, #04060d 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
  opacity: 0.35;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0 80px;
}

.hero {
  max-width: 760px;
  margin: 0 auto 30px;
  text-align: center;
}

.result-card__eyebrow,
.result-card__rarity {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 4.4rem);
  line-height: 0.96;
}

.roulette-section {
  display: grid;
  gap: 30px;
}

.roulette-frame {
  position: relative;
  border: 1px solid var(--panel-border);
  border-radius: 30px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(13, 19, 36, 0.94), rgba(8, 11, 22, 0.98));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.roulette-frame__glow {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(circle at center, rgba(109, 92, 255, 0.24), transparent 30%),
    radial-gradient(circle at 65% 50%, rgba(57, 184, 255, 0.18), transparent 26%);
  filter: blur(30px);
  pointer-events: none;
}

.roulette-viewport {
  position: relative;
  min-height: calc(var(--card-height) + 34px);
  overflow: hidden;
  border-radius: 22px;
  padding: 18px 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    linear-gradient(90deg, rgba(7, 11, 22, 0.92) 0%, rgba(7, 11, 22, 0.22) 14%, rgba(7, 11, 22, 0.22) 86%, rgba(7, 11, 22, 0.92) 100%);
}

.roulette-viewport::before,
.roulette-viewport::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20%;
  pointer-events: none;
  z-index: 2;
}

.roulette-viewport::before {
  left: 0;
  background: linear-gradient(90deg, rgba(7, 11, 22, 1) 0%, rgba(7, 11, 22, 0) 100%);
}

.roulette-viewport::after {
  right: 0;
  background: linear-gradient(270deg, rgba(7, 11, 22, 1) 0%, rgba(7, 11, 22, 0) 100%);
}

.roulette-marker {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 0;
  transform: translateX(-50%);
  z-index: 4;
  pointer-events: none;
}

.roulette-marker::before,
.roulette-marker::after,
.roulette-marker span {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.roulette-marker span {
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(57, 184, 255, 0), rgba(57, 184, 255, 1) 22%, rgba(255, 206, 99, 1) 50%, rgba(57, 184, 255, 1) 78%, rgba(57, 184, 255, 0));
  box-shadow: 0 0 22px rgba(57, 184, 255, 0.45);
}

.roulette-marker::before,
.roulette-marker::after {
  width: 22px;
  height: 22px;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  background: linear-gradient(180deg, #ffd06d 0%, #ff9d43 100%);
  filter: drop-shadow(0 8px 16px rgba(255, 157, 67, 0.4));
}

.roulette-marker::before {
  top: 2px;
}

.roulette-marker::after {
  bottom: 2px;
  transform: translateX(-50%) rotate(180deg);
}

.roulette-track {
  display: flex;
  align-items: center;
  gap: var(--gap);
  width: max-content;
  transform: translate3d(var(--track-offset), 0, 0);
  will-change: transform;
}

.beer-card {
  width: var(--card-width);
  height: var(--card-height);
  flex: 0 0 auto;
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03)),
    rgba(9, 13, 24, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 20px 40px rgba(0, 0, 0, 0.28);
}

.beer-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

.beer-card__media {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 18px;
  padding: 18px 8px 14px;
  background: var(--media-bg);
  box-shadow:
    inset 0 0 0 1px rgba(24, 28, 39, 0.08);
  min-height: 0;
}

.beer-card__media::after {
  content: "";
  position: absolute;
  inset: auto 12px 8px;
  height: 24px;
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.16);
  filter: blur(10px);
}

.beer-card img {
  position: relative;
  z-index: 1;
  display: block;
  width: auto;
  height: auto;
  max-width: 72%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.beer-card__meta {
  display: grid;
  gap: 4px;
}

.beer-card__name {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.16;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.beer-card[data-rarity="rare"] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 20px 40px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(57, 184, 255, 0.16);
}

.beer-card[data-rarity="epic"] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 20px 40px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(160, 104, 255, 0.22);
}

.beer-card[data-rarity="legendary"] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 20px 40px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 206, 99, 0.28),
    0 0 40px rgba(255, 177, 57, 0.16);
}

.controls {
  display: flex;
  justify-content: center;
  text-align: center;
  padding-top: 6px;
}

.spin-button,
.ghost-button {
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.spin-button {
  min-width: min(100%, 320px);
  padding: 18px 28px;
  border-radius: 999px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  color: #fefeff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow:
    0 18px 40px rgba(62, 104, 255, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.spin-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.spin-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.spin-button--secondary {
  min-width: 0;
}

.ghost-button {
  padding: 15px 22px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 6, 14, 0.82);
  backdrop-filter: blur(16px);
}

.result-overlay[hidden] {
  display: none;
}

.result-card {
  width: min(560px, 100%);
  display: grid;
  gap: 22px;
  padding: 24px;
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(18, 26, 46, 0.98), rgba(8, 12, 24, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-card__image-wrap {
  min-height: 320px;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 24px;
  background: var(--media-bg);
  box-shadow:
    inset 0 0 0 1px rgba(24, 28, 39, 0.08);
}

.result-card__image-wrap img {
  display: block;
  max-width: 62%;
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.result-card__text {
  display: grid;
  gap: 8px;
}

.result-card h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.05;
}

.result-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

body.is-spinning .roulette-frame {
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(57, 184, 255, 0.08),
    0 0 80px rgba(84, 92, 255, 0.12);
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  :root {
    --card-width: min(42vw, 162px);
    --card-height: min(82vw, 310px);
    --gap: 14px;
  }

  .page-shell {
    width: min(100% - 20px, 1120px);
    min-height: 100svh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    justify-content: stretch;
    padding-top: max(36px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .hero {
    margin-bottom: 0;
  }

  .roulette-section {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: center;
    gap: 28px;
    padding-top: 26px;
  }

  .roulette-frame {
    width: 100%;
    align-self: center;
    padding: 14px;
    border-radius: 24px;
  }

  .controls {
    align-self: end;
    padding-top: 0;
    padding-bottom: 4px;
  }

  .roulette-viewport {
    min-height: calc(var(--card-height) + 28px);
    border-radius: 18px;
    padding: 14px 0;
  }

  .beer-card {
    padding: 12px;
    border-radius: 20px;
  }

  .beer-card__media {
    padding: 16px 6px 12px;
    border-radius: 16px;
  }

  .beer-card img {
    max-width: 76%;
  }

  .result-card {
    padding: 18px;
    border-radius: 24px;
  }

  .result-card__image-wrap {
    min-height: 280px;
  }

  .result-card__image-wrap img {
    max-width: 72%;
    max-height: 260px;
  }
}
