:root {
  --ink: #241d16;
  --muted: #766c61;
  --cream: #f6f0e5;
  --paper: #fffaf1;
  --orange: #e85b2a;
  --orange-dark: #b83d1b;
  --yellow: #f4b83f;
  --green: #5d7458;
  --blue: #537f93;
  --pink: #ce6e72;
  --line: rgba(36, 29, 22, 0.14);
  --shadow: 0 30px 80px rgba(67, 47, 28, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(244, 184, 63, 0.16), transparent 27rem),
    radial-gradient(circle at 90% 55%, rgba(232, 91, 42, 0.11), transparent 30rem),
    var(--cream);
  font-family: "DM Sans", sans-serif;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.17;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}

.site-header,
main,
footer {
  width: min(1160px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50% 45% 52% 42%;
  background: var(--orange);
  color: white;
  font-family: "Fraunces", serif;
  transform: rotate(-7deg);
}

.icon-button,
.close-button {
  display: grid;
  border: 0;
  place-items: center;
  cursor: pointer;
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 250, 241, 0.64);
  transition: 180ms ease;
}

.icon-button:hover {
  border-color: var(--ink);
  transform: rotate(20deg);
}

.icon-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.hero {
  padding: 38px 0 22px;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 15px;
  color: var(--orange-dark);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow span {
  width: 25px;
  height: 2px;
  background: currentColor;
}

h1,
h2 {
  font-family: "Fraunces", serif;
}

h1 {
  margin: 0;
  font-size: clamp(3.2rem, 8vw, 6.9rem);
  line-height: 0.94;
  letter-spacing: -0.065em;
}

.intro {
  max-width: 545px;
  margin: 25px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.65;
}

.intro strong {
  display: inline-block;
  color: var(--ink);
  font-size: 1.28em;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: underline;
  text-decoration-color: var(--orange);
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

.wheel-section {
  position: relative;
  display: grid;
  padding: 28px 0 76px;
  place-items: center;
}

.wheel-stage {
  position: relative;
  width: min(620px, 86vw);
  aspect-ratio: 1;
  filter: drop-shadow(0 25px 25px rgba(67, 47, 28, 0.18));
}

.wheel-shell {
  position: relative;
  width: 100%;
  height: 100%;
  border: clamp(9px, 1.5vw, 15px) solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 6px rgba(255, 250, 241, 0.9),
    0 0 0 3px rgba(36, 29, 22, 0.08);
}

#wheel {
  display: block;
  width: 100%;
  height: 100%;
}

.pointer {
  position: absolute;
  top: -25px;
  left: 50%;
  z-index: 4;
  width: 58px;
  height: 76px;
  transform: translateX(-50%);
  filter: drop-shadow(0 8px 5px rgba(44, 28, 18, 0.25));
  transform-origin: 50% 12%;
}

.pointer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--orange);
  border: 5px solid var(--ink);
  clip-path: polygon(50% 100%, 5% 0, 95% 0);
}

.pointer span {
  position: absolute;
  z-index: 1;
  top: 15px;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cream);
  transform: translateX(-50%);
}

.pointer.ticking {
  animation: pointer-tick 90ms ease-in-out;
}

@keyframes pointer-tick {
  50% { transform: translateX(-50%) rotate(8deg); }
}

.spin-button {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: clamp(115px, 21%, 142px);
  aspect-ratio: 1;
  padding: 0;
  border: 5px solid var(--ink);
  border-radius: 50%;
  place-content: center;
  background: var(--paper);
  box-shadow:
    0 6px 0 var(--ink),
    0 12px 22px rgba(43, 27, 15, 0.25);
  cursor: pointer;
  transform: translate(-50%, -52%);
  transition: 150ms ease;
}

.spin-button:hover:not(:disabled) {
  transform: translate(-50%, -54%) scale(1.04);
}

.spin-button:active:not(:disabled) {
  box-shadow: 0 2px 0 var(--ink);
  transform: translate(-50%, -48%);
}

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

.spin-button span {
  font-family: "Fraunces", serif;
  font-size: clamp(1.3rem, 3.5vw, 1.8rem);
  font-weight: 800;
  line-height: 1;
}

