:root {
  --paper: #f6f1e8;
  --card: #fffdf8;
  --ink: #1f1a14;
  --muted: #8b7f6d;
  --line: #e3d9c9;
  --accent: #c0472d;
  --accent-soft: #f4e3db;
  --gold: #bd8a2e;
  --radius: 18px;
  --font-display: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, "SimSun", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #fffdf7 0%, rgba(255, 253, 247, 0) 60%),
    radial-gradient(900px 500px at 90% 110%, #f1eadc 0%, rgba(241, 234, 220, 0) 55%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 38px 22px 30px;
}
@media (min-width: 760px) {
  .app { max-width: 680px; padding-top: 60px; }
}

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
@media (min-width: 760px) {
  .top h1 { font-size: 31px; }
}
.pool {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- mode switch ---------- */
.modes {
  display: flex;
  gap: 26px;
  margin: 20px 0 24px;
  border-bottom: 1px solid var(--line);
}
.mode {
  appearance: none;
  background: none;
  border: 0;
  padding: 0 0 11px;
  margin-bottom: -1px;
  font: inherit;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.mode:hover { color: var(--ink); }
.mode.is-on {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------- chips ---------- */
.chips {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  margin: 0 -2px 20px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  appearance: none;
  font: inherit;
  font-size: 13.5px;
  line-height: 1;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
  white-space: nowrap;
}
.chip:hover { border-color: var(--ink); }
.chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* ingredient group tabs */
.chips.tabs {
  gap: 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}
.tab {
  flex: 0 0 auto;
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 2px 1px 9px;
  font: inherit;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-on {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.chips.chips-ing {
  flex-wrap: wrap;
  overflow: visible;
  gap: 8px;
  padding-bottom: 2px;
  margin-bottom: 14px;
}
.chips.chips-ing .chip { padding: 8px 13px; font-size: 13px; }
.chips.chips-ing .chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff7f2;
}
.chip.is-ghost {
  border-style: dashed;
  color: var(--muted);
  cursor: default;
  pointer-events: none;
}

/* ---------- wheel ---------- */
.stage {
  position: relative;
  width: min(84vw, 352px);
  aspect-ratio: 1 / 1;
  margin: 6px auto 0;
}
@media (min-width: 760px) {
  .stage { width: 380px; }
}
#wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow:
    0 26px 50px -28px rgba(58, 40, 25, 0.55),
    0 2px 0 rgba(255, 255, 255, 0.8) inset,
    0 0 0 1px rgba(227, 217, 201, 0.85);
  will-change: transform;
  transition: transform 3.9s cubic-bezier(0.1, 0.72, 0.12, 1);
  background: var(--card);
}
.mark {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 18px solid var(--ink);
  filter: drop-shadow(0 3px 3px rgba(31, 26, 20, 0.28));
  pointer-events: none;
  z-index: 3;
}
.hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  cursor: pointer;
  z-index: 2;
  box-shadow:
    0 8px 22px -10px rgba(58, 40, 25, 0.5),
    0 0 0 6px rgba(255, 253, 248, 0.55);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.hub:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff7f2;
}
.hub:active:not(:disabled) { transform: translate(-50%, -50%) scale(0.97); }
.hub:disabled { cursor: default; color: var(--muted); }

/* ---------- ingredient helpers ---------- */
.field { margin-bottom: 14px; }
.field input {
  width: 100%;
  appearance: none;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 2px;
  outline: none;
}
.field input::placeholder { color: var(--muted); }
.field input:focus { border-bottom-color: var(--ink); }

.picked {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 2px 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.picked .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: #8f3520;
  border-radius: 999px;
  padding: 6px 10px 6px 12px;
  font-size: 13px;
}
.picked .tag button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  color: #b06a56;
  cursor: pointer;
}
.picked .count { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- result ---------- */
.result { margin-top: 34px; }
.dish {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  animation: rise 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #efe6d7, #e6dac6);
  overflow: hidden;
}
.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.01);
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(31, 26, 20, 0) 62%, rgba(31, 26, 20, 0.16) 100%);
  pointer-events: none;
}

.dish-body { padding: 22px 22px 20px; }
@media (min-width: 760px) {
  .dish-body { padding: 26px 26px 22px; }
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.meta .cat {
  color: var(--accent);
  border: 1px solid #e8cfc5;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
}
.meta .stars { letter-spacing: 0.18em; color: var(--gold); }

.dish h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.32;
}
@media (min-width: 760px) {
  .dish h2 { font-size: 31px; }
}

.dish h3 {
  margin: 26px 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-indent: 0.2em;
}

.ing {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  column-gap: 22px;
}
.ing li {
  font-size: 14px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  color: #3a3229;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: s;
}
.steps li {
  counter-increment: s;
  position: relative;
  padding: 0 0 13px 30px;
  font-size: 14.5px;
  line-height: 1.72;
  color: #2b241c;
}
.steps li::before {
  content: counter(s, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--accent);
}

.tips {
  margin: 0;
  padding: 0;
  list-style: none;
}
.tips li {
  position: relative;
  padding: 0 0 9px 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--muted);
}
.tips li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  width: 6px;
  height: 1px;
  background: var(--muted);
}

.again {
  width: 100%;
  margin-top: 24px;
  appearance: none;
  font: inherit;
  font-size: 14.5px;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  padding: 13px 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.again:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- footer / toast ---------- */
.foot {
  margin: 44px 0 4px;
  text-align: center;
  font-size: 12px;
}
.foot a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.foot a:hover { color: var(--ink); border-bottom-color: var(--line); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--paper);
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 9;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  #wheel { transition-duration: 0.6s; }
  .dish, .toast { animation: none; transition: none; }
}
