:root {
  color-scheme: light;
  --ink: #123f35;
  --ink-deep: #082d27;
  --vermilion: #c8422f;
  --mustard: #d9a321;
  --rice: #f6edd7;
  --paper: #fffaf0;
  --blue: #2d6f88;
  --muted: #6d705f;
  --line: #174f43;
  --border: 2px solid var(--ink);
  --font-display: "Arial Black", "Microsoft YaHei", sans-serif;
  --font-body: "Noto Sans CJK SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  background-color: var(--rice);
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: clip;
  color: var(--ink-deep);
  background-color: var(--rice);
  background-image:
    linear-gradient(rgb(18 63 53 / 16%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(18 63 53 / 16%) 1px, transparent 1px);
  background-size: 18px 18px;
  font-family: var(--font-body);
  line-height: 1.45;
}

button,
select,
input {
  min-height: 44px;
  color: inherit;
  border: var(--border);
  border-radius: 4px;
  background: var(--paper);
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 4px solid var(--mustard);
  outline-offset: 3px;
}

button:active {
  translate: 2px 2px;
}

svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  grid-template-rows: auto auto 1fr auto;
}

.topbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  gap: 24px;
  min-height: 76px;
  padding: 12px clamp(16px, 3vw, 44px);
  color: var(--rice);
  border-bottom: 3px solid var(--ink-deep);
  background: var(--ink);
  box-shadow: 0 6px 0 var(--mustard);
}

.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  aspect-ratio: 1;
  place-items: center;
  color: var(--rice);
  border: 2px solid var(--rice);
  background: var(--vermilion);
  box-shadow: 3px 3px 0 var(--mustard);
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.65rem);
  line-height: 1;
}

.mode-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(104px, 1fr));
  padding: 4px;
  margin: 0;
  border: 2px solid var(--rice);
  border-radius: 6px;
  background: var(--ink-deep);
}

.mode-control label {
  position: relative;
  cursor: pointer;
}

.mode-control input {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  opacity: 0;
}

.mode-control span {
  display: grid;
  min-height: 40px;
  padding: 0 14px;
  place-items: center;
  color: var(--rice);
  border: 2px solid transparent;
  border-radius: 3px;
  font-weight: 800;
  white-space: nowrap;
}

.mode-control input:checked + span {
  color: var(--ink-deep);
  border-color: var(--ink-deep);
  background: var(--mustard);
  box-shadow: 2px 2px 0 var(--vermilion);
}

.mode-control input:focus-visible + span {
  outline: 3px solid var(--paper);
  outline-offset: 1px;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  min-width: 44px;
  padding: 0;
  place-items: center;
  color: var(--ink-deep);
  border-color: var(--rice);
  background: var(--mustard);
  box-shadow: 3px 3px 0 var(--vermilion);
}

.ink-button {
  color: var(--rice);
  border-color: var(--ink-deep);
  background: var(--ink);
  box-shadow: 3px 3px 0 var(--mustard);
}

.quick-filters {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 240px));
  justify-content: center;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 56px) 14px;
  border-bottom: var(--border);
  background: var(--paper);
}

.menu-tag {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  border: var(--border);
  border-radius: 4px;
  background: var(--rice);
  box-shadow: 4px 4px 0 var(--vermilion);
  font-weight: 800;
}

.menu-tag > span {
  align-self: stretch;
  display: grid;
  padding: 0 12px;
  place-items: center;
  color: var(--rice);
  background: var(--ink);
}

.menu-tag select {
  width: 100%;
  min-width: 0;
  padding: 0 36px 0 12px;
  border: 0;
  background-color: transparent;
  font-weight: 800;
}

.main-stage {
  display: grid;
  width: min(100%, 1440px);
  min-width: 0;
  padding: clamp(24px, 3vw, 46px) clamp(16px, 3vw, 44px);
  margin: 0 auto;
  grid-template-areas: "path wheel candidates";
  grid-template-columns: minmax(156px, 210px) minmax(400px, 720px) minmax(240px, 300px);
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 3vw, 48px);
}

.path-rail {
  grid-area: path;
  align-self: stretch;
  padding: 22px 0;
  border-left: 4px solid var(--ink);
}

.rail-label {
  width: fit-content;
  padding: 4px 10px;
  margin: 0 0 24px -4px;
  color: var(--rice);
  background: var(--ink);
  font-family: var(--font-display);
  font-size: 0.78rem;
}

.path-rail ol {
  display: grid;
  gap: 20px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.path-rail li {
  position: relative;
  padding-left: 22px;
}

.path-rail li::before {
  position: absolute;
  top: 17px;
  left: -9px;
  width: 14px;
  height: 14px;
  content: "";
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--rice);
}