.spin-button small {
  margin-top: 3px;
  color: var(--orange-dark);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.hint span {
  color: var(--orange);
  font-size: 1rem;
}

.round-status {
  display: flex;
  margin-top: 9px;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.round-progress {
  margin: 0;
  color: var(--orange-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.clear-history {
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
}

.clear-history:hover {
  color: var(--ink);
}

.clear-history:disabled {
  cursor: default;
  opacity: 0.35;
}

.promise {
  display: flex;
  max-width: 760px;
  margin: 0 auto 100px;
  padding: 28px 30px;
  border-block: 1px solid var(--line);
  align-items: center;
  gap: 23px;
}

.promise-icon {
  display: grid;
  min-width: 54px;
  height: 54px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  place-items: center;
  color: var(--orange);
  font-size: 1.5rem;
}

.promise h2 {
  margin: 0 0 5px;
  font-size: 1.25rem;
}

.promise p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

footer {
  display: flex;
  padding: 26px 0 38px;
  border-top: 1px solid var(--line);
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
}

footer button {
  border: 0;
  border-bottom: 1px solid currentColor;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-size: inherit;
}

.ownership {
  display: block;
  margin-top: 6px;
  color: color-mix(in srgb, var(--muted) 70%, transparent);
  font-size: 0.62rem;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.footer-actions a {
  color: var(--muted);
  font-size: 0.65rem;
  text-decoration: none;
}

.footer-actions a:hover {
  color: var(--ink);
}

dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(35, 27, 20, 0.65);
  backdrop-filter: blur(8px);
}

dialog[open] {
  animation: dialog-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.welcome-card {
  width: min(500px, calc(100vw - 28px));
  padding: 48px 40px 40px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.welcome-card h2 {
  margin: 0;
  font-size: clamp(2.4rem, 9vw, 4rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.welcome-card > p:not(.result-kicker) {
  max-width: 390px;
  margin: 18px auto 12px;
  color: var(--muted);
  line-height: 1.6;
}

.welcome-card > strong {
  display: block;
  margin-bottom: 28px;
  color: var(--ink);
  font-size: 1.55rem;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: var(--orange);
  text-decoration-thickness: 3px;
  text-underline-offset: 6px;
}

.welcome-card .primary-button {
  width: 100%;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
}

.dialog-card {
  width: min(560px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  padding: 34px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: auto;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.dialog-heading .eyebrow {
  margin-bottom: 8px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  letter-spacing: -0.04em;
}

.close-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  font-size: 1.8rem;
  line-height: 1;
}

.close-button:hover {
  background: rgba(36, 29, 22, 0.07);
}

.dialog-copy {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

.dialog-copy strong {
  color: var(--ink);
}

.dish-search {
  width: 100%;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: white;
}

.dish-search:focus {
  border-color: var(--ink);
}

.dish-list {
  display: grid;
  max-height: 310px;
  padding-right: 4px;
  gap: 8px;
  overflow-y: auto;
}

.dish-row {
  display: flex;
  min-width: 0;
  padding: 11px 12px 11px 16px;
  border: 1px solid var(--line);
  align-items: center;
  gap: 10px;
  background: white;
}

.dish-row span {
  flex: 1;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dish-row small {
  color: var(--muted);
}

.dish-row button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
}

.dish-row button:hover {
  background: #f7e5df;
  color: var(--orange-dark);
}

.add-row {
  display: flex;
  margin-top: 14px;
  gap: 8px;
}

.add-row input {
  min-width: 0;
  flex: 1;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: white;
}

.add-row input:focus {
  border-color: var(--ink);
}

.add-row button {
  padding: 0 17px;
  border: 1px solid var(--ink);
  background: var(--yellow);
  cursor: pointer;
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  margin: 9px 0 0;
  color: var(--orange-dark);
  font-size: 0.8rem;
}

.dialog-actions {
  display: flex;
  margin-top: 20px;
  justify-content: flex-end;
  gap: 9px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 0 20px;
  border: 1.5px solid var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--orange);
  color: white;
  box-shadow: 3px 3px 0 var(--ink);
}

.primary-button:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.primary-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.5;
}

.secondary-button {
  background: transparent;
}

.result-card {
  position: relative;
  width: min(520px, calc(100vw - 28px));
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.result-content {
  position: relative;
  z-index: 1;
  padding: 52px 40px 40px;
  text-align: center;
}

.result-kicker {
  margin: 0;
  color: var(--orange-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.result-sparkle {
  margin: 13px 0 1px;
  color: var(--yellow);
  font-size: 2rem;
}

.result-content h2 {
  margin: 0;
  font-size: clamp(3rem, 12vw, 5rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

.result-content > p:not(.result-kicker) {
  margin: 16px 0 27px;
  color: var(--muted);
}

.agreement {
  display: flex;
  padding: 16px;
  border: 1px solid var(--line);
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  text-align: left;
  font-size: 0.88rem;
  line-height: 1.45;
}

.agreement input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.custom-check {
  display: grid;
  min-width: 23px;
  height: 23px;
  border: 2px solid var(--ink);
  place-items: center;
  background: white;
}

.agreement input:checked + .custom-check {
  background: var(--green);
}

.agreement input:checked + .custom-check::after {
  content: "✓";
  color: white;
  font-weight: 700;
}

.result-button {
  width: 100%;
  margin-top: 16px;
}

.share-button {
  display: inline-flex;
  width: 100%;
  margin-top: 14px;
  padding: 13px 18px;
  border: 2px solid var(--ink);
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--green);
  color: #fffaf1;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 700;
}

.share-button svg {
  fill: currentColor;
}

.share-button:hover {
  filter: brightness(1.08);
}

.recipe-link {
  margin-top: 15px;
  padding: 5px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
}

.recipe-card {
  width: min(820px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
  padding: 38px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.recipe-card h2 {
  max-width: 650px;
  margin: 0;
  font-size: clamp(2.1rem, 7vw, 4rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.recipe-columns {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  margin-top: 32px;
  gap: 38px;
}

.recipe-columns h3 {
  margin: 0 0 14px;
  font-family: "Fraunces", serif;
  font-size: 1.2rem;
}

.recipe-columns ul,
.recipe-columns ol {
  display: grid;
  margin: 0;
  padding-left: 21px;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.recipe-note {
  margin: 28px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}

.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  z-index: 40;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: 220ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Mobile-first layout */
.site-header,
main,
footer {
  width: min(100% - 28px, 1160px);
}

.site-header {
  height: 76px;
}

.brand {
  font-size: 0.94rem;
  min-height: 48px;
  padding-block: 5px;
}

.icon-button {
  width: 48px;
  height: 48px;
}

.hero {
  padding: 22px 0 12px;
}

h1 {
  font-size: clamp(2.75rem, 14vw, 6.9rem);
}

.intro {
  margin-top: 18px;
}

.wheel-section {
  padding: 28px 0 54px;
}

.wheel-stage {
  width: min(92vw, 620px);
}

.pointer {
  top: -19px;
  width: 46px;
  height: 62px;
}

.spin-button {
  width: clamp(102px, 27%, 142px);
}

.hint {
  margin-top: 20px;
}

.round-status {
  flex-direction: column;
  gap: 7px;
}

.clear-history {
  min-height: 44px;
  padding: 10px 2px 5px;
}

.promise {
  margin-bottom: 62px;
  padding: 25px 8px;
  gap: 16px;
}

footer {
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.footer-actions {
  gap: 22px;
}

.footer-actions button,
.footer-actions a {
  display: inline-flex;
  min-width: 48px;
  min-height: 44px;
  padding-inline: 7px;
  align-items: center;
  justify-content: center;
}

.welcome-card,
.dialog-card,
.result-card,
.recipe-card {
  max-height: calc(100dvh - 20px);
}

.welcome-card {
  padding: 38px 21px 24px;
  overflow-y: auto;
}

.dialog-card {
  padding: 25px 18px;
}

.close-button {
  min-width: 48px;
  width: 48px;
  height: 48px;
}

.dish-search,
.add-row input,
.add-row button {
  min-height: 48px;
}

.dish-list {
  max-height: min(38dvh, 310px);
}

.dish-row {
  min-height: 52px;
  padding: 8px 8px 8px 13px;
}

.dish-row button {
  min-width: 44px;
  width: 44px;
  height: 44px;
}

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

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.primary-button,
.secondary-button {
  min-height: 50px;
  padding-inline: 14px;
}

.result-card {
  overflow-y: auto;
}

.result-content {
  padding: 38px 20px 24px;
}

.agreement {
  min-height: 58px;
  padding: 14px;
}

.recipe-link {
  min-height: 46px;
  margin-top: 10px;
  padding: 12px 0 6px;
}

.recipe-card {
  padding: 26px 18px;
}

.recipe-columns {
  grid-template-columns: 1fr;
  margin-top: 28px;
  gap: 28px;
}

.toast {
  bottom: 16px;
  width: min(calc(100% - 28px), 440px);
  text-align: center;
}

@media (min-width: 768px) {
  .site-header {
    height: 96px;
  }

  .brand {
    font-size: 1rem;
  }

  .hero {
    padding: 38px 0 22px;
  }

  h1 {
    font-size: clamp(3.2rem, 8vw, 6.9rem);
  }

  .intro {
    margin-top: 25px;
  }

  .wheel-section {
    padding: 28px 0 76px;
  }

  .wheel-stage {
    width: min(620px, 86vw);
  }

  .pointer {
    top: -25px;
    width: 58px;
    height: 76px;
  }

  .spin-button {
    width: clamp(115px, 21%, 142px);
  }

  .round-status {
    flex-direction: row;
    gap: 12px;
  }

  .promise {
    margin-bottom: 100px;
    padding: 28px 30px;
    gap: 23px;
  }

  footer {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }

  .welcome-card {
    padding: 48px 40px 40px;
  }

  .dialog-card {
    padding: 34px;
  }

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

  .result-content {
    padding: 52px 40px 40px;
  }

  .recipe-card {
    padding: 38px;
  }

  .recipe-columns {
    grid-template-columns: 0.85fr 1.15fr;
    margin-top: 32px;
    gap: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
