/* Spin Pick Wheel: all colour lives on the wheel. The page around it is plain ink on paper
   (true black in dark mode), so the slices and the winner carry the energy.
   Gabarito for display type and wheel labels, system sans for reading. */
@font-face {
  font-family: "Gabarito";
  src: url("/gabarito.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #15161a;
  --muted: #5d6270;
  --line: #dde0e6;
  --field: #ffffff;
  --primary: #15161a;
  --on-primary: #ffffff;
  --rim: #15161a;
  --peg: #ffffff;
  --focus: #2f7cf6;
  --display: "Gabarito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #121212;
    --ink: #f0f0f0;
    --muted: #a0a0a0;
    --line: #2b2b2b;
    --field: #0a0a0a;
    --primary: #f0f0f0;
    --on-primary: #000000;
    --rim: #262626;
    --peg: #e8e8e8;
  }
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }
body { margin: 0; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line); text-decoration-thickness: 1.5px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* Header */
header.site { position: relative; border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; }
.brand { font: 750 1.12rem/1 var(--display); letter-spacing: -0.01em; text-decoration: none; display: flex; align-items: center; gap: 9px; }
.brand .mark { width: 26px; height: 26px; }
nav.site { display: flex; gap: 22px; font-size: 0.93rem; }
nav.site a { text-decoration: none; color: var(--muted); }
nav.site a:hover, nav.site a[aria-current] { color: var(--ink); }

.menu { display: none; }
.menu summary { list-style: none; cursor: pointer; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; margin-right: -10px; }
.menu summary::-webkit-details-marker { display: none; }
.bars, .bars::before, .bars::after { display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease; }
.bars { position: relative; }
.bars::before, .bars::after { content: ""; position: absolute; left: 0; }
.bars::before { top: -6px; }
.bars::after { top: 6px; }
.menu[open] .bars { background: transparent; }
.menu[open] .bars::before { transform: translateY(6px) rotate(45deg); }
.menu[open] .bars::after { transform: translateY(-6px) rotate(-45deg); }
.menu nav { position: absolute; left: 0; right: 0; top: 56px; z-index: 400; display: grid; padding: 4px 16px 12px; background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: 0 16px 24px rgb(0 0 0 / 0.08); }
.menu nav a { padding: 13px 0; font: 600 1.05rem/1.3 var(--display); text-decoration: none; border-bottom: 1px solid var(--line); }
.menu nav a:last-child { border-bottom: 0; }

/* Type */
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.015em; }
h1 { font-weight: 800; font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.08; margin: 40px 0 12px; }
h2 { font-weight: 750; font-size: 1.5rem; line-height: 1.2; margin: 52px 0 10px; }
h3 { font-weight: 700; font-size: 1.12rem; line-height: 1.3; margin: 28px 0 4px; }
.prose { max-width: 68ch; }
.prose li { margin: 8px 0; }
.prose ol, .prose ul { padding-left: 1.3em; }
.lede { color: var(--muted); margin: 0 0 18px; }
kbd { font: inherit; }

/* ---------- Tool layout ---------- */
.tool {
  display: grid; gap: 0 40px; margin: 22px 0 8px;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas: "stage head" "stage panel";
  grid-template-rows: auto 1fr;
}
.tool-head { grid-area: head; }
.tool-head h1 { margin: 6px 0 10px; font-size: clamp(1.7rem, 3vw, 2.2rem); }
.stage { grid-area: stage; display: flex; flex-direction: column; align-items: center; gap: 18px; min-width: 0; }
.panel { grid-area: panel; min-width: 0; }

/* Wheel: as large as the viewport allows, never wider than its column. */
.wheel-box {
  --size: min(100%, calc(100svh - 56px - 130px));
  position: relative; width: var(--size); aspect-ratio: 1; min-width: 0;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.wheel { display: block; width: 100%; height: 100%; border-radius: 50%; cursor: pointer; touch-action: manipulation; }
.wheel:focus-visible { outline-offset: 4px; }
.pointer {
  position: absolute; top: -3.2%; left: 50%; width: 9%; min-width: 30px; max-width: 54px;
  translate: -50% 0; transform-origin: 50% 32%; fill: var(--ink); pointer-events: none;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.3));
}
.pointer circle { fill: var(--bg); }
.hub {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 19%; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; background: var(--rim); color: var(--peg);
  font: 750 clamp(0.85rem, 2.6vw, 1.35rem)/1 var(--display); pointer-events: none;
  box-shadow: 0 0 0 4px var(--peg), 0 3px 10px rgb(0 0 0 / 0.35);
}
.spinning .hub { opacity: 0.92; }

