:root {
  --bg: #fff7e2;
  --surface: #fffdf7;
  --surface-strong: #ffffff;
  --ink: #261d16;
  --muted: #75685d;
  --red: #d51f2a;
  --yellow: #ffc72c;
  --green: #198754;
  --line: #eadfca;
  --shadow: 0 14px 34px rgba(67, 45, 23, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 10% 8%, rgba(255, 199, 44, 0.36), transparent 28%),
    linear-gradient(180deg, #fff9e9 0%, #fff2d6 54%, #fff7e2 100%);
}

button {
  font: inherit;
}

.top-menu {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 30;
}

.menu-entry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.9);
  box-shadow: 4px 4px 0 rgba(255, 199, 44, 0.74);
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.menu-panel {
  position: fixed;
  top: 112px;
  left: 14px;
  display: none;
  width: 210px;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: 20px;
  background: rgba(255, 253, 247, 0.98);
  box-shadow:
    0 18px 40px rgba(38, 29, 22, 0.18),
    5px 5px 0 rgba(255, 199, 44, 0.78);
  backdrop-filter: blur(12px);
}

.menu-panel.is-open {
  display: grid;
  gap: 6px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 14px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(255, 199, 44, 0.28);
}

.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 22px 16px 148px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px 2px 14px;
}

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

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.7rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.subtitle {
  max-width: 24rem;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.hero-badge {
  position: relative;
  width: clamp(92px, 24vw, 156px);
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 199, 44, 0.92), rgba(255, 255, 255, 0.9)),
    var(--yellow);
  box-shadow: 8px 8px 0 var(--red);
  transform: rotate(3deg);
}

.hero-badge .stack {
  position: absolute;
  filter: drop-shadow(0 7px 0 rgba(38, 29, 22, 0.09));
}

.hero-badge .stack-a {
  top: 6%;
  left: 10%;
  z-index: 2;
  font-size: clamp(2rem, 7vw, 4rem);
  transform: rotate(-17deg);
}

.hero-badge .stack-b {
  right: 7%;
  bottom: 9%;
  z-index: 4;
  font-size: clamp(2.1rem, 7vw, 4.2rem);
}

.hero-badge .stack-c {
  top: 24%;
  right: 12%;
  z-index: 1;
  font-size: clamp(1.6rem, 5.6vw, 3.2rem);
  transform: rotate(10deg);
}

.hero-badge .stack-d {
  bottom: 5%;
  left: 13%;
  z-index: 3;
  font-size: clamp(1.5rem, 5.2vw, 3rem);
  transform: rotate(-9deg);
}

.hero-badge .stack-e {
  top: 46%;
  left: 33%;
  z-index: 5;
  font-size: clamp(1.25rem, 4vw, 2.25rem);
  transform: rotate(8deg);
}

.category-tabs {
  position: sticky;
  top: 58px;
  z-index: 5;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 0;
  background: transparent;
  backdrop-filter: blur(12px);
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 16px;
  border: 2px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(117, 104, 93, 0.18);
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.tab:hover {
  transform: translateY(-1px);
}

.tab.is-active {
  border-color: var(--ink);
  color: var(--ink);
  font-weight: 800;
  background: var(--yellow);
}

.notice {
  margin: 6px 0 16px;
  padding: 10px 12px;
  border: 1px solid rgba(213, 31, 42, 0.18);
  border-radius: 16px;
  color: #6b5141;
  background: rgba(255, 255, 255, 0.58);
  font-size: 0.84rem;
  line-height: 1.55;
}

.random-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
  padding: 14px;
  border: 2px solid rgba(38, 29, 22, 0.12);
  border-radius: 22px;
  background:
    radial-gradient(circle at 8% 18%, rgba(255, 255, 255, 0.92), transparent 26%),
    linear-gradient(135deg, rgba(255, 199, 44, 0.34), rgba(255, 255, 255, 0.7));
  box-shadow: 0 12px 28px rgba(67, 45, 23, 0.1);
}

.random-label {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
}

.random-box strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.12rem;
}

.random-box span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.random-button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 16px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: var(--yellow);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--red);
}

.food-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.food-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 210px;
  scroll-margin: 92px 0 120px;
  padding: 12px;
  border: 2px solid rgba(38, 29, 22, 0.1);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  isolation: isolate;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.food-card:hover {
  transform: translateY(-3px);
}

.food-card.is-selected {
  border-color: var(--red);
  background: #fff1d1;
  box-shadow: 0 14px 32px rgba(213, 31, 42, 0.16);
}

.check-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: transparent;
  background: var(--surface-strong);
  font-weight: 900;
  transform: scale(0.9);
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.food-card.is-selected .check-mark {
  color: var(--surface-strong);
  background: var(--green);
  transform: scale(1);
}

.food-art {
  display: grid;
  min-height: 92px;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.72), transparent 25%),
    linear-gradient(135deg, rgba(255, 199, 44, 0.42), rgba(213, 31, 42, 0.12));
  font-size: clamp(3rem, 12vw, 4.8rem);
}

.food-name {
  min-height: 2.6em;
  margin: 0;
  font-size: clamp(1rem, 3.8vw, 1.15rem);
  line-height: 1.3;
  letter-spacing: 0;
}

.food-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 999px;
  color: #57463a;
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.82rem;
  font-weight: 700;
}

