:root {
  --bg: #1e0a52;
  --ray-a: #2a0e6c;
  --ray-b: #3b1793;
  --pink: #ff2e93;
  --sun: #ffd23f;
  --orange: #ff9f1c;
  --cyan: #22d3ee;
  --mint: #12d6a0;
  --indigo: #1a0b4d;
  --purple: #6d3fe0;
  --lav: #d9ccff;
  --line: rgba(217, 204, 255, 0.22);
  --card: #24106a;
  --sans: "Avenir Next", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* Scrollbars in the Spin Fiesta colours */
html,
.panel,
.tabs,
.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: var(--purple) var(--indigo);
}

::-webkit-scrollbar { width: 12px; height: 10px; }
::-webkit-scrollbar-track { background: var(--indigo); }

::-webkit-scrollbar-thumb {
  border: 3px solid var(--indigo);
  border-radius: 999px;
  background: var(--purple);
}

::-webkit-scrollbar-thumb:hover { background: var(--sun); }
::-webkit-scrollbar-corner { background: var(--indigo); }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: #fff;
  font: 1rem/1.5 var(--sans);
}

body::before {
  content: "";
  position: fixed;
  inset: -60%;
  z-index: -1;
  background: repeating-conic-gradient(from 0deg at 50% 50%, var(--ray-a) 0 6deg, var(--ray-b) 6deg 12deg);
  animation: rays 200s linear infinite;
}

@keyframes rays { to { transform: rotate(360deg); } }

#app {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* Header */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.brand {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  color: var(--sun);
  text-shadow: 3px 3px 0 var(--pink);
}