.spin-row { display: flex; gap: 10px; width: min(100%, 520px); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: 650 1rem/1 var(--display); cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.big { min-height: 62px; border-radius: 18px; font-size: 1.4rem; font-weight: 750; padding: 0 22px; }
.btn.primary.big { flex: 1; }
.btn.square { width: 62px; padding: 0; flex: none; }
.btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn kbd { font: 500 0.8rem/1 system-ui, sans-serif; opacity: 0.6; }
.link { background: none; border: 0; padding: 8px 0 8px 12px; color: var(--muted); font: inherit; font-size: 0.9rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }

/* Panel */
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.field-head label, .field-head h2 { font: 700 1.05rem/1.3 var(--display); margin: 0; letter-spacing: 0; }
.count { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
textarea {
  display: block; width: 100%; min-height: 236px; max-height: 50vh; resize: vertical;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--field); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
textarea:focus { border-color: var(--muted); outline: none; }
textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.row .btn { flex: 1 1 auto; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--primary); }
.num { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; flex: 1 1 auto; }
.num input { width: 5.5em; min-height: 44px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--field); color: var(--ink); font: 600 1.05rem/1 var(--display); }
.seg { border: 0; padding: 0; margin: 14px 0 0; display: flex; gap: 8px; }
.seg legend { font: 700 1.05rem/1.3 var(--display); padding: 0; margin-bottom: 6px; }
.seg label { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 0.95rem; text-align: center; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.history { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.history ol { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.history li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history li b { font: 650 1rem/1.4 var(--display); overflow-wrap: anywhere; }
.history li span { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; }
.history ol:empty::before { content: "Spin to see results here."; color: var(--muted); font-size: 0.92rem; }

/* Result board (name picker, teams) */
.board {
  width: 100%; min-height: min(56svh, 520px); border-radius: 28px; padding: 28px;
  background: var(--surface); border: 1.5px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px;
}
.board .hint { color: var(--muted); margin: 0; }
.board .hint b { display: block; color: var(--ink); font: 800 clamp(2.4rem, 7vw, 4.4rem)/1 var(--display); margin-bottom: 10px; }
.board ol.picks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; width: 100%; }
.picks li { display: flex; align-items: center; gap: 14px; justify-content: center; font: 800 clamp(2rem, 6vw, 3.6rem)/1.1 var(--display); overflow-wrap: anywhere; }
.picks.many li { font-size: clamp(1.3rem, 3vw, 1.9rem); justify-content: flex-start; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.picks.many li:last-child { border-bottom: 0; }
.picks i { flex: none; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--c); }
.picks .n { font: 600 0.9rem/1 system-ui, sans-serif; color: var(--muted); min-width: 1.6em; }
.board.rolling .picks li { opacity: 0.55; }
.board.teams { align-items: stretch; justify-content: flex-start; text-align: left; }
.board.teams .hint { margin: auto; text-align: center; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.team { border-radius: 18px; padding: 14px 16px; background: var(--bg); }
.team h3 { margin: 0 0 6px; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.team h3::before { content: ""; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--c); }
.team h3 span { margin-left: auto; color: var(--muted); font: 500 0.85rem/1.6 system-ui, sans-serif; }
.team ul { list-style: none; margin: 0; padding: 0; }
.team li { padding: 4px 0; overflow-wrap: anywhere; }

/* Winner dialog */
dialog.result {
  width: min(calc(100% - 32px), 520px); border: 0; border-radius: 28px; padding: 28px 24px 22px;
  background: var(--surface); color: var(--ink); text-align: center; box-shadow: 0 30px 80px rgb(0 0 0 / 0.35);
}
dialog.result::backdrop { background: rgb(0 0 0 / 0.5); }
.result .label { margin: 0; color: var(--muted); font-size: 0.95rem; }
.result .winner {
  margin: 8px 0 22px; font: 850 clamp(2.2rem, 10vw, 4.2rem)/1.05 var(--display); letter-spacing: -0.02em; overflow-wrap: anywhere;
  text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 0.14em; text-underline-offset: 0.16em;
}
.result .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.result .actions .btn { flex: 1 1 120px; min-height: 52px; font-size: 1.1rem; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 2000; padding: 12px 18px; border-radius: 12px;
  background: var(--primary); color: var(--on-primary); font-weight: 600; box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
}

/* Fullscreen: only the wheel and its button, as large as the screen allows. */
.stage.is-full {
  position: fixed; inset: 0; z-index: 1000; background: var(--bg); justify-content: center; padding: 40px 16px 16px;
}
.stage.is-full .wheel-box { --size: min(calc(100vw - 32px), calc(100svh - 150px)); }
.stage:fullscreen { background: var(--bg); }

/* Other tools */
.others { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.others a { display: grid; padding: 14px 0; text-decoration: none; border-bottom: 1px solid var(--line); }
.others b { font: 700 1.12rem/1.3 var(--display); }
.others span { color: var(--muted); font-size: 0.95rem; }
.others a:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* Footer */
footer.site { margin-top: 88px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.92rem; }
footer.site .wrap { padding-block: 36px 28px; }
.footer-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.footer-cols h2 { font: 700 0.95rem/1.4 var(--display); letter-spacing: 0; margin: 0 0 8px; color: var(--ink); }
.footer-cols ul { list-style: none; padding: 0; margin: 0; }
.footer-cols li { margin: 6px 0; }
.footer-cols a { text-decoration: none; }
.footer-cols a:hover { color: var(--ink); }

@media (max-width: 900px) {
  nav.site { display: none; }
  .menu { display: block; }
  .tool { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "stage" "panel"; grid-template-rows: auto; margin-top: 12px; }
  .tool-head h1 { font-size: clamp(1.35rem, 5.6vw, 1.9rem); margin: 0 0 12px; text-align: center; }
  .stage { gap: 14px; }
  .wheel-box { --size: min(100%, calc(100svh - 56px - 170px)); min-width: min(100%, 280px); }
  .panel { margin-top: 28px; }
  .board { min-height: 300px; border-radius: 22px; padding: 22px 16px; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 14px; }
  h1 { margin-top: 28px; }
  h2 { font-size: 1.35rem; margin-top: 44px; }
  .btn kbd { display: none; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
}

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

/* Embed: just the wheel, sized to the host's iframe. */
.embed main.wrap { padding: 12px; }
.embed .tool { display: block; margin: 0; }
.embed .stage { gap: 12px; }
.embed .wheel-box { --size: min(calc(100vw - 24px), calc(100svh - 140px)); }
.embed .made-by { margin: 0; font-size: 0.9rem; color: var(--muted); }