.path-rail li.is-current::before {
  background: var(--vermilion);
}

.path-rail button,
.path-rail li > span {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  text-align: left;
  font-weight: 800;
}

.path-rail button {
  border-color: var(--ink);
  background: var(--mustard);
  box-shadow: 4px 4px 0 var(--vermilion);
}

.path-rail button span,
.path-rail li b {
  font-family: var(--font-display);
  font-size: 0.75rem;
}

.path-rail .is-pending {
  color: var(--muted);
}

.wheel-stage {
  display: grid;
  min-width: 0;
  grid-area: wheel;
  justify-items: center;
}

.stage-heading {
  position: relative;
  z-index: 2;
  padding: 6px 18px 8px;
  margin-bottom: -12px;
  color: var(--rice);
  border: var(--border);
  background: var(--ink);
  box-shadow: 5px 5px 0 var(--vermilion);
  text-align: center;
}

.stage-heading p,
.stage-heading h2 {
  margin: 0;
}

.stage-heading p {
  color: var(--mustard);
  font-family: var(--font-display);
  font-size: 0.7rem;
}

.stage-heading h2 {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.4vw, 1.4rem);
}

.wheel-wrap {
  position: relative;
  display: grid;
  width: min(100%, 720px);
  aspect-ratio: 1;
  place-items: center;
  border: 12px solid var(--paper);
  border-radius: 50%;
  background: var(--paper);
  box-shadow:
    0 0 0 4px var(--ink),
    10px 10px 0 var(--mustard),
    14px 14px 0 var(--vermilion);
}

#wheel {
  display: block;
  width: 100%;
  height: 100%;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background:
    repeating-conic-gradient(
      from -15deg,
      var(--vermilion) 0deg 29deg,
      var(--mustard) 29deg 59deg,
      var(--blue) 59deg 89deg,
      var(--paper) 89deg 119deg
    );
}

.wheel-wrap::after {
  position: absolute;
  inset: 7%;
  content: "";
  pointer-events: none;
  border: 2px dashed var(--ink-deep);
  border-radius: 50%;
}

.chopstick-pointer {
  position: absolute;
  z-index: 4;
  top: -18px;
  left: 50%;
  width: 38px;
  height: 72px;
  translate: -50% 0;
  filter: drop-shadow(4px 4px 0 var(--mustard));
}

.chopstick-pointer span {
  position: absolute;
  top: 0;
  width: 10px;
  height: 64px;
  border: 2px solid var(--ink-deep);
  border-radius: 2px 2px 8px 8px;
  background: var(--vermilion);
  transform-origin: top;
}

.chopstick-pointer span:first-child {
  left: 8px;
  rotate: -8deg;
}

.chopstick-pointer span:last-child {
  right: 8px;
  rotate: 8deg;
}

.spin-button {
  position: absolute;
  z-index: 5;
  display: grid;
  width: clamp(94px, 20%, 138px);
  min-height: 0;
  aspect-ratio: 1;
  padding: 12px;
  place-content: center;
  color: var(--rice);
  border: 5px double var(--rice);
  border-radius: 50%;
  background: var(--ink);
  box-shadow:
    0 0 0 4px var(--ink-deep),
    6px 6px 0 var(--mustard);
  font-family: var(--font-display);
}

.spin-button span {
  font-size: clamp(1.2rem, 3vw, 2rem);
  line-height: 1;
}

.spin-button small {
  margin-top: 4px;
  color: var(--mustard);
  font-size: 0.65rem;
}

.wheel-feedback {
  position: relative;
  z-index: 2;
  min-width: 150px;
  padding: 5px 14px;
  margin: -7px 0 0;
  color: var(--rice);
  border: var(--border);
  background: var(--vermilion);
  font-weight: 800;
  text-align: center;
}

.candidate-ticket {
  position: relative;
  grid-area: candidates;
  align-self: center;
  min-width: 0;
  padding: 20px;
  border: var(--border);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--mustard);
}

.candidate-ticket::before,
.candidate-ticket::after {
  position: absolute;
  left: 0;
  width: 100%;
  height: 6px;
  content: "";
  background: repeating-linear-gradient(90deg, var(--ink) 0 8px, transparent 8px 14px);
}

.candidate-ticket::before {
  top: 0;
}

.candidate-ticket::after {
  bottom: 0;
}

.candidate-ticket header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 2px dashed var(--ink);
}

.candidate-ticket header p,
.candidate-ticket h2 {
  margin: 0;
}

.candidate-ticket header p {
  color: var(--vermilion);
  font-family: var(--font-display);
  font-size: 0.68rem;
}

