@font-face {
  font-family: Fredoka;
  src: url("/static/fonts/fredoka-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Fredoka;
  src: url("/static/fonts/fredoka-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("/static/fonts/nunito-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("/static/fonts/nunito-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #160b2e;
  --ink: #fff6e8;
  --muted: #d7c4f0;
  --gold: #ffd166;
  --pink: #ff5d8f;
  --cyan: #3dfff3;
  --orange: #ff7a18;
  --card: rgba(22, 10, 48, 0.78);
  --line: rgba(255, 209, 102, 0.38);
  --shadow: 0 18px 50px rgba(8, 2, 20, 0.45);
  --radius: 1.4rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }
body {
  font-family: Nunito, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}
img { max-width: 100%; height: auto; }
a { color: var(--gold); }
h1, h2, h3, .brand span, .winner-name {
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin: 0 0 0.4em; }
h2 { font-size: 1.5rem; }

.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(180deg, rgba(22, 11, 46, 0.28), rgba(22, 11, 46, 0.7)),
    url("/static/img/magic-bg.jpg");
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat;
}
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 10%, rgba(255, 93, 143, 0.22), transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(61, 255, 243, 0.12), transparent 35%);
  pointer-events: none;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(16, 6, 36, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.15rem;
}
.brand img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  object-fit: cover;
}
.nav {
  display: flex;
  gap: 1.65rem;
  align-items: center;
  flex-wrap: wrap;
}
.nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  padding: 0.15rem 0.1rem;
}
.nav a:not(.nav-account) + a:not(.nav-account) {
  position: relative;
}
.nav a:not(.nav-account) + a:not(.nav-account)::before {
  content: "";
  position: absolute;
  left: -0.9rem;
  top: 20%;
  bottom: 20%;
  width: 1px;
  background: rgba(255, 209, 102, 0.35);
}
.nav a:hover { color: var(--gold); }
.nav-account {
  background: var(--pink);
  color: #160b2e !important;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
}
.nav-toggle {
  display: none;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font: inherit;
}

.main { width: min(1120px, calc(100% - 1.6rem)); margin: 1.4rem auto 3rem; }
.foot { text-align: center; color: var(--muted); padding: 1rem 0 2rem; }
.foot a { color: var(--gold); text-decoration: none; font-weight: 700; }
.foot a:hover { text-decoration: underline; }
.ver { color: var(--gold); }
.settings-heading {
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--gold);
  margin: 0.85rem 0 0.45rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 2.5rem;
}
.eyebrow {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}
.lead { font-size: 1.12rem; color: var(--muted); }
.hero-art { position: relative; min-height: 280px; }
.hero-wheel {
  width: min(100%, 420px);
  border-radius: 50%;
  box-shadow: var(--shadow), 0 0 0 8px rgba(255, 209, 102, 0.35);
  animation: floaty 6s ease-in-out infinite;
}
.hero-booth {
  position: absolute;
  width: 42%;
  right: 0;
  bottom: -8%;
  border-radius: 1rem;
  box-shadow: var(--shadow);
}
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: 700 1rem Nunito, sans-serif;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: linear-gradient(90deg, var(--pink), var(--orange)); color: #1a0828; }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--line); }
.btn.danger { background: #5a1230; color: #ffd6e4; }
.btn.add-item {
  background: linear-gradient(90deg, #06d6a0, var(--cyan));
  color: #160b2e;
  gap: 0.35rem;
  box-shadow: 0 6px 16px rgba(61, 255, 243, 0.28);
}
.btn.add-item .add-icon { font-size: 1.25em; line-height: 1; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.hero-actions, .row-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.band h2 { margin-bottom: 1rem; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.list-card h3 { margin: 0 0 0.4rem; }
.list-card p { color: var(--muted); }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-size: 0.82rem;
}
.meta span, .pill {
  background: rgba(255, 209, 102, 0.12);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}
.pill { color: var(--cyan); }
.card-spark {
  position: absolute;
  width: 120px;
  height: 120px;
  right: -30px;
  top: -40px;
  background: url("/static/img/starburst.png") center / contain no-repeat;
  opacity: 0.28;
  pointer-events: none;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.2rem;
}
.empty { text-align: center; padding: 2rem 1rem; }
.empty img { width: min(280px, 70vw); border-radius: 1.2rem; margin-bottom: 1rem; }

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.4rem;
  align-items: start;
}
.form-card, .stack { display: grid; gap: 0.85rem; }
label { display: grid; gap: 0.35rem; font-weight: 700; }
input, textarea, select {
  font: inherit;
  color: var(--ink);
  background: rgba(8, 2, 24, 0.55);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.65rem 0.75rem;
}
textarea { resize: vertical; }
.form-msg { color: #ffb4c8; margin: 0; }
.form-msg.ok { color: var(--cyan); }
.tabs { display: flex; gap: 0.4rem; }
.tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.5rem;
  font: inherit;
  cursor: pointer;
}
.tab.on { color: var(--ink); border-color: var(--gold); background: rgba(255, 209, 102, 0.12); }
.aside-art img { border-radius: var(--radius); box-shadow: var(--shadow); }
.choice {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  font-weight: 400;
}
.choice input { width: auto; }

.toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.15rem;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.toggle-ui {
  width: 2.7rem;
  height: 1.5rem;
  border-radius: 999px;
  background: rgba(8, 2, 24, 0.7);
  border: 1px solid var(--line);
  position: relative;
  flex: 0 0 auto;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.35);
}
.toggle-ui::after {
  content: "";
  position: absolute;
  top: 0.12rem;
  left: 0.14rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.18s ease;
}
.toggle input:checked + .toggle-ui {
  background: linear-gradient(90deg, var(--pink), var(--orange));
  border-color: var(--gold);
}
.toggle input:checked + .toggle-ui::after {
  transform: translateX(1.15rem);
  background: #fff6e8;
}
.toggle input:focus-visible + .toggle-ui {
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.55);
}
.toggle-text { color: var(--ink); }