.summary-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(980px, calc(100% - 20px));
  margin: 0 auto 10px;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.9), transparent 24%),
    linear-gradient(135deg, rgba(255, 251, 226, 0.98), rgba(255, 231, 190, 0.96));
  box-shadow:
    0 18px 44px rgba(38, 29, 22, 0.2),
    6px 6px 0 rgba(255, 199, 44, 0.74);
  backdrop-filter: blur(16px);
}

.summary-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 10px;
  border: 2px solid rgba(38, 29, 22, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  white-space: nowrap;
}

.summary-icon {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  font-size: 0.86rem;
  line-height: 1;
}

.summary-metrics strong {
  color: var(--ink);
  font-size: 1.25rem;
}

.summary-advice {
  display: flex;
  flex: 1 1 220px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 10px;
  border-left: 2px dashed rgba(38, 29, 22, 0.18);
  color: #5d4a3c;
  font-size: 0.9rem;
  line-height: 1.35;
}

.health-label {
  flex: 0 0 auto;
  min-width: 58px;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
  text-align: center;
  box-shadow: 3px 3px 0 rgba(38, 29, 22, 0.14);
}

.health-copy {
  min-width: 0;
  max-width: 22rem;
  white-space: normal;
}

.clear-button {
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 46px;
  border: 0;
  border-radius: 18px;
  color: #fff;
  background: var(--red);
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(38, 29, 22, 0.16);
}

.clear-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.login-modal,
.meals-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(38, 29, 22, 0.36);
  backdrop-filter: blur(8px);
}

.login-modal.is-open,
.meals-modal.is-open {
  display: flex;
}

.login-panel,
.meals-panel {
  position: relative;
  width: min(420px, 100%);
  padding: 24px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.95), transparent 25%),
    linear-gradient(135deg, #fffdf7, #fff0cf);
  box-shadow:
    0 24px 54px rgba(38, 29, 22, 0.26),
    7px 7px 0 var(--yellow);
}

.login-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid rgba(38, 29, 22, 0.18);
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.login-kicker {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.login-panel h2 {
  margin: 0 42px 16px 0;
  font-size: 1.65rem;
  line-height: 1.15;
}

.meals-panel h2 {
  margin: 0 42px 16px 0;
  font-size: 1.65rem;
  line-height: 1.15;
}

.meals-list {
  display: grid;
  gap: 10px;
  max-height: min(62vh, 520px);
  overflow: auto;
  padding-right: 4px;
}

.meal-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 2px solid rgba(38, 29, 22, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.meal-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.meal-card h3 {
  margin: 0;
  font-size: 1rem;
}

.meal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.meal-delete {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--red);
  font-weight: 800;
  cursor: pointer;
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.login-tab {
  min-height: 42px;
  border: 2px solid rgba(38, 29, 22, 0.1);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.login-tab.is-active {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--yellow);
  font-weight: 900;
}

.login-form {
  display: none;
}

.login-form.is-active {
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: #57463a;
  font-size: 0.9rem;
  font-weight: 800;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 2px solid rgba(38, 29, 22, 0.14);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  font: inherit;
  outline: 0;
}

.login-form input:focus {
  border-color: var(--red);
}

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

.code-button,
.login-submit {
  border: 0;
  border-radius: 16px;
  font-weight: 900;
  cursor: pointer;
}

.code-button {
  min-width: 112px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--yellow);
}

.login-submit {
  min-height: 48px;
  color: #fff;
  background: var(--red);
  box-shadow: inset 0 -3px 0 rgba(38, 29, 22, 0.16);
}

.login-message {
  min-height: 1.3em;
  margin: 12px 0 0;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 800;
}

.login-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 34px;
  }

  .food-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }

  .food-card {
    min-height: 232px;
    padding: 14px;
  }
}

@media (max-width: 560px) {
  .top-menu {
    top: 10px;
    left: 10px;
  }

  .menu-entry {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.88rem;
  }

  .menu-panel {
    top: 228px;
    left: 10px;
    width: 196px;
  }

  .app-shell {
    padding-bottom: 236px;
  }

  .summary-bar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    border-radius: 22px;
    padding: 12px;
  }

  .summary-metrics {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .clear-button {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
    min-height: 42px;
  }

  .summary-advice {
    grid-column: 1 / -1;
    grid-row: 1;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    padding: 0 0 10px;
    border-bottom: 2px dashed rgba(38, 29, 22, 0.16);
    border-top: 0;
    border-left: 0;
    font-size: 0.9rem;
  }

  .summary-chip {
    justify-content: center;
    min-height: 34px;
    padding: 0 6px;
  }

  .summary-icon {
    width: 22px;
    height: 22px;
    font-size: 0.78rem;
  }

  .health-label {
    min-width: 54px;
    padding: 7px 9px;
    border-radius: 14px;
  }

  .health-copy {
    flex: 1 1 auto;
    max-width: none;
    line-height: 1.45;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

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

  .hero-badge {
    width: 94px;
  }

  .food-grid {
    gap: 10px;
  }

  .food-card {
    min-height: 198px;
    padding: 10px;
  }

  .food-art {
    min-height: 78px;
  }

  .random-box {
    align-items: stretch;
    flex-direction: column;
  }

  .random-button {
    width: 100%;
  }

  .login-panel,
  .meals-panel {
    padding: 22px 18px;
    border-radius: 24px;
  }

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

  .code-button {
    min-height: 42px;
  }
}