.candidate-ticket h2 {
  font-family: var(--font-display);
  font-size: 1.08rem;
}

.ticket-stamp {
  display: grid;
  width: 42px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  place-items: center;
  color: var(--vermilion);
  border: 3px double var(--vermilion);
  border-radius: 50%;
  font-family: var(--font-display);
  rotate: 8deg;
}

.candidate-ticket ol {
  display: grid;
  gap: 0;
  padding: 8px 0;
  margin: 0;
  list-style: none;
}

.candidate-ticket li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 0 8px;
  padding: 9px 0;
  border-bottom: 1px dashed rgb(18 63 53 / 45%);
}

.candidate-ticket li > span {
  grid-row: span 2;
  color: var(--vermilion);
  font-family: var(--font-display);
  font-size: 0.75rem;
}

.candidate-ticket li b,
.candidate-ticket li small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.candidate-ticket li small {
  color: var(--muted);
}

.ticket-action,
.button-primary,
.button-secondary,
.button-quiet {
  min-width: 0;
  padding: 8px 14px;
  font-weight: 900;
}

.ticket-action {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--rice);
  background: var(--ink);
  box-shadow: 4px 4px 0 var(--vermilion);
}

.status-strip {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 5vw, 72px);
  padding: 8px 20px;
  color: var(--rice);
  border-top: 3px solid var(--ink-deep);
  background: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.status-strip p {
  margin: 0;
}

.status-strip p:first-child span {
  color: var(--vermilion);
}

.status-strip p:nth-child(2) span {
  color: var(--mustard);
}

dialog {
  color: var(--ink-deep);
  border: var(--border);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 10px 10px 0 var(--mustard);
}

dialog::backdrop {
  background: rgb(8 45 39 / 72%);
}

.result-ticket {
  width: min(88vw, 500px, calc(92dvh - 250px));
  max-height: 92vh;
  max-height: 92dvh;
  padding: clamp(10px, 1.8dvh, 16px);
  overflow: hidden;
}

.ticket-topline,
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ticket-topline {
  padding-bottom: clamp(8px, 1.4dvh, 12px);
  border-bottom: 2px dashed var(--ink);
}

.ticket-topline p,
.drawer-header p {
  margin: 0;
  color: var(--vermilion);
  font-family: var(--font-display);
  font-size: 0.72rem;
}

.result-ticket .icon-button {
  width: clamp(38px, 5.5dvh, 44px);
  min-width: clamp(38px, 5.5dvh, 44px);
  min-height: clamp(38px, 5.5dvh, 44px);
}

.result-ticket .icon-button svg {
  width: clamp(1rem, 2.4dvh, 1.25rem);
  height: clamp(1rem, 2.4dvh, 1.25rem);
}

.result-visual {
  position: relative;
  aspect-ratio: 1;
  margin: clamp(8px, 1.5dvh, 14px) 0;
  overflow: hidden;
  border: var(--border);
  background-color: var(--rice);
  background-image:
    linear-gradient(rgb(14 73 61 / 10%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(14 73 61 / 10%) 1px, transparent 1px);
  background-size: 18px 18px;
}

.result-visual img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  opacity: 1;
  transition: opacity 140ms ease-out;
}

.result-visual img.is-loading {
  opacity: 0;
}

.result-visual figcaption {
  position: absolute;
  right: clamp(5px, 1dvh, 8px);
  bottom: clamp(5px, 1dvh, 8px);
  max-width: calc(100% - 12px);
  padding: clamp(3px, 0.7dvh, 4px) clamp(6px, 1.2dvh, 8px);
  color: var(--rice);
  border: 2px solid var(--rice);
  background: var(--ink);
  font-size: clamp(0.68rem, 1.7dvh, 0.88rem);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.result-copy {
  text-align: center;
}

.result-copy > p,
.result-copy h2 {
  margin: 0;
}

.result-copy > p {
  margin-bottom: clamp(1px, 0.4dvh, 3px);
  color: var(--vermilion);
  font-family: var(--font-display);
  font-size: clamp(0.62rem, 1.5dvh, 0.72rem);
}

.result-copy h2 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5.2dvh, 2.7rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.result-copy h2:focus {
  outline: 0;
}

.result-copy ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(5px, 1dvh, 8px);
  padding: 0;
  margin: clamp(6px, 1.1dvh, 10px) 0 clamp(8px, 1.5dvh, 14px);
  list-style: none;
}

.result-copy li {
  padding: clamp(2px, 0.6dvh, 4px) clamp(6px, 1.1dvh, 9px);
  border: 1px solid var(--ink);
  background: var(--rice);
  font-size: clamp(0.68rem, 1.6dvh, 0.8rem);
  font-weight: 800;
}

