:root {
  --paper: #f7f3e8;
  --ink: #202020;
  --muted: #5f5a50;
  --line: #d8d0be;
  --red: #d84d42;
  --blue: #2d70b7;
  --green: #2f8b57;
  --gold: #d9a441;
  --violet: #7b5fc4;
  --panel: #fffaf0;
  --shadow: 0 20px 55px rgba(49, 42, 29, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
textarea,
input,
select {
  font: inherit;
}

.site-header,
.site-footer {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-header {
  min-height: 76px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--gold);
  font-size: 0.76rem;
}

.site-nav,
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-nav a,
.site-footer a {
  text-decoration: none;
}

.hero {
  width: min(1440px, calc(100% - 28px));
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 8px 0 56px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.hero-copy {
  display: grid;
  max-width: none;
  grid-template-columns: minmax(0, 0.92fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: center;
}

.hero-copy .eyebrow {
  grid-column: 1 / -1;
  margin-bottom: -8px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-left: 5px solid var(--gold);
  background: rgba(216, 77, 66, 0.08);
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: none;
  font-size: clamp(2.3rem, 4vw, 3.8rem);
  line-height: 0.96;
  text-wrap: balance;
}

h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

h3 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.hero-text {
  max-width: 48ch;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.primary-link,
.spin-button,
.secondary-button,
.preset-row button,
.mode-button,
.editor-tab {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  padding: 0 18px;
  color: #fff;
  background: var(--ink);
  text-decoration: none;
}

.wheel-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.85fr);
  gap: 22px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.78);
  box-shadow: var(--shadow);
}

.wheel-stage {
  position: relative;
  display: grid;
  min-height: clamp(600px, 74vh, 820px);
  align-items: start;
  justify-items: center;
}

.wheel-frame {
  position: relative;
  width: min(100%, 840px);
  aspect-ratio: 1;
  margin-top: clamp(18px, 5vh, 54px);
}

.pair-stage {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 250, 240, 0.95) 0 26%, rgba(245, 234, 210, 0.94) 27% 100%),
    linear-gradient(135deg, rgba(216, 77, 66, 0.1), rgba(45, 112, 183, 0.12));
  box-shadow: inset 0 0 0 8px rgba(32, 32, 32, 0.08);
}

.wheel-panel.is-pair-mode canvas,
.wheel-panel.is-pair-mode .pointer {
  display: none;
}

.wheel-panel.is-pair-mode .pair-stage {
  display: grid;
}

.pair-visual {
  display: grid;
  width: min(82%, 620px);
  gap: clamp(16px, 3vw, 26px);
  text-align: center;
}

.pair-visual .eyebrow {
  margin: 0;
}

.pair-visual p:last-child {
  max-width: 42ch;
  margin: 0 auto;
  color: var(--muted);
  font-weight: 700;
}

.pair-dice-display {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 0.55fr) minmax(0, 1fr);
  gap: clamp(10px, 3vw, 28px);
  align-items: center;
}

.pair-dice-card {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.pair-dice-card > span:first-child {
  color: var(--ink);
  font-size: clamp(0.82rem, 1.7vw, 1rem);
  font-weight: 900;
  text-transform: uppercase;
}

.pair-dice-gap {
  display: block;
}

canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: drop-shadow(0 18px 24px rgba(49, 42, 29, 0.18));
}

.pointer {
  position: absolute;
  top: calc(50% - 15px);
  right: -8px;
  z-index: 2;
  width: 0;
  height: 0;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-right: 32px solid var(--ink);
}

.spin-button {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 126px;
  height: 126px;
  transform: translate(-50%, -50%);
  color: #fff;
  background: var(--ink);
  border: 5px solid var(--paper);
  border-radius: 50%;
  font-size: 1.28rem;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

.spin-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.controls-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}

.controls-panel label {
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: clamp(190px, 25vh, 260px);
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fffdf8;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fffdf8;
}

.button-row,
.preset-row,
.mode-row,
.editor-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.editor-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.editor-tab {
  color: var(--muted);
  background: transparent;
}

.editor-tab.is-active {
  color: #fff;
  background: var(--ink);
}

.editor-panel {
  display: none;
}

.editor-panel.is-active {
  display: block;
}