.links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.links a {
  padding: 0.4rem 0.9rem;
  border: 2px solid var(--lav);
  border-radius: 999px;
  background: var(--purple);
  box-shadow: 0 3px 0 #3b1793;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.links a:hover { background: #7d52f0; }

.links a.play {
  border-color: var(--sun);
  background: var(--sun);
  box-shadow: 0 3px 0 var(--orange);
  color: var(--indigo);
  font-weight: 900;
}

.links a.play:hover { background: #ffe066; }

/* Hero */
.hero { margin: 1.75rem 0 2rem; }

h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(2rem, 5.5vw, 3.6rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.grad {
  background: linear-gradient(100deg, var(--sun), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lead {
  max-width: 40rem;
  margin: 0;
  color: var(--lav);
  font-size: 1.1rem;
}

h2 { margin: 0; font-size: 1.2rem; font-weight: 900; }
h3 { margin: 1.1rem 0 0.5rem; color: var(--sun); font-size: 0.85rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; }

/* Numbered steps */
.step {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.9rem;
  font-size: 1.25rem;
}

.step-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--sun);
  color: var(--indigo);
  font-size: 1rem;
  font-weight: 900;
}

.panel .step:not(:first-child) { margin-top: 1.6rem; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

.panel,
.card,
.stat,
.offer {
  border: 2px solid var(--line);
  border-radius: 1.2rem;
  background: var(--card);
}

.panel { padding: 1.25rem; }

/* Presets */
.presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.preset {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.8rem 0.85rem;
  border: 2px solid var(--line);
  border-radius: 0.9rem;
  background: var(--indigo);
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.preset b { font-size: 1rem; font-weight: 900; }
.preset small { color: var(--lav); font-size: 0.8rem; line-height: 1.3; }

.preset:hover { transform: translateY(-2px); border-color: var(--lav); }

.preset[aria-pressed="true"] {
  border-color: var(--sun);
  background: var(--sun);
  box-shadow: 0 4px 0 var(--orange);
  color: var(--indigo);
}

.preset[aria-pressed="true"] small { color: #4a2a8a; }

/* Custom rules */
.customize {
  margin-top: 0.9rem;
  border-radius: 0.9rem;
  background: rgba(26, 11, 77, 0.6);
}

.customize summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  color: var(--lav);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.customize summary::-webkit-details-marker { display: none; }

.customize summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-weight: 900;
}

.customize[open] summary::before { content: "−"; }
.customize[open] { padding-bottom: 0.9rem; }
.customize > :not(summary) { margin-left: 0.9rem; margin-right: 0.9rem; }

.custom-tag {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--cyan);
  color: var(--indigo);
  font-size: 0.75rem;
  font-weight: 900;
}

.fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.25rem;
  min-width: 0;
}

.field span { color: var(--lav); font-size: 0.8rem; font-weight: 700; line-height: 1.25; }

input,
select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 2px solid var(--line);
  border-radius: 0.65rem;
  background: var(--indigo);
  color: #fff;
  font: inherit;
  font-weight: 800;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.rtp { margin: 0.55rem 0 0; color: var(--lav); font-size: 0.85rem; }
.rtp b { color: var(--sun); }
.rtp b.over { color: var(--mint); }
.rtp b.under { color: #ff8fb8; }

.styles { display: grid; gap: 0.45rem; }

.style {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 4.2rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.55rem 0.45rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 0.75rem;
  background: var(--indigo);
}

.swatch { width: 0.8rem; height: 0.8rem; border-radius: 50%; }
.careful .swatch { background: var(--cyan); }
.balanced .swatch { background: #ff5fb0; }
.risky .swatch { background: var(--orange); }

.style-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.style-text small { color: var(--lav); font-size: 0.78rem; }

.mix-note { margin: 0.45rem 0 0; color: var(--lav); font-size: 0.8rem; }

/* Run */
.run {
  display: block;
  width: 100%;
  padding: 0.95rem 1rem;
  border: 0;
  border-radius: 0.9rem;
  background: var(--pink);
  box-shadow: 0 5px 0 #b01264;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.run:hover { background: #ff4fa5; }
.run:active { transform: translateY(3px); box-shadow: 0 2px 0 #b01264; }
.run:disabled { cursor: wait; }

.run { position: relative; overflow: hidden; }
.run-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(255, 255, 255, 0.25); }
#run-text { position: relative; }

/* Results */
.results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-content: start; min-width: 0; }
.results > .step { margin-bottom: 0; }

.verdict {
  padding: 1.5rem;
  border: 3px solid var(--sun);
  border-radius: 1.4rem;
  background: var(--card);
  box-shadow: 0 0 2.5rem rgba(255, 210, 63, 0.22);
}

.verdict.tight { border-color: #ff6b8a; box-shadow: 0 0 2.5rem rgba(255, 46, 147, 0.28); }
.verdict.balanced { border-color: var(--mint); box-shadow: 0 0 2.5rem rgba(18, 214, 160, 0.22); }

.verdict-chip {
  display: inline-block;
  margin: 0 0 0.7rem;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  background: var(--sun);
  color: var(--indigo);
  font-size: 0.9rem;
  font-weight: 900;
}

.verdict.tight .verdict-chip { background: #ff6b8a; }
.verdict.balanced .verdict-chip { background: var(--mint); }

.verdict h2 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.15;
}

.verdict p { margin: 0 0 0.45rem; }
.verdict p:last-child { margin-bottom: 0; }
.verdict-note { color: var(--sun); font-weight: 800; }
.verdict-note:empty { display: none; }

.verdict-tip {
  margin-top: 0.8rem !important;
  padding-top: 0.8rem;
  border-top: 2px solid var(--line);
  color: var(--lav);
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  padding: 0.9rem 1rem;
}

.stat-label { color: var(--lav); font-size: 0.82rem; font-weight: 800; line-height: 1.25; }

.stat b {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 900;
  line-height: 1.15;
  color: var(--sun);
  font-variant-numeric: tabular-nums;
}

.stat small { color: var(--lav); font-size: 0.76rem; line-height: 1.3; }
.stat em { font-size: 0.82rem; font-style: normal; font-weight: 800; }
.stat em:empty { display: none; }
.stat em.up { color: var(--mint); }
.stat em.down { color: #ff8fb8; }

/* Tabs */
.card { padding: 0.5rem 1.2rem 1.2rem; }

.tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0 -0.7rem 1rem;
  padding: 0.3rem;
  overflow-x: auto;
  border-radius: 0.9rem;
  background: var(--indigo);
}

.tab {
  flex: 1 0 auto;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-radius: 0.65rem;
  background: transparent;
  color: var(--lav);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.tab:hover { color: #fff; }

.tab[aria-selected="true"] {
  background: var(--purple);
  box-shadow: 0 3px 0 #3b1793;
  color: #fff;
}

.chart-note { margin: 0 0 0.7rem; color: var(--lav); font-size: 0.9rem; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-bottom: 0.6rem;
  color: var(--lav);
  font-size: 0.82rem;
  font-weight: 700;
}

.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i { display: inline-block; width: 1.3rem; height: 0.3rem; border-radius: 999px; }
.legend i.dashed { background: repeating-linear-gradient(90deg, #b8a8ff 0 5px, transparent 5px 9px); }

.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: 16rem; }

.tip {
  position: absolute;
  z-index: 2;
  min-width: 9rem;
  padding: 0.5rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 0.7rem;
  background: rgba(12, 4, 40, 0.96);
  font-size: 0.8rem;
  font-weight: 700;
  pointer-events: none;
}

.tip b { display: block; margin-bottom: 0.2rem; color: var(--sun); }
.tip div { display: flex; justify-content: space-between; gap: 0.8rem; }

.histo {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 15rem;
  padding-top: 1rem;
}

.bar {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  min-width: 0;
  gap: 0.3rem;
  text-align: center;
}

.bar-value { font-size: 0.8rem; font-weight: 800; color: var(--sun); }

.bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 0.5rem 0.5rem 0.2rem 0.2rem;
  background: linear-gradient(180deg, var(--pink), #8a1cff);
  transition: height 0.5s ease;
}

.bar.never .bar-fill { background: linear-gradient(180deg, var(--mint), #0b8f6d); }
.bar-label { color: var(--lav); font-size: 0.72rem; font-weight: 700; line-height: 1.2; }

.table-wrap { overflow-x: auto; }

.styles-table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.styles-table th {
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid var(--line);
  color: var(--lav);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: left;
}

.styles-table td {
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.styles-table td:first-child { font-weight: 900; white-space: nowrap; }
.styles-table tr.total td { border-bottom: 0; background: rgba(255, 255, 255, 0.06); }

.swatch-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.3rem;
  border-radius: 50%;
}

.chip {
  display: inline-block;
  white-space: nowrap;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--sun);
  color: var(--indigo);
  font-size: 0.78rem;
  font-weight: 900;
}

.chip.healthy { background: var(--mint); }
.chip.tight { background: #ff6b8a; }

/* Buy offer */
.offer {
  padding: 1rem 1.2rem;
  border-color: var(--cyan);
  border-left-width: 6px;
}

.offer p { margin: 0; }
.offer-label { margin-bottom: 0.2rem !important; color: var(--cyan); font-size: 0.85rem; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; }

/* Actions */
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.ghost {
  flex: 1 1 auto;
  padding: 0.7rem 1rem;
  border: 2px solid var(--lav);
  border-radius: 0.8rem;
  background: var(--purple);
  box-shadow: 0 4px 0 #2a0e6c;
  color: #fff;
  font-weight: 800;
}

.ghost:hover:not(:disabled) { background: #7d52f0; }
.ghost:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #2a0e6c; }
.ghost:disabled { opacity: 0.45; cursor: not-allowed; }

.action-note { min-height: 1.4rem; margin: 0; color: var(--sun); font-size: 0.9rem; font-weight: 700; }

.how {
  padding: 0.9rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: 1rem;
  color: var(--lav);
}

.how summary { cursor: pointer; font-weight: 800; color: #fff; }
.how ul { margin: 0.8rem 0 0; padding-left: 1.2rem; }
.how li { margin-bottom: 0.4rem; }

footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 2px solid var(--line);
  color: var(--lav);
  font-size: 0.85rem;
}

footer p { margin: 0; }

@media (min-width: 64rem) {
  #app { padding: 1.5rem 2rem 3rem; }

  .layout {
    grid-template-columns: 22rem minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
  }

  .panel {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}

@media (max-width: 34rem) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 0.6rem; }
  .stat-label { flex: 1 1 100%; }
  .stat small { flex: 1 1 100%; }
  .histo { gap: 0.3rem; }
  .bar-label { font-size: 0.62rem; }
  .card { padding: 0.5rem 0.9rem 1rem; }
  .tabs { margin: 0 -0.4rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .bar-fill { transition: none; }
}