.result-actions {
  display: grid;
  gap: clamp(6px, 1.2dvh, 10px);
}

#food-result-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#cuisine-result-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-actions button {
  min-height: clamp(38px, 5.5dvh, 44px);
  padding: 5px clamp(5px, 1.2dvh, 10px);
  font-size: clamp(0.7rem, 1.8dvh, 0.88rem);
  line-height: 1.15;
  white-space: nowrap;
}

.result-actions[hidden] {
  display: none;
}

.button-primary {
  color: var(--rice);
  background: var(--vermilion);
  box-shadow: 4px 4px 0 var(--mustard);
}

.button-secondary {
  color: var(--rice);
  background: var(--ink);
  box-shadow: 4px 4px 0 var(--mustard);
}

.button-quiet {
  background: var(--paper);
}

.library-drawer {
  width: min(100%, 440px);
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  padding: 0;
  margin: 0 0 0 auto;
  border-block: 0;
  border-right: 0;
  box-shadow: -10px 0 0 var(--mustard);
}

.drawer-header {
  min-height: 84px;
  padding: 16px 20px;
  color: var(--rice);
  border-bottom: var(--border);
  background: var(--ink);
}

.drawer-header h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.library-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: var(--border);
}

.library-tabs button {
  min-width: 0;
  padding: 6px 4px;
  border: 0;
  border-right: 1px solid var(--ink);
  border-radius: 0;
  background: var(--rice);
  font-size: 0.82rem;
  font-weight: 900;
}

.library-tabs button:last-child {
  border-right: 0;
}

.library-tabs button[aria-selected="true"] {
  color: var(--rice);
  background: var(--vermilion);
}

.drawer-content {
  height: calc(100dvh - 129px);
  padding: 20px;
  overflow-y: auto;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 2px dashed var(--ink);
}

.panel-heading h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
}

.panel-heading span {
  color: var(--vermilion);
  font-size: 0.78rem;
  font-weight: 900;
}

.library-list {
  padding: 0;
  margin: 10px 0 0;
  list-style: none;
}

.library-list li {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed rgb(18 63 53 / 45%);
}

.library-list li > span {
  display: grid;
  min-width: 0;
}

.library-list small {
  color: var(--muted);
}

.library-list button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  color: var(--vermilion);
  background: var(--rice);
  font-size: 1.35rem;
  font-weight: 900;
}

.empty-state {
  padding: 26px 16px;
  margin: 12px 0;
  border: 2px dashed var(--ink);
  color: var(--muted);
  background: var(--rice);
  text-align: center;
}

#custom-food-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-top: 16px;
}

#custom-food-form label {
  display: grid;
  gap: 5px;
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 900;
}

#custom-food-form label:first-child,
#custom-food-form .form-submit,
#custom-food-form .form-feedback {
  grid-column: 1 / -1;
}

#custom-food-form input,
#custom-food-form select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
}

#custom-food-form .select-control {
  min-height: 44px;
  border: var(--border);
  border-radius: 4px;
  background: var(--paper);
}

#custom-food-form .select-trigger {
  min-height: 40px;
}

.form-submit {
  width: 100%;
  margin-top: 4px;
}

.form-feedback {
  min-height: 1.5em;
  margin: 0;
  color: var(--vermilion);
  font-weight: 800;
}

@media (max-width: 68rem) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .mode-control {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-self: center;
  }

  .main-stage {
    grid-template-areas:
      "path wheel"
      "candidates wheel";
    grid-template-columns: minmax(220px, 280px) minmax(380px, 680px);
    align-items: start;
  }

  .path-rail {
    align-self: auto;
  }

  .candidate-ticket {
    align-self: start;
  }
}

