:root {
  --bg: #12061f;
  --bg-2: #2a0e4a;
  --gold: #ffc93c;
  --gold-2: #ff9f1c;
  --pink: #ff4f8b;
  --text: #fff7e8;
  --muted: #c9b8e6;
  --line: rgba(255, 255, 255, 0.12);
  --card: rgba(255, 255, 255, 0.06);
  --radius: 20px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background-color: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--font);
  min-height: 100dvh;
  color: var(--text);
  display: grid;
  grid-template-areas: "header" "main" "about" "banner" "disclaimer";
  grid-template-rows: auto 1fr auto auto auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 100lvh;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2) 0%, var(--bg) 60%);
}

header, main, #about-games, #ad-slot {
  width: min(100% - 2rem, 34rem);
  margin-inline: auto;
}

header {
  grid-area: header;
  text-align: center;
  padding: 1rem;
}

.eyebrow {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.title {
  margin: 0;
  font-size: clamp(1.9rem, 7vw, 2.75rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.title span {
  background: linear-gradient(to right, var(--gold), var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  color: var(--muted);
  margin-top: 0.5rem;
}

.sound-toggle {
  margin-top: 0.75rem;
  min-height: 44px;
  padding: 0 1rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.sound-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

main {
  grid-area: main;
  padding-top: 1rem;
  padding-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.games span {
  text-align: center;
  line-height: 1.15;
  padding: 0.25rem 0.4rem;
  font-size: 0.85rem;
}

.balls {
  --ball: clamp(84px, 24vw, 128px);
  display: grid;
  grid-template-columns: repeat(var(--n, 3), var(--ball));
  justify-content: center;
  gap: clamp(0.75rem, 4vw, 1.5rem);
  justify-items: center;
}

.balls[data-count="1"] { --n: 1; }
.balls[data-count="2"] { --n: 2; }
.balls[data-count="4"] { --n: 4; --ball: clamp(60px, 19vw, 100px); }
.balls[data-count="6"] { --n: 6; --ball: clamp(44px, 13vw, 76px); gap: clamp(0.25rem, 1.5vw, 0.75rem); }
.balls[data-count="6"] .digit { font-size: clamp(1.1rem, 5.2vw, 2.2rem); }
.balls[data-count="4"] .digit { font-size: clamp(1.8rem, 8vw, 3rem); }

.digit {
  width: var(--ball);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(2.6rem, 11vw, 4.25rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--bg-2);
  background: radial-gradient(circle at 35% 30%, #fff 0%, #fff3c4 35%, var(--gold) 70%, var(--gold-2) 100%);
  box-shadow: 0 10px 30px rgba(255, 159, 28, 0.35), inset 0 -6px 12px rgba(0, 0, 0, 0.15);
}

.digit:empty::before {
  content: "?";
  opacity: 0.35;
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
  75% { transform: rotate(-5deg); }
}

.digit.rolling {
  animation: wobble 120ms infinite;
}

@media (prefers-reduced-motion: reduce) {
  .digit.rolling {
    animation: none;
  }
}

.reasons {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  list-style: none;
  margin: 0;
  width: 100%;
  max-width: 34rem;
}

.reasons li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 1rem;
  line-height: 1.35;
}

.reasons li:not(:last-child) {
  border-bottom: 1px solid var(--line);
}

.mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg-2);
  font-weight: 900;
  font-size: 0.875rem;
}

#combo-output {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.6rem 1.25rem;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
  max-width: 100%;
}

#combo-output.prompt {
  letter-spacing: normal;
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 22rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.segmented span {
  display: block;
  min-height: 44px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--gold);
  color: var(--bg);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.about {
  width: 100%;
  max-width: 22rem;
  display: grid;
  gap: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

.about-row {
  display: grid;
  grid-template-columns: 1fr 6.5rem;
  gap: 0.75rem;
}

.field span,
.games legend,
.moods legend {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field small,
.moods legend small {
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
}

.about input[type="text"] {
  min-height: 44px;
  width: 100%;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  padding: 0 0.75rem;
}

.about input[type="text"]:focus-visible {
  outline: 2px solid var(--gold);
}

.games,
.moods {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.games legend,
.moods legend {
  grid-column: 1 / -1;
  padding: 0;
}

.games input,
.moods input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.games span,
.moods span {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.games span {
  gap: 0.35rem;
  justify-content: flex-start;
  text-align: left;
  line-height: 1.15;
  padding: 0.35rem 0.75rem 0.35rem 0.4rem;
}

@media (max-width: 359px), (min-width: 561px) {
  .games span { font-size: 0.78rem; padding-right: 0.4rem; gap: 0.25rem; }
}

@media (max-width: 560px) {
  .games {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 561px) {
  .about {
    max-width: 26rem;
  }
}

.games span::before {
  content: attr(data-ball) / "";
  flex: none;
  width: 1.6rem;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--bg);
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #fff3c4 35%, var(--gold) 70%, var(--gold-2) 100%);
  box-shadow: 0 0 0 1px var(--bg);
}

.games span.lotto::before {
  background: radial-gradient(circle at 35% 30%, #fff 0%, #ffd1e1 35%, var(--pink) 75%, #c2185b 100%);
}

.moods span {
  gap: 0.35rem;
}

.moods span::before {
  content: attr(data-emoji) / "";
  flex: none;
  font-size: 1.1em;
  line-height: 1;
}

.games input:checked + span,
.moods input:checked + span {
  background: var(--gold);
  color: var(--bg);
}

.games input:focus-visible + span,
.moods input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

#form-status {
  font-size: 0.85rem;
  color: var(--pink);
  min-height: 1.2em;
  margin: 0;
}

.for-name {
  color: var(--gold);
  font-weight: 800;
  text-align: center;
  margin: 0;
  overflow-wrap: anywhere;
}

.roast {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: center;
  color: var(--pink);
  font-weight: 600;
  font-size: 0.95rem;
  display: grid;
  gap: 0.25rem;
  overflow-wrap: anywhere;
}

.roast[hidden] {
  display: none;
}

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

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  width: 100%;
  max-width: 22rem;
}

#draw {
  font: inherit;
  min-height: 60px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: var(--bg);
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(255, 159, 28, 0.35);
  cursor: pointer;
  border: none;
}

#draw:active {
  transform: translateY(1px) scale(0.98);
}

#draw:focus-visible {
  outline: 3px solid #fff;
}

#share {
  font: inherit;
  min-height: 48px;
  border-radius: 999px;
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

#share:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#share:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

#share-status {
  min-height: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
}

/* Ad slot */
.ad-slot {
  grid-area: banner;
  height: 0;
  overflow: hidden;
}

footer#disclaimer {
  grid-area: disclaimer;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  background: rgba(18, 6, 31, 0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.625rem;
  line-height: 1.3;
  text-align: center;
  padding: 0.35rem 0.75rem calc(0.35rem + env(safe-area-inset-bottom));
  z-index: 100;
}

/* Desktop */
@media (min-width: 768px) {
  main {
    padding-top: 3rem;
  }
}

.segmented[hidden] {
  display: none;
}

/* Not-affiliated note (last child of main; clear of the fixed footer) */
.fine-print {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 0.625rem;
  line-height: 1.4;
  text-align: center;
}

/* Crawlable about / FAQ section (below the app, clear of the fixed footer) */
.about-games {
  grid-area: about;
  padding-bottom: calc(5rem + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.about-games h2 {
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
  font-size: 1.1rem;
}

.about-games ul {
  margin: 0;
  padding-left: 1.25rem;
}

.about-games details {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.5rem;
}

.about-games summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.about-games details p {
  margin: 0.5rem 0 0;
}

.about-games .lore { font-style: italic; }