.with-tip { position: relative; display: grid; gap: 0.35rem; font-weight: 700; }
.with-tip-head {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.info-dot {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: rgba(255, 209, 102, 0.15);
  color: var(--gold);
  font: 700 0.75rem Fredoka, Nunito, sans-serif;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.info-bubble {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 0.35rem);
  z-index: 8;
  width: min(16rem, 70vw);
  padding: 0.65rem 0.75rem;
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  background: #1c0b3a;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.86rem;
  box-shadow: var(--shadow);
}
.with-tip:hover .info-bubble,
.with-tip:focus-within .info-bubble,
.info-dot[aria-expanded="true"] + .info-bubble {
  display: block;
}

.mode-picker {
  border: 0;
  margin: 0.2rem 0 0;
  padding: 0;
  min-width: 0;
}
.mode-picker legend {
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 600;
  color: var(--gold);
  padding: 0 0 0.65rem;
}
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.mode-card {
  position: relative;
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: rgba(8, 2, 24, 0.5);
  cursor: pointer;
  min-width: 0;
  box-shadow: 0 8px 18px rgba(8, 2, 20, 0.25);
}
.mode-card input {
  appearance: none;
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.mode-title {
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 600;
  color: var(--ink);
}
.mode-blurb {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 400;
}
.mode-card:hover {
  border-color: rgba(255, 209, 102, 0.7);
}
.mode-card:focus-within,
.mode-card:has(input:checked) {
  border-color: var(--gold);
  background: linear-gradient(165deg, rgba(255, 93, 143, 0.32), rgba(255, 209, 102, 0.14) 55%, rgba(61, 255, 243, 0.08));
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.35), 0 10px 22px rgba(255, 93, 143, 0.22);
}
.mode-card:has(input:checked) .mode-title { color: var(--gold); }

.spin-page { display: grid; gap: 1.4rem; }
.stage {
  position: relative;
  display: grid;
  justify-items: center;
  grid-template-rows: 2.2rem auto 3rem 1.5rem;
  gap: 1.35rem;
  padding: 0.4rem 0 2rem;
}
.hint {
  grid-row: 1;
  margin: 0;
  color: var(--gold);
  font-weight: 700;
  min-height: 2.2rem;
  line-height: 2.2rem;
}
.wheel-stack { grid-row: 2; }
.stage .hint[hidden],
.stage .form-msg[hidden] {
  display: block !important;
  visibility: hidden;
}
.stage-action {
  grid-row: 3;
  min-height: 3rem;
  display: grid;
  place-items: center;
}
.stage .form-msg { grid-row: 4; min-height: 1.5rem; }
.wheel-stack {
  display: grid;
  justify-items: center;
  width: min(520px, 92vw);
}
.wheel-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  filter: drop-shadow(0 18px 28px rgba(0,0,0,0.45));
  cursor: pointer;
}
.wheel-wrap.busy { cursor: wait; }
.wheel-wrap.faded canvas { filter: blur(3px) saturate(0.7) brightness(0.55); }
#wheel { width: 100%; height: 100%; border-radius: 50%; }
.pointer {
  width: 12%;
  margin-bottom: -5%;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.4));
}
.hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18%;
  height: 18%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #ff5d8f 45%, #7b21ff);
  border: 4px solid #ffd166;
  box-shadow: 0 0 24px rgba(255, 93, 143, 0.8);
  z-index: 2;
  pointer-events: none;
}
.winner {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  z-index: 4;
  pointer-events: none;
  padding: 1rem;
}
.winner-icon {
  font-size: clamp(3rem, 12vw, 6rem);
  animation: pulse 0.9s ease-in-out infinite;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.45));
}
.winner-name {
  font-size: clamp(1.8rem, 7vw, 3.4rem);
  color: #fff;
  text-shadow: 0 4px 0 #ff5d8f, 0 8px 18px rgba(0,0,0,0.45);
  animation: pulse 0.9s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.fx {
  position: absolute;
  inset: 0;
  grid-area: 1 / 1 / -1 / -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.spin-again { min-width: 12rem; min-height: 2.9rem; }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.55rem; }
.history li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.55rem 0.85rem;
}
.history .dot {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}
.quiet { color: var(--muted); }