@media (max-width: 48rem) {
  .topbar {
    gap: 12px;
    padding: 10px 14px 16px;
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  .brand-mark {
    width: 40px;
  }

  .mode-control {
    width: min(100%, 360px);
  }

  .quick-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 16px 12px 12px;
  }

  .menu-tag {
    grid-template-columns: 1fr;
  }

  .menu-tag > span {
    min-height: 30px;
    padding: 3px 6px;
    font-size: 0.72rem;
  }

  .menu-tag select {
    padding-inline: 8px 20px;
    font-size: 0.8rem;
  }

  .main-stage {
    grid-template-areas:
      "path"
      "wheel"
      "candidates";
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding: 24px 14px 34px;
  }

  .path-rail {
    padding: 0;
    border: 0;
  }

  .rail-label {
    margin: 0 0 8px;
  }

  .path-rail ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .path-rail li {
    min-width: 0;
    padding: 0;
  }

  .path-rail li::before {
    display: none;
  }

  .path-rail button,
  .path-rail li > span {
    min-height: 48px;
    padding: 5px 7px;
    justify-content: center;
    overflow-wrap: anywhere;
    text-align: center;
  }

  .path-rail li > span {
    display: grid;
    border: 1px dashed var(--ink);
    font-size: 0.72rem;
  }

  .wheel-wrap {
    border-width: 8px;
    box-shadow:
      0 0 0 3px var(--ink),
      6px 6px 0 var(--mustard),
      9px 9px 0 var(--vermilion);
  }

  .candidate-ticket {
    width: min(100%, 520px);
    justify-self: center;
  }

  .status-strip {
    flex-wrap: wrap;
    gap: 4px 18px;
    padding-block: 9px;
  }

  .status-strip p:last-child {
    width: 100%;
    text-align: center;
  }

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

  .library-drawer {
    width: 100%;
    height: min(86vh, 760px);
    height: min(86dvh, 760px);
    margin: auto 0 0;
    border: var(--border);
    border-bottom: 0;
    box-shadow: 0 -8px 0 var(--mustard);
  }

  .drawer-content {
    height: calc(min(86dvh, 760px) - 129px);
  }
}

@media (max-width: 30rem) {
  .topbar-actions {
    gap: 6px;
  }

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

  .mode-control span {
    padding-inline: 6px;
    font-size: 0.84rem;
  }

  .quick-filters {
    grid-template-columns: 1fr;
  }

  .menu-tag {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .result-ticket {
    width: calc(100vw - 20px);
    padding: 12px;
  }

  #custom-food-form {
    grid-template-columns: 1fr;
  }

  #custom-food-form label,
  #custom-food-form label:first-child,
  #custom-food-form .form-submit,
  #custom-food-form .form-feedback {
    grid-column: 1;
  }
}

@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;
  }
}

/* One-screen application layout and refined interaction states */
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 0;
}

.app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: 64px 62px minmax(0, 1fr) 36px;
}

.topbar {
  min-height: 0;
  padding-block: 8px;
}

.brand-mark {
  width: 40px;
}

.mode-control span {
  min-height: 36px;
}

.topbar-actions {
  gap: 8px;
}

.tool-button {
  display: inline-grid;
  min-width: 72px;
  min-height: 44px;
  padding: 4px 9px;
  grid-template-columns: 20px auto;
  align-items: center;
  gap: 6px;
  color: var(--ink-deep);
  border-color: var(--rice);
  background: var(--mustard);
  box-shadow: 3px 3px 0 var(--vermilion);
  font-size: 0.75rem;
  font-weight: 900;
}

.tool-button svg {
  width: 20px;
  height: 20px;
}

.tool-button .sound-off-icon {
  display: none;
}

.tool-button[data-enabled="false"] {
  color: var(--rice);
  background: var(--ink-deep);
  box-shadow: 3px 3px 0 var(--muted);
}

.tool-button[data-enabled="false"] .sound-on-icon {
  display: none;
}

.tool-button[data-enabled="false"] .sound-off-icon {
  display: block;
}

.tool-button[aria-expanded="true"] {
  color: var(--rice);
  background: var(--vermilion);
  box-shadow: 3px 3px 0 var(--mustard);
}

.quick-filters {
  align-items: center;
  gap: 14px;
  padding: 10px clamp(16px, 4vw, 56px) 8px;
}

.menu-tag {
  position: relative;
  min-height: 44px;
}

.menu-tag > span {
  min-height: 40px;
}

.native-select {
  display: none;
  position: absolute;
  width: 1px !important;
  height: 1px;
  min-height: 0;
  padding: 0 !important;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0 !important;
}

.select-control {
  position: relative;
  min-width: 0;
  align-self: stretch;
}

.select-trigger {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 900;
  text-align: left;
}

.select-trigger[aria-expanded="true"] {
  color: var(--rice);
  background: var(--vermilion);
}

.select-chevron {
  font-size: 1rem;
  line-height: 1;
  transition: rotate 160ms ease;
}

.select-trigger[aria-expanded="true"] .select-chevron {
  rotate: 180deg;
}

.select-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 7px);
  right: -2px;
  left: -2px;
  max-height: min(280px, 44dvh);
  padding: 5px;
  overflow-y: auto;
  border: var(--border);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--mustard);
}

.select-popover[role="listbox"] {
  overscroll-behavior: contain;
}

.select-popover[hidden] {
  display: none;
}