.results-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.results-list {
  display: grid;
  max-height: clamp(220px, 30vh, 330px);
  gap: 8px;
  overflow-y: auto;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.result-row {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 8px;
  background: #f4ecd9;
}

.result-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.probability-list {
  display: grid;
  max-height: clamp(220px, 30vh, 330px);
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.probability-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.9fr) minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.probability-row > * {
  min-width: 0;
}

.probability-row span:first-child {
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.probability-row output {
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.probability-row input[type="range"],
.range-control input[type="range"] {
  accent-color: var(--ink);
  padding: 0;
}

.mode-control {
  display: grid;
  gap: 8px;
}

.mode-control > span {
  font-weight: 800;
}

.mode-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.mode-button {
  color: var(--muted);
  background: transparent;
}

.mode-button.is-active {
  color: #fff;
  background: var(--ink);
}

.option-toggles {
  display: grid;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}

.option-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.range-control {
  display: grid;
  gap: 8px;
}

.range-control label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-control output {
  color: var(--muted);
  font-weight: 800;
}

.saved-presets {
  display: grid;
  gap: 8px;
}

.saved-presets > label {
  font-weight: 800;
}

.save-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.save-row:last-of-type {
  grid-template-columns: 1fr auto auto;
}

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

.secondary-button,
.preset-row button {
  padding: 0 10px;
  color: var(--ink);
  background: #ede3cf;
  min-width: 0;
  overflow-wrap: anywhere;
}

.danger-button {
  background: #f0d7d2;
}

.dice-tool {
  display: none;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.dice-tool.is-visible {
  display: grid;
}

.dice-display {
  display: grid;
  grid-template-columns: repeat(2, 54px);
  gap: 8px;
}

.die {
  display: grid;
  width: 54px;
  min-height: 54px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 6px 0 rgba(32, 32, 32, 0.12);
}

.die.rolling {
  transform: translateY(-2px) rotate(4deg);
}

.pair-stage .die {
  width: clamp(96px, 16vw, 150px);
  min-height: clamp(96px, 16vw, 150px);
  border-width: 4px;
  background: #fffdf8;
  color: var(--ink);
  font-size: clamp(2.35rem, 7vw, 4.6rem);
  box-shadow: 0 12px 0 rgba(32, 32, 32, 0.13), 0 18px 35px rgba(49, 42, 29, 0.16);
}

.fate-counter {
  display: grid;
  grid-template-columns: auto minmax(4ch, auto) auto;
  gap: 8px;
  align-items: baseline;
  justify-content: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #fffdf8 0%, #f5ead2 100%);
  box-shadow: 0 10px 24px rgba(49, 42, 29, 0.1);
  color: var(--ink);
  font-weight: 900;
  text-align: center;
}

.fate-counter strong {
  min-width: 4ch;
  color: var(--red);
  font-size: clamp(1.45rem, 4.8vw, 2.35rem);
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
}

.fate-counter span {
  white-space: nowrap;
}

.result {
  display: flex;
  align-items: center;
  min-height: 42px;
  border-left: 4px solid var(--line);
  padding: 8px 0 8px 12px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.winner-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 32, 32, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.winner-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.winner-modal[hidden] {
  display: none;
}

.winner-card {
  position: relative;
  overflow: hidden;
  width: min(480px, 100%);
  padding: 26px 28px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf8 0%, #f5ead2 100%);
  box-shadow: 0 24px 70px rgba(49, 42, 29, 0.24);
  text-align: center;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transition: opacity 220ms ease, transform 220ms ease;
}

.winner-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 7px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green), var(--blue), var(--violet));
}

.winner-modal.is-open .winner-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.winner-card .eyebrow {
  margin-bottom: 8px;
}

.winner-card h2 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 4.6vw, 3rem);
  line-height: 0.95;
}

#winnerText {
  display: inline-block;
  max-width: 100%;
  margin: 4px auto 24px;
  padding: 10px 18px;
  border: 1px solid rgba(32, 32, 32, 0.12);
  border-radius: 8px;
  color: #fffaf0;
  background: var(--ink);
  font-size: clamp(1.55rem, 5vw, 2.35rem);
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.modal-close-button {
  justify-content: center;
}

