:root {
  --chalk: #194f45;
  --chalk-deep: #103e37;
  --leaf: #356e57;
  --leaf-light: #6f9e72;
  --cream: #fff9e9;
  --paper: #fffdf7;
  --sun: #f8c63f;
  --sun-deep: #e7a81f;
  --coral: #c9503f;
  --ink: #193d38;
  --muted: #5d7168;
  --line: #e5ddc9;
  --shadow: 0 18px 46px rgba(24, 66, 55, .12);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 16%, rgba(248, 198, 63, .23), transparent 28%),
    radial-gradient(circle at 92% 74%, rgba(111, 158, 114, .18), transparent 31%),
    var(--cream);
  font-family: 'Nunito', 'Noto Sans SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
}

button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 3px solid rgba(248, 198, 63, .48); outline-offset: 3px; }

.hero {
  position: relative;
  overflow: hidden;
  color: var(--paper);
  background: linear-gradient(120deg, var(--chalk-deep), var(--chalk) 56%, #39745a);
}

.hero::before, .hero::after {
  position: absolute;
  content: '';
  border: 1px solid rgba(255, 249, 233, .2);
  border-radius: 50%;
}
.hero::before { width: 360px; height: 360px; top: -244px; right: 7%; }
.hero::after { width: 220px; height: 220px; right: 22%; bottom: -166px; }

.hero-inner {
  width: min(1380px, calc(100% - 52px));
  min-height: 176px;
  margin: 0 auto;
  padding: 54px 0 29px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  position: relative;
  z-index: 1;
}

.back-link {
  position: absolute;
  top: 13px;
  left: 0;
  padding: 7px 12px;
  border: 1px solid rgba(255, 249, 233, .68);
  border-radius: 999px;
  background: rgba(255, 253, 247, .1);
  color: var(--paper);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: transform .18s ease, background .18s ease;
}
.back-link:hover { background: rgba(255, 253, 247, .21); transform: translateX(-2px); }

.brand { display: flex; align-items: center; gap: 16px; }
.brand-icon {
  width: 65px;
  height: 65px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 249, 233, .35);
  border-radius: 19px;
  background: rgba(255, 253, 247, .14);
  font-size: 34px;
}
.brand h1 { margin: 0 0 4px; font-family: 'DM Serif Display', 'Noto Sans SC', serif; font-size: clamp(31px, 3vw, 42px); font-weight: 400; line-height: 1; }
.brand p { margin: 0; color: rgba(255, 253, 247, .84); font-size: 16px; }
.hero-note { padding: 11px 15px; border: 1px solid rgba(255, 249, 233, .26); border-radius: 999px; background: rgba(255, 253, 247, .1); color: #ffe49a; font-size: 13px; font-weight: 800; }

.workspace { width: min(1380px, calc(100% - 52px)); margin: -22px auto 0; padding-bottom: 42px; position: relative; z-index: 2; }
.card { border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }

.intro {
  padding: 22px 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}
.eyebrow { margin: 0 0 5px; color: var(--leaf); font-size: 12px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
h2 { margin: 0; font-family: 'DM Serif Display', 'Noto Sans SC', serif; font-size: 25px; font-weight: 400; line-height: 1.16; }
.intro p:not(.eyebrow) { max-width: 765px; margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.limits { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.limits span { padding: 7px 10px; border: 1px solid #d5e1c5; border-radius: 999px; background: #edf5df; color: var(--leaf); font-size: 12px; font-weight: 800; white-space: nowrap; }

.layout { margin-top: 19px; display: grid; grid-template-columns: minmax(320px, 386px) minmax(0, 1fr); gap: 20px; align-items: start; }
.editor { padding: 23px; }
.editor-heading, .stage-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.wheel-count { padding: 7px 10px; border-radius: 999px; background: #fff2c6; color: #7e5112; font-size: 12px; font-weight: 900; white-space: nowrap; }

.wheel-editors { margin-top: 17px; display: grid; gap: 14px; }
.wheel-editor { padding: 14px; border: 1px solid #d8e5c7; border-radius: 15px; background: #fffef9; }
.wheel-editor-heading { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wheel-editor-heading label { color: var(--chalk); font-size: 14px; font-weight: 900; }
.item-count { color: var(--leaf); font-size: 11px; font-weight: 900; }
.item-count.warning { color: var(--coral); }
.wheel-input { width: 100%; min-height: 144px; padding: 10px 11px; resize: vertical; border: 1px solid #d7dfcf; border-radius: 11px; background: #fffdf7; color: var(--ink); font-size: 14px; line-height: 1.55; }
.wheel-input:focus { border-color: var(--sun-deep); box-shadow: 0 0 0 3px rgba(248, 198, 63, .18); }
.input-help { min-height: 18px; margin: 7px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.input-help.warning { color: var(--coral); font-weight: 800; }

.wheel-controls { margin-top: 17px; padding-top: 17px; border-top: 1px dashed #cbdac2; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.btn { min-height: 42px; padding: 9px 13px; border: 1px solid transparent; border-radius: 12px; font-size: 13px; font-weight: 900; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { cursor: not-allowed; opacity: .48; }
.btn-primary { background: var(--coral); box-shadow: 0 5px 0 #9d392f; color: white; }
.btn-primary:hover:not(:disabled) { background: #d75d49; box-shadow: 0 7px 0 #9d392f; }
.btn-secondary { border-color: #d8e5c7; background: #fffef9; color: var(--chalk); }
.btn-secondary:hover:not(:disabled) { border-color: var(--sun-deep); background: #fff2c6; }
.control-help { grid-column: 1 / -1; min-height: 18px; margin: 0 1px; color: var(--muted); font-size: 11px; line-height: 1.35; }

.stage { min-height: 720px; padding: 23px; }
.stage-heading { align-items: center; }
.btn-all { background: var(--chalk); box-shadow: 0 5px 0 #103e37; color: white; white-space: nowrap; }
.btn-all:hover:not(:disabled) { background: #286451; box-shadow: 0 7px 0 #103e37; }
.wheel-stage { min-height: 620px; margin-top: 17px; display: grid; gap: 14px; align-items: stretch; }
.wheel-stage[data-wheels='1'] { grid-template-columns: minmax(0, 1fr); }
.wheel-stage[data-wheels='2'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wheel-stage[data-wheels='3'], .wheel-stage[data-wheels='4'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.wheel-card { min-width: 0; padding: 14px; display: flex; flex-direction: column; border: 1px solid #e5ddc9; border-radius: 17px; background: linear-gradient(145deg, #fffef9, #fff9e9); }
.wheel-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wheel-card h3 { margin: 0; color: var(--chalk); font-family: 'DM Serif Display', 'Noto Sans SC', serif; font-size: 20px; font-weight: 400; }
.spin-button { min-height: 35px; padding: 6px 11px; border: 1px solid #d3dfc1; border-radius: 999px; background: #edf5df; color: var(--chalk); font-size: 12px; font-weight: 900; transition: transform .18s ease, background .18s ease; }
.spin-button:hover:not(:disabled) { background: #fff2c6; transform: rotate(-3deg) scale(1.04); }
.spin-button:disabled { cursor: not-allowed; opacity: .5; }

.sunflower-garden { min-height: 0; flex: 1; display: grid; place-items: center; position: relative; overflow: hidden; }
.leaves::before, .leaves::after { position: absolute; z-index: 0; content: ''; width: 115px; height: 52px; border-radius: 100% 0 100% 0; background: #8eaf76; opacity: .45; }
.leaves::before { bottom: 12%; left: 8%; transform: rotate(-24deg); }
.leaves::after { top: 19%; right: 6%; transform: rotate(137deg); }
.sunflower-spinner { width: min(100%, 470px); aspect-ratio: 1; position: relative; z-index: 1; padding: 17px; }
.sunflower-wheel { width: 100%; height: 100%; display: block; filter: drop-shadow(0 11px 12px rgba(107, 73, 23, .18)); transform: rotate(var(--rotation)); transition: transform 4.4s cubic-bezier(.14,.74,.14,1); transform-origin: center; }
.pointer { position: absolute; z-index: 2; top: 2px; left: 50%; width: 0; height: 0; transform: translateX(-50%); border-top: 18px solid var(--coral); border-right: 12px solid transparent; border-left: 12px solid transparent; filter: drop-shadow(0 3px 1px rgba(88, 43, 35, .22)); }
.petal-text { paint-order: stroke; stroke: rgba(255, 253, 247, .45); stroke-width: .35px; }
.result { min-height: 46px; padding: 10px 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #d7c89c; border-radius: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.result.has-winner { border-style: solid; border-color: #e4be4a; background: #fff5cd; color: #77541a; }
.result span { font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.result strong { max-width: 100%; overflow: hidden; color: var(--chalk); font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.wheel-placeholder { min-height: 250px; padding: 30px; display: grid; place-content: center; gap: 8px; color: var(--muted); text-align: center; }
.wheel-placeholder span { font-size: 50px; }
.wheel-placeholder strong { color: var(--chalk); font-size: 14px; }
.wheel-placeholder small { font-size: 12px; }

.toast { max-width: calc(100% - 32px); padding: 11px 16px; position: fixed; z-index: 10; bottom: 22px; left: 50%; transform: translate(-50%, 22px); border-radius: 999px; background: var(--chalk); box-shadow: 0 12px 30px rgba(16, 62, 55, .28); color: white; font-size: 13px; font-weight: 800; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.petal-decision-modal[hidden] { display: none; }
.petal-decision-modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 22px; }
.petal-decision-backdrop { position: absolute; inset: 0; background: rgba(16, 62, 55, .48); backdrop-filter: blur(4px); }
.petal-decision-dialog { width: min(100%, 420px); padding: 29px; position: relative; z-index: 1; border: 1px solid #e4be4a; border-radius: 23px; background: var(--paper); box-shadow: 0 24px 58px rgba(16, 62, 55, .34); text-align: center; }
.decision-sunflower { width: 58px; height: 58px; margin: -55px auto 10px; display: grid; place-items: center; border: 5px solid var(--paper); border-radius: 50%; background: #fff2c6; font-size: 36px; box-shadow: 0 7px 16px rgba(107, 73, 23, .14); }
.petal-decision-dialog h2 { font-size: 28px; }
.decision-message { margin: 11px 0 5px; color: var(--chalk); font-size: 16px; font-weight: 900; line-height: 1.45; overflow-wrap: anywhere; }
.decision-note { min-height: 19px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.decision-actions { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
body.decision-open { overflow: hidden; }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 1fr; }
  .stage { min-height: 0; }
  .wheel-stage { min-height: 580px; }
  .wheel-stage[data-wheels='1'] { max-width: 690px; margin-inline: auto; }
}

@media (max-width: 720px) {
  .hero-inner, .workspace { width: calc(100% - 28px); }
  .hero-inner { min-height: 153px; padding-top: 48px; }
  .hero-note { display: none; }
  .intro { align-items: flex-start; flex-direction: column; }
  .limits { justify-content: flex-start; }
  .wheel-stage[data-wheels='2'], .wheel-stage[data-wheels='3'], .wheel-stage[data-wheels='4'] { grid-template-columns: 1fr; }
  .wheel-stage { min-height: 0; }
  .sunflower-garden { min-height: 330px; }
}

@media (max-width: 480px) {
  .hero-inner, .workspace { width: calc(100% - 20px); }
  .hero-inner { min-height: 146px; padding-bottom: 23px; }
  .brand-icon { width: 52px; height: 52px; border-radius: 16px; font-size: 29px; }
  .brand h1 { font-size: 29px; }
  .brand p { font-size: 13px; }
  .editor, .stage { padding: 17px 14px; border-radius: 18px; }
  .intro { padding: 18px; border-radius: 18px; }
  .wheel-controls { grid-template-columns: 1fr; }
  .sunflower-garden { min-height: 295px; }
  .sunflower-spinner { max-width: 350px; }
  .petal-decision-dialog { padding: 26px 19px; }
  .decision-actions { grid-template-columns: 1fr; }
}