.select-popover [role="option"] {
  width: 100%;
  min-height: 38px;
  padding: 6px 9px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.select-popover [role="option"]:hover,
.select-popover [role="option"]:focus-visible {
  color: var(--rice);
  outline: 0;
  background: var(--ink);
}

.select-popover [role="option"][aria-selected="true"] {
  color: var(--ink-deep);
  background: var(--mustard);
}

.main-stage {
  width: min(100%, 1500px);
  height: 100%;
  min-height: 0;
  padding: 12px clamp(16px, 2.4vw, 38px);
  overflow: hidden;
  grid-template-columns: minmax(150px, 190px) minmax(360px, 1fr) minmax(240px, 288px);
  align-items: center;
  gap: clamp(18px, 2vw, 34px);
}

.path-rail {
  align-self: center;
  padding: 12px 0;
}

.rail-label {
  margin-bottom: 14px;
}

.path-rail ol {
  gap: 12px;
}

.path-rail button,
.path-rail li > span,
.path-current,
.path-selected {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  text-align: left;
  font-weight: 800;
}

.path-current {
  color: var(--rice);
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--vermilion);
}

.path-selected {
  color: var(--ink-deep);
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--mustard);
}

.path-back {
  color: var(--ink-deep);
  border: 2px dashed var(--ink);
  background: var(--paper);
  box-shadow: none;
}

.path-back::after {
  margin-left: auto;
  content: "↩";
  color: var(--vermilion);
}

.wheel-stage {
  height: 100%;
  min-height: 0;
  align-content: center;
}

.wheel-wrap {
  --wheel-size: min(100%, calc(100dvh - 280px), 620px);
  width: var(--wheel-size);
  height: var(--wheel-size);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  border-width: 8px;
  box-shadow:
    0 0 0 4px var(--ink),
    0 0 0 9px var(--paper),
    0 0 0 12px var(--ink);
}

.stage-heading {
  padding: 4px 16px 6px;
  margin-bottom: -8px;
}

.stage-heading h2 {
  font-size: 1.12rem;
}

.chopstick-pointer {
  top: -14px;
  height: 60px;
}

.chopstick-pointer span {
  height: 54px;
}

.wheel-feedback {
  min-width: 140px;
  padding-block: 3px;
  margin-top: -5px;
  font-size: 0.78rem;
}

.candidate-ticket {
  width: 100%;
  max-height: 100%;
  padding: 14px;
  overflow: hidden;
}

.candidate-ticket header {
  padding-bottom: 8px;
}

.candidate-ticket h2 {
  font-size: 1rem;
}

.ticket-stamp {
  width: 40px;
  font-size: 0.72rem;
  rotate: 5deg;
}

.candidate-ticket ol {
  padding: 5px 0;
}

.candidate-ticket li {
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 0 6px;
  padding: 4px 0;
  line-height: 1.22;
}

.candidate-ticket li b {
  font-size: 0.82rem;
}

.candidate-ticket li small {
  font-size: 0.68rem;
}

.candidate-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 8px;
}

.candidate-actions .ticket-action {
  min-height: 40px;
  padding: 5px 7px;
  box-shadow: 3px 3px 0 var(--vermilion);
  font-size: 0.76rem;
}

.candidate-actions .save-action {
  color: var(--ink-deep);
  background: var(--mustard);
  box-shadow: 3px 3px 0 var(--ink);
}

.status-strip {
  min-height: 0;
  padding: 4px 18px;
  font-size: 0.72rem;
}

.result-visual canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
}

@media (max-width: 68rem) {
  .app-shell {
    grid-template-rows: 64px 62px minmax(0, 1fr) 36px;
  }

  .topbar {
    grid-template-columns: minmax(190px, 1fr) auto minmax(160px, 1fr);
  }

  .mode-control {
    grid-row: auto;
    grid-column: auto;
  }

  .main-stage {
    grid-template-areas: "path wheel candidates";
    grid-template-columns: minmax(140px, 172px) minmax(320px, 1fr) minmax(220px, 260px);
    align-items: center;
    gap: 18px;
  }

  .wheel-wrap {
    --wheel-size: min(100%, calc(100dvh - 280px), 520px);
  }

  .candidate-ticket {
    align-self: center;
  }
}