.winner-card .button-row {
  width: min(320px, 100%);
  margin: 0 auto;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.content-band {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 84px 0;
  border-top: 1px solid var(--line);
}

.legal-page {
  display: grid;
  align-content: start;
  gap: 22px;
}

.legal-page .eyebrow {
  margin-bottom: -8px;
}

.legal-page h1 {
  margin-bottom: -4px;
}

.legal-page .hero-text,
.legal-page > p:not(.eyebrow) {
  max-width: 76ch;
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.75;
}

.legal-page .hero-text {
  max-width: 62ch;
}

.legal-page .primary-link {
  width: max-content;
  margin-top: 4px;
}

.section-heading {
  max-width: 760px;
  margin-bottom: 30px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.feature-grid article {
  min-height: 180px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.feature-grid p,
.tool-card p,
.text-stack p,
.faq p {
  color: var(--muted);
}

.tool-link-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.tool-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  align-content: start;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-radius: 8px;
}

.tool-card h3,
.tool-card p {
  margin: 0;
}

.tool-card h3 {
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 800;
}

.starter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.starter-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 220px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.starter-card p {
  margin: 0;
  color: var(--muted);
}

.starter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.starter-list li {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4ecd9;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.text-link {
  color: var(--ink);
  font-weight: 900;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

.split-band {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 48px;
}

.content-band.split-band h1 {
  margin-bottom: 18px;
}

.content-band.split-band .hero-text {
  margin-bottom: 20px;
}

.text-stack {
  display: grid;
  gap: 18px;
  font-size: 1.08rem;
}

.text-stack p {
  margin: 0;
}

.faq details {
  border-top: 1px solid var(--line);
  padding: 20px 0;
}

.faq details:last-child {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  cursor: pointer;
  font-size: 1.08rem;
  font-weight: 800;
}

.faq p {
  max-width: 78ch;
  margin-bottom: 0;
}

.site-footer {
  min-height: 92px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

@media (max-width: 1220px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
    padding-top: 8px;
  }

  .hero-copy {
    display: grid;
    max-width: none;
    grid-template-columns: minmax(0, 0.9fr) minmax(260px, 1fr);
    gap: 16px;
    align-items: center;
  }

  .hero-copy .eyebrow {
    grid-column: 1 / -1;
    margin-bottom: -8px;
  }

  .hero-copy h1 {
    max-width: none;
    font-size: clamp(2.2rem, 4.2vw, 3.4rem);
    line-height: 0.96;
  }

  .hero-text {
    max-width: 44ch;
    margin: 0;
  }

  .wheel-panel {
    grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.85fr);
    gap: 18px;
    padding: 16px;
  }

  .wheel-stage {
    min-height: clamp(560px, 68vh, 720px);
  }
}

@media (max-width: 1080px) {
  .hero-copy {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr);
  }

  .wheel-panel {
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.85fr);
    padding: 14px;
  }

  .wheel-stage {
    min-height: clamp(520px, 64vh, 680px);
  }
}

@media (max-width: 980px) {
  .wheel-panel,
  .split-band {
    grid-template-columns: 1fr;
  }

  .wheel-stage {
    min-height: clamp(460px, 62vh, 620px);
  }

  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tool-link-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .starter-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding: 16px 0;
  }

  .site-header {
    min-height: 112px;
  }

  .hero,
  .hero-copy {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .hero-copy {
    gap: 14px;
  }

  .hero-copy .eyebrow {
    margin-bottom: 0;
  }

  .hero-copy h1 {
    font-size: clamp(2.9rem, 16vw, 4.8rem);
  }

  .wheel-panel {
    padding: 12px;
  }

  .wheel-stage {
    min-height: clamp(340px, 58vh, 500px);
  }

  .pointer {
    right: -2px;
  }

  .spin-button {
    width: 88px;
    height: 88px;
  }

  .feature-grid,
  .tool-link-grid,
  .button-row,
  .mode-row,
  .preset-row,
  .save-row,
  .save-row:last-of-type,
  .dice-tool,
  .fate-counter {
    grid-template-columns: 1fr;
  }

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

  .probability-row {
    grid-template-columns: 1fr;
  }

  .probability-row output {
    text-align: left;
  }

  .editor-tabs,
  .results-toolbar {
    grid-template-columns: 1fr;
  }

  .content-band {
    padding: 58px 0;
  }
}
