/* Spin the Wheel — styles. System fonts only, light/dark aware. */

:root {
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f6f4ff;
  --bg-blob-1: #ffd6e7;
  --bg-blob-2: #d6e9ff;
  --surface: #ffffff;
  --surface-2: #f1eefc;
  --text: #1e1b2e;
  --muted: #5d5a72;
  --border: #e2ddf5;
  --accent: #6c4cff;
  --accent-ink: #ffffff;
  --accent-soft: #ebe6ff;
  --hot: #ff3d6e;
  --danger: #d6263f;
  --shadow: 0 1px 2px rgba(30, 20, 80, .06), 0 8px 24px rgba(30, 20, 80, .08);
  --shadow-lg: 0 24px 64px rgba(30, 20, 80, .25);
  --radius: 18px;
  --ad-bg: repeating-linear-gradient(-45deg, transparent 0 10px, rgba(108, 76, 255, .04) 10px 20px);
  --ad-border: #c9c2e8;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12101c;
    --bg-blob-1: #3a1838;
    --bg-blob-2: #15284a;
    --surface: #1c1a2b;
    --surface-2: #26233a;
    --text: #f2f0ff;
    --muted: #aaa6c4;
    --border: #34304d;
    --accent: #8f78ff;
    --accent-ink: #12101c;
    --accent-soft: #2c2650;
    --danger: #ff6b81;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    --ad-bg: repeating-linear-gradient(-45deg, transparent 0 10px, rgba(143, 120, 255, .06) 10px 20px);
    --ad-border: #403a5e;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse 60% 50% at 0% 0%, var(--bg-blob-1), transparent 70%),
    radial-gradient(ellipse 60% 50% at 100% 10%, var(--bg-blob-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
code, kbd { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 10px;
}
.skip-link:focus { top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid transparent;
  background: none; cursor: pointer; font-weight: 650; white-space: nowrap;
  transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active { transform: scale(.96); }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px rgba(108, 76, 255, .35); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { border-color: var(--border); background: var(--surface); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--soft { background: var(--accent-soft); color: var(--text); }
.btn--soft:hover { filter: brightness(.97); }
.btn--text { min-height: 32px; padding: 0 8px; color: var(--accent); }
.btn--text:hover { background: var(--accent-soft); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn--danger { color: var(--danger); }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: var(--surface-2); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1240px; margin: 0 auto; padding: 14px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.brand__logo { width: 34px; height: 34px; stroke: none; transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.brand:hover .brand__logo { transform: rotate(240deg); }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 720px) {
  .header-actions .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .header-actions .btn { padding: 0 10px; }
  .brand__name { font-size: 1rem; }
}

/* ---------- Ad slots (fixed reserved size to avoid layout shift) ---------- */
.ad-slot {
  position: relative; display: grid; place-items: center; margin: 0 auto;
  border: 1.5px dashed var(--ad-border); border-radius: 12px; background: var(--ad-bg);
  overflow: hidden; contain: layout paint;
}
.ad-slot__label {
  font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); opacity: .8;
}
.ad-slot--leaderboard { width: min(728px, calc(100% - 32px)); height: 90px; margin-bottom: 8px; }
.ad-slot--rect { width: 300px; max-width: 100%; height: 250px; }
.ad-slot--bottom { width: min(728px, calc(100% - 32px)); height: 90px; margin-top: 24px; }
@media (max-width: 760px) {
  .ad-slot--leaderboard { width: 320px; max-width: calc(100% - 32px); height: 50px; }
  .ad-slot--bottom { width: 320px; max-width: calc(100% - 32px); height: 100px; }
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1240px; margin: 0 auto; padding: 8px 16px 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start;
}
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card h2 { font-size: 1.05rem; margin: 0; }

/* ---------- Stage ---------- */
.stage { display: flex; flex-direction: column; align-items: center; text-align: center; outline: none; padding-bottom: 8px; }
.stage__title {
  margin: 4px 0 0; font-size: clamp(1.7rem, 4.5vw, 2.8rem); line-height: 1.1; font-weight: 850; letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.stage__meta { margin: 6px 0 4px; color: var(--muted); font-size: .95rem; min-height: 1.5em; }

.wheel-wrap { width: min(100%, 560px); position: relative; }
.wheel {
  display: block; width: 100%; aspect-ratio: 1; height: auto; cursor: grab;
  touch-action: none; -webkit-tap-highlight-color: transparent; border-radius: 50%;
}
.wheel:active { cursor: grabbing; }
.wheel:focus-visible { outline-offset: -4px; }
.is-spinning .wheel { cursor: progress; }

.stage__actions { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

.spin-btn {
  position: relative; display: inline-flex; align-items: center; gap: 12px;
  min-width: 200px; justify-content: center; padding: 16px 36px; border: 0; border-radius: 999px;
  font-size: 1.35rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #ff3d6e, #ff8a3d 55%, #ffc93d);
  box-shadow: 0 6px 0 #c4224b, 0 14px 28px rgba(255, 61, 110, .35);
  transition: transform .1s ease, box-shadow .1s ease, filter .2s ease;
}
.spin-btn:hover { filter: saturate(1.15) brightness(1.04); }
.spin-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c4224b, 0 6px 14px rgba(255, 61, 110, .3); }
.spin-btn:disabled { filter: grayscale(.5) brightness(.95); cursor: progress; }
.spin-btn__kbd { background: rgba(255, 255, 255, .25); color: #fff; font-size: .7rem; letter-spacing: .04em; text-transform: none; }
@media (hover: none) { .spin-btn__kbd { display: none; } }

.open-full { margin-top: 10px; color: var(--accent); font-weight: 650; font-size: .9rem; }

/* ---------- Side / history ---------- */
.side { display: grid; gap: 20px; justify-items: center; }
.side > .card { width: 100%; }
.history__list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.history__item {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 4px; border-bottom: 1px solid var(--border);
  animation: pop-in .35s cubic-bezier(.2, .9, .3, 1.3);
}
.history__item:last-child { border-bottom: 0; }
.history__dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.history__name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.history__meta { color: var(--muted); font-size: .82rem; text-align: right; white-space: nowrap; }
.history__count {
  display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text); font-weight: 700; font-size: .75rem;
}
.history__empty { color: var(--muted); margin: 6px 0 2px; font-size: .95rem; }
@media (max-width: 960px) {
  .side { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
}
@media (max-width: 680px) {
  .side { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Content ---------- */
.content {
  max-width: 1240px; margin: 32px auto 0; padding: 0 16px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 20px;
}
.prose h2 { font-size: 1.3rem; margin: 0 0 10px; }
.prose h3 { font-size: 1.05rem; margin: 18px 0 6px; }
.prose ol, .prose ul { padding-left: 1.3em; margin: 0; }
.prose li { margin: 6px 0; }
.faq details { border-top: 1px solid var(--border); padding: 10px 0; }
.faq details:first-of-type { border-top: 0; }
.faq summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-weight: 800; color: var(--accent); transition: transform .2s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq p { margin: 8px 0 2px; color: var(--muted); }

.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 20px 16px 40px; }

/* ---------- Drawer / bottom sheet ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(15, 10, 35, .4);
  backdrop-filter: blur(2px); animation: fade-in .2s ease;
}
.drawer {
  position: fixed; z-index: 50; top: 0; right: 0; height: 100%; width: min(420px, 100%);
  display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-lg);
  border-left: 1px solid var(--border);
  transform: translateX(105%); transition: transform .32s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
}
.drawer.is-open { transform: none; visibility: visible; }
.drawer__grip { display: none; }
.drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--border);
}
.drawer__head h2 { margin: 0; font-size: 1.15rem; }
.drawer__body { overflow: auto; padding: 8px 18px 28px; overscroll-behavior: contain; }
.drawer__foot { display: flex; justify-content: flex-end; }

@media (max-width: 720px) {
  .drawer {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: auto; max-height: 86vh;
    border-left: 0; border-top: 1px solid var(--border); border-radius: 22px 22px 0 0;
    transform: translateY(105%);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .drawer__grip { display: block; width: 44px; height: 5px; border-radius: 5px; background: var(--border); margin: 8px auto 0; }
  .drawer__head { padding-top: 8px; }
}

/* ---------- Form fields ---------- */
.field { display: block; border: 0; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.field:last-child { border-bottom: 0; }
.field legend, .field__label { display: block; font-weight: 750; font-size: .92rem; margin-bottom: 8px; padding: 0; float: none; }
.field legend { float: left; width: 100%; }
.field legend + * { clear: both; }
.field__count { font-weight: 600; color: var(--muted); }
.field__hint { margin: 6px 0 8px; color: var(--muted); font-size: .82rem; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface);
  padding: 9px 12px; transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea { resize: vertical; min-height: 140px; font-family: var(--mono); font-size: .9rem; line-height: 1.6; }
.add-row { display: flex; gap: 8px; margin-bottom: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-weight: 650; font-size: .9rem; transition: transform .12s ease, border-color .15s;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip:active { transform: scale(.96); }

.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.palette {
  display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--border); background: var(--surface); text-align: left; font-size: .82rem; font-weight: 650;
  transition: border-color .15s, transform .12s;
}
.palette:hover { transform: translateY(-1px); }
.palette[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.palette__swatches { display: flex; height: 18px; border-radius: 6px; overflow: hidden; }
.palette__swatches span { flex: 1; }
.custom-colors { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.custom-colors input[type="color"] {
  width: 40px; height: 40px; padding: 0; border: 2px solid var(--border); border-radius: 10px; background: none; cursor: pointer;
}

.modes { display: grid; gap: 8px; }
.mode {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 12px; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode input { margin-top: 4px; accent-color: var(--accent); }
.mode span { display: grid; }
.mode small { color: var(--muted); }
.avoid-opts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; font-size: .92rem; }
.avoid-opts[hidden] { display: none; }
.avoid-opts input { width: 64px; display: inline-block; margin: 0 4px; }
.avoid-opts select { width: auto; }

.range { display: grid; gap: 4px; margin-bottom: 10px; font-size: .92rem; }
.range span { display: flex; justify-content: space-between; }
.range output { font-weight: 750; color: var(--accent); }
.range input { width: 100%; accent-color: var(--accent); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; font-size: .95rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--border); flex: none;
  transition: background-color .2s ease;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s cubic-bezier(.3, 1.4, .5, 1);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Winner dialog ---------- */
.winner {
  border: 0; border-radius: 26px; padding: 28px 28px 22px; width: min(440px, calc(100% - 32px));
  background: var(--surface); color: var(--text); text-align: center; box-shadow: var(--shadow-lg);
}
.winner[open] { animation: winner-in .45s cubic-bezier(.2, .9, .3, 1.35); }
.winner::backdrop { background: rgba(15, 10, 35, .45); backdrop-filter: blur(3px); }
.winner__kicker { margin: 0; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .1em; font-size: .78rem; }
.winner__name {
  margin: 10px 0 6px; font-size: clamp(2rem, 8vw, 3.2rem); line-height: 1.1; font-weight: 900; letter-spacing: -.02em;
  overflow-wrap: anywhere;
  background: linear-gradient(135deg, var(--winner-color, var(--accent)), var(--hot));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.winner__note { margin: 0 0 16px; color: var(--muted); min-height: 1.2em; font-size: .92rem; }
.winner__actions { display: flex; gap: 10px; justify-content: center; }
.winner__actions .btn { min-width: 120px; min-height: 46px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 90; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  background: #1e1b2e; color: #fff; padding: 10px 12px 10px 18px; border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: toast-in .3s cubic-bezier(.2, .9, .3, 1.3); font-weight: 600;
}
.toast .btn--text { color: #c7b8ff; }
.toast .btn--text:hover { background: rgba(255, 255, 255, .1); }
.toast[hidden] { display: none; }
@media (prefers-color-scheme: dark) { .toast { background: #f2f0ff; color: #1e1b2e; } .toast .btn--text { color: var(--accent-ink); } }

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 100; }

.noscript { text-align: center; padding: 20px; }

/* ---------- Mode-specific visibility ---------- */
.embed-only, .present-only { display: none; }

/* Embed mode: just the wheel. */
.embed .chrome, .embed .skip-link { display: none !important; }
.embed .embed-only { display: inline-block; }
.embed .layout { grid-template-columns: minmax(0, 1fr); padding-top: 12px; }
.embed .stage__title { font-size: clamp(1.3rem, 5vw, 2rem); }
.embed .wheel-wrap { width: max(220px, min(100%, 560px, calc(100vh - 190px))); }

/* Presentation mode: the stage takes over the screen. */
.presenting { overflow: hidden; }
.presenting .stage {
  position: fixed; inset: 0; z-index: 60; justify-content: center; padding: 16px;
  background:
    radial-gradient(ellipse 60% 50% at 0% 0%, var(--bg-blob-1), transparent 70%),
    radial-gradient(ellipse 60% 50% at 100% 100%, var(--bg-blob-2), transparent 70%),
    var(--bg);
}
.presenting .stage__title { font-size: clamp(2rem, 5vw, 3.6rem); }
.presenting .wheel-wrap { width: min(92vw, calc(100vh - 230px), 980px); }
.presenting .present-only { display: inline-flex; }
.presenting .open-full { display: none; }

/* ---------- Animations ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@keyframes winner-in { from { opacity: 0; transform: scale(.85) translateY(12px); } }
@keyframes title-bump { 50% { transform: scale(1.04); } }
.bump { animation: title-bump .4s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