@media (max-width: 48rem) {
  .app-shell {
    grid-template-rows: 108px 56px minmax(0, 1fr) 32px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
    padding: 8px 12px;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .brand-mark {
    width: 36px;
  }

  .mode-control {
    width: min(100%, 340px);
    grid-row: 2;
    grid-column: 1 / -1;
    justify-self: center;
  }

  .mode-control span {
    min-height: 34px;
    padding-inline: 8px;
    font-size: 0.82rem;
  }

  .tool-button {
    min-width: 64px;
    padding-inline: 7px;
  }

  .quick-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 6px 8px;
  }

  .menu-tag {
    grid-template-columns: 42px minmax(0, 1fr);
    min-height: 40px;
  }

  .menu-tag > span {
    min-height: 36px;
    padding: 2px 4px;
    font-size: 0.68rem;
  }

  .select-trigger {
    min-height: 36px;
    padding-inline: 7px 5px;
    font-size: 0.7rem;
  }

  .select-popover {
    right: -4px;
    left: -44px;
  }

  .main-stage {
    grid-template-areas:
      "path"
      "wheel"
      "candidates";
    grid-template-rows: 50px minmax(0, 1fr) auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: 6px 10px;
  }

  .path-rail {
    width: 100%;
    padding: 0;
    border: 0;
  }

  .rail-label {
    display: none;
  }

  .path-rail ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .path-rail li {
    min-width: 0;
    padding: 0;
  }

  .path-rail li::before {
    display: none;
  }

  .path-rail button,
  .path-rail li > span,
  .path-current,
  .path-selected {
    min-height: 44px;
    justify-content: center;
    padding: 3px 5px;
    overflow: hidden;
    font-size: 0.68rem;
    text-align: center;
  }

  .path-back::after {
    display: none;
  }

  .wheel-stage {
    align-content: center;
  }

  .wheel-wrap {
    --wheel-size: min(calc(100vw - 32px), calc(100dvh - 540px), 360px);
    min-width: 210px;
    min-height: 210px;
    border-width: 6px;
    box-shadow:
      0 0 0 3px var(--ink),
      0 0 0 6px var(--paper),
      0 0 0 8px var(--ink);
  }

  .stage-heading {
    padding: 2px 12px 4px;
  }

  .stage-heading p {
    font-size: 0.58rem;
  }

  .stage-heading h2 {
    font-size: 0.9rem;
  }

  .wheel-feedback {
    min-width: 120px;
    padding: 2px 10px;
    font-size: 0.68rem;
  }

  .candidate-ticket {
    width: 100%;
    padding: 8px 10px;
  }

  .candidate-ticket header {
    align-items: center;
    padding-bottom: 4px;
  }

  .candidate-ticket header p {
    font-size: 0.58rem;
  }

  .candidate-ticket h2 {
    font-size: 0.84rem;
  }

  .ticket-stamp {
    width: 32px;
    font-size: 0.58rem;
  }

  .candidate-ticket ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 6px;
    padding: 3px 0;
  }

  .candidate-ticket li {
    display: flex;
    min-width: 0;
    gap: 4px;
    padding: 2px 0;
    border-bottom: 1px dashed rgb(18 63 53 / 28%);
  }

  .candidate-ticket li > span {
    grid-row: auto;
    flex: 0 0 auto;
    font-size: 0.58rem;
  }

  .candidate-ticket li b {
    overflow: hidden;
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .candidate-ticket li small {
    display: none;
  }

  .candidate-actions .ticket-action {
    min-height: 34px;
    font-size: 0.68rem;
  }

  .status-strip {
    flex-wrap: nowrap;
    gap: 12px;
    padding: 3px 8px;
    overflow: hidden;
    white-space: nowrap;
  }

  .status-strip p:last-child {
    width: auto;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
  }

  .result-ticket {
    max-height: 94dvh;
  }

  .result-visual {
    margin-block: clamp(7px, 1.4dvh, 10px);
  }

  .result-copy ul {
    margin-bottom: clamp(7px, 1.4dvh, 10px);
  }

  .result-actions button {
    padding-inline: 4px;
  }

  .library-drawer {
    height: min(92dvh, 760px);
  }

  .drawer-content {
    height: calc(min(92dvh, 760px) - 129px);
  }
}