.editor { display: grid; gap: 1rem; }
.item-stack { display: grid; gap: 0.8rem; }
.item-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: start;
  padding: 0.7rem;
  border: 1px dashed var(--line);
  border-radius: 1rem;
}
.item-main { display: grid; gap: 0.5rem; }
.item-extras {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem;
  align-items: end;
}
.cadence-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  min-width: 0;
}
.cadence-pair input,
.cadence-pair select { width: 100%; min-width: 0; }
.icon-btn {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(8,2,24,0.55);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 2, 20, 0.7);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(640px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: #1c0b3a;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr));
  gap: 0.3rem;
}
.icon-grid button {
  font-size: 1.4rem;
  background: transparent;
  border: 0;
  cursor: pointer;
  border-radius: 0.6rem;
  padding: 0.25rem;
}
.icon-grid button:hover { background: rgba(255, 209, 102, 0.16); }

.guide {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 2rem);
  box-shadow: var(--shadow);
}
.guide h2 { color: var(--gold); margin-top: 1.6rem; }
.guide dt { font-weight: 700; margin-top: 0.8rem; }
.guide dd { margin: 0.2rem 0 0.4rem; color: var(--muted); }

.burst {
  position: absolute;
  width: 180px;
  height: 180px;
  margin: -90px 0 0 -90px;
  background: url("/static/img/starburst.png") center / contain no-repeat;
  pointer-events: none;
  z-index: 6;
  animation: burst 0.7s ease-out forwards;
}
@keyframes burst {
  0% { transform: scale(0.2) rotate(0deg); opacity: 1; }
  100% { transform: scale(1.4) rotate(40deg); opacity: 0; }
}

@media (max-width: 820px) {
  .sky {
    background-image:
      linear-gradient(180deg, rgba(22, 11, 46, 0.28), rgba(22, 11, 46, 0.7)),
      url("/static/img/magic-bg-portrait.jpg");
  }
  .hero, .split { grid-template-columns: 1fr; }
  .hero-booth { position: static; width: 55%; margin-top: 0.8rem; }
  .nav-toggle { display: inline-flex; }
  .item-extras { grid-template-columns: 1fr; }
  .nav {
    display: none;
    position: absolute;
    top: 64px;
    right: 0.8rem;
    left: 0.8rem;
    background: #1a0a36;
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 0.8rem;
    flex-direction: column;
    align-items: stretch;
  }
  .nav.open { display: flex; gap: 0.75rem; }
  .nav a:not(.nav-account) + a:not(.nav-account)::before { display: none; }
  .item-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-wheel, .winner-icon, .winner-name { animation: none; }
}