@media (max-width: 30rem) {
  .quick-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .menu-tag {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .topbar-actions {
    gap: 5px;
  }

  .tool-button {
    min-width: 60px;
    grid-template-columns: 18px auto;
    gap: 4px;
    padding-inline: 5px;
    font-size: 0.68rem;
  }
}

@media (max-height: 44rem) {
  .wheel-wrap {
    --wheel-size: min(100%, calc(100dvh - 274px), 430px);
  }

  .candidate-ticket li {
    padding-block: 2px;
  }
}

@media (max-width: 48rem) and (max-height: 44rem) {
  .wheel-wrap {
    --wheel-size: min(calc(100vw - 32px), calc(100dvh - 520px), 270px);
  }
}

/* China-market taxonomy and final interaction pass */
.app-shell {
  grid-template-rows: 64px 62px minmax(0, 1fr);
}

.wheel-stage {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.stage-heading {
  grid-row: 1;
}

.direction-control {
  z-index: 3;
  display: grid;
  width: min(100%, 260px);
  min-width: 0;
  padding: 3px;
  margin: 12px 0 4px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--mustard);
  grid-row: 2;
}

.direction-control[hidden] {
  display: none;
}

.direction-control label {
  position: relative;
  min-width: 0;
}

.direction-control input {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.direction-control span {
  display: grid;
  min-height: 36px;
  place-items: center;
  color: var(--ink-deep);
  border: 0;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
}

.direction-control input:checked + span {
  color: var(--rice);
  background: var(--vermilion);
}

.direction-control input:focus-visible + span {
  outline: 3px solid var(--mustard);
  outline-offset: 2px;
}

.mode-control input:disabled + span,
.direction-control input:disabled + span {
  cursor: not-allowed;
  opacity: 0.52;
}

.wheel-wrap {
  --wheel-size: min(100%, calc(100dvh - 320px), 590px);
  grid-row: 3;
}

.wheel-feedback {
  align-self: start;
  grid-row: 4;
}

.chopstick-pointer {
  top: -34px;
  width: 52px;
  height: 92px;
  filter: drop-shadow(4px 4px 0 var(--vermilion));
}

.chopstick-pointer span {
  top: 0;
  width: 14px;
  height: 86px;
  border: 3px solid var(--ink-deep);
  border-radius: 3px 3px 10px 10px;
  background:
    linear-gradient(
      to bottom,
      var(--vermilion) 0 18px,
      var(--rice) 18px 100%
    );
}

.chopstick-pointer span:first-child {
  left: 9px;
  rotate: -7deg;
}

.chopstick-pointer span:last-child {
  right: 9px;
  rotate: 7deg;
}

.cuisine-manager {
  padding: 12px;
  margin-bottom: 18px;
  border: 2px solid var(--ink);
  background: var(--rice);
  box-shadow: 4px 4px 0 var(--mustard);
}

.cuisine-manager .panel-heading {
  padding-bottom: 8px;
}

.cuisine-manager .panel-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.cuisine-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 10px;
}

.cuisine-toggle-grid label {
  position: relative;
  min-width: 0;
}

.cuisine-toggle-grid input {
  position: absolute;
  opacity: 0;
}

.cuisine-toggle-grid span {
  display: grid;
  min-height: 40px;
  padding: 5px 8px;
  place-items: center;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
  cursor: pointer;
}

.cuisine-toggle-grid input:checked + span {
  color: var(--rice);
  background: var(--ink);
  box-shadow: 3px 3px 0 var(--vermilion);
}

.cuisine-toggle-grid input:focus-visible + span {
  outline: 3px solid var(--mustard);
  outline-offset: 2px;
}

@media (max-width: 68rem) {
  .app-shell {
    grid-template-rows: 64px 62px minmax(0, 1fr);
  }

  .wheel-wrap {
    --wheel-size: min(100%, calc(100dvh - 320px), 490px);
  }
}

@media (max-width: 48rem) {
  .app-shell {
    grid-template-rows: 108px 56px minmax(0, 1fr);
  }

  .direction-control {
    position: absolute;
    top: 2px;
    right: 4px;
    width: 154px;
    margin: 0;
  }

  .direction-control span {
    min-height: 30px;
    font-size: 0.66rem;
  }

  .wheel-stage {
    position: relative;
  }

  .wheel-wrap {
    --wheel-size: min(calc(100vw - 32px), calc(100dvh - 510px), 344px);
  }
}

@media (max-width: 48rem) and (max-height: 44rem) {
  .main-stage {
    padding: 4px 8px;
    grid-template-rows: 38px minmax(0, 1fr) 142px;
    gap: 4px;
  }

  .path-rail button,
  .path-rail li > span,
  .path-current,
  .path-selected {
    min-height: 34px;
  }

  .wheel-wrap {
    --wheel-size: min(calc(100vw - 116px), calc(100dvh - 384px), 210px);
    min-width: 138px;
    min-height: 138px;
  }

  .stage-heading {
    padding: 1px 8px 2px;
    margin-bottom: -4px;
  }

  .stage-heading p {
    display: none;
  }

  .candidate-ticket {
    max-height: 142px;
    padding: 5px 8px;
  }

  .candidate-ticket header {
    padding-bottom: 2px;
  }

  .candidate-ticket ol {
    padding-block: 1px;
  }

  .candidate-ticket li {
    padding-block: 1px;
  }

  .candidate-actions .ticket-action {
    min-height: 30px;
    padding-block: 2px;
  }
}

@media (min-width: 48.001rem) and (max-height: 44rem) {
  .candidate-ticket ol {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 8px;
  }

  .candidate-ticket li {
    padding-block: 2px;
  }

  .candidate-ticket li small {
    display: none;
  }
}
