:root {
  --bg-0: #f4fbff;
  --bg-1: #e8f4fb;
  --bg-2: #dbeaf4;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: #f8fcff;
  --surface-soft: #eef5fa;
  --line: rgba(74, 116, 145, 0.2);
  --line-strong: rgba(74, 116, 145, 0.34);
  --text: #183142;
  --muted: #5d7a8f;
  --accent: #46a8d7;
  --accent-strong: #2b7da7;
  --danger: #d25c5c;
  --shadow: 0 18px 48px rgba(74, 116, 145, 0.14);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--text);
  background: #ffffff;
}

body {
  padding: 24px 16px 32px;
}

body[data-page="home"] {
  height: 100dvh;
  padding: 0 16px;
  overflow: hidden;
}

.site-footer {
  padding: 20px 16px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

body[data-page="home"] .app-shell {
  width: min(820px, 100%);
  height: calc(100dvh - 44px);
  display: grid;
  align-content: center;
}

body[data-page="home"] .site-footer {
  height: 44px;
  padding: 10px 16px 12px;
  overflow: hidden;
}

.hero,
.card,
.modal-panel,
.draw-stage-shell {
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent 28%),
    var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::before,
.card::before,
.modal-panel::before,
.draw-stage-shell::before {
  content: none;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
}

.hero-plain {
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  padding: 8px 0 18px;
}

body[data-page="home"] .hero-plain {
  padding: 0;
  display: block;
  text-align: center;
}

.eyebrow,
.section-kicker,
.focus-kicker,
.stage-result-label {
  margin: 0 0 8px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 700;
}

.hero h1,
.section-head h2,
.modal-head h2,
.stage-top h2,
.focus-card h3,
.stage-result h3 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

body[data-page="home"] .hero h1 {
  font-size: clamp(42px, 7vw, 72px);
  line-height: 0.92;
}

body[data-page="home"] .hero-copy {
  margin: 12px auto 0;
  text-align: center;
}

.selected-tags {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.selected-tags-label {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.selected-tags-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.selected-tag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid rgba(70, 168, 215, 0.28);
  border-radius: 999px;
  background: rgba(70, 168, 215, 0.12);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.selected-tag-chip::before {
  content: "#";
  margin-right: 6px;
  opacity: 0.7;
}

.hero-copy {
  margin: 14px 0 0;
  max-width: 36rem;
  color: var(--muted);
  line-height: 1.7;
}

.hero-badge {
  align-self: flex-start;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--accent-strong);
  font-weight: 600;
}

.hero-plain .hero-badge {
  background: rgba(255, 255, 255, 0.4);
}

.secret-trigger {
  cursor: pointer;
}

.landing-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 18px;
}

body[data-page="home"] .landing-layout {
  gap: 0;
  margin-top: 28px;
}

.selector-shell {
  padding-top: 6px;
}

body[data-page="home"] .selector-shell {
  display: grid;
  gap: 24px;
  justify-items: center;
  padding-top: 0;
}

.card {
  padding: 22px;
}

.section-head,
.modal-head,
.stage-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.section-head {
  margin-bottom: 18px;
}

.inline-note,
.muted,
.focus-meta,
.stage-status-copy,
.stage-result-copy,
.stage-result-reasons {
  color: var(--muted);
  font-size: 14px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

body[data-page="home"] .tag-cloud {
  width: min(100%, 720px);
  justify-content: center;
  gap: 12px;
  padding: 8px 0 10px;
}

.tag-chip,
.pill,
.context-pill {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  border-radius: 10px;
}

.tag-chip {
  padding: 10px 14px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

body[data-page="home"] .tag-chip {
  min-height: 44px;
  padding: 11px 16px;
}

.tag-chip.active {
  background: linear-gradient(180deg, rgba(70, 168, 215, 0.2), rgba(43, 125, 167, 0.24));
  border-color: rgba(70, 168, 215, 0.5);
  color: var(--text);
}

.tag-chip:hover,
.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.draw-toolbar,
.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.draw-toolbar {
  margin-top: 20px;
}

body[data-page="home"] .draw-toolbar {
  width: min(100%, 520px);
  margin-top: 0;
  justify-content: center;
}

.big-button {
  min-width: 180px;
}

body[data-page="home"] .big-button,
body[data-page="home"] .ghost-button {
  min-width: 160px;
}

.primary-button,
.ghost-button {
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.primary-button {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  color: #f8fcff;
  font-weight: 800;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
}

button:focus,
button:focus-visible {
  outline: none;
  box-shadow: none;
}

.summary-stack,
.history-list,
.food-list,
.stack-form {
  display: grid;
  gap: 14px;
}

.context-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.context-pill,
.pill {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.result-box,
.food-item,
.history-item,
.auth-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
}

.result-box,
.auth-card {
  padding: 18px;
}

.selector-shell .result-box {
  margin-top: 24px;
}

.result-box.empty {
  color: var(--muted);
}

.result-title {
  margin: 0 0 10px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.result-copy,
.result-reasons {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.draw-stage.hidden,
.modal.hidden,
.hidden {
  display: none !important;
}

.draw-stage {
  position: fixed;
  inset: 0;
  z-index: 35;
  padding: 12px;
}

.draw-stage-bg {
  position: absolute;
  inset: 0;
  background: #ffffff;
}

.draw-stage-shell {
  width: min(1180px, 100%);
  min-height: calc(100vh - 24px);
  margin: 0 auto;
  padding: 26px;
  color: var(--text);
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.draw-stage-shell .section-kicker,
.draw-stage-shell .focus-kicker,
.draw-stage-shell .stage-result-label {
  color: var(--accent-strong);
}

.draw-stage-shell .ghost-button {
  background: rgba(255, 255, 255, 0.68);
}

.draw-stage-shell .primary-button {
  box-shadow: 0 12px 32px rgba(70, 168, 215, 0.16);
}

.stage-status-copy,
.focus-meta,
.stage-result-copy,
.stage-result-reasons {
  color: var(--muted);
}

.stage-status-copy {
  margin: 10px 0 0;
  max-width: 48rem;
}

.stage-arena {
  min-height: 58vh;
  display: grid;
  place-items: center;
}

.draw-stage-minimal .stage-top,
.draw-stage-minimal .stage-status-copy,
.draw-stage-minimal .focus-kicker,
.draw-stage-minimal .focus-meta {
  display: none !important;
}

.draw-stage-minimal .draw-stage-shell {
  display: grid;
  place-items: center;
  padding: 0;
}

.draw-stage-minimal .stage-arena {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.focus-card h3,
.stage-result h3 {
  font-size: clamp(28px, 4vw, 52px);
  letter-spacing: -0.05em;
}

.focus-card {
  width: min(760px, 100%);
  min-height: 320px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 24px 12px;
  background: transparent;
  border: 0;
  box-shadow: none;
  transition: transform 220ms ease, opacity 220ms ease;
}

.focus-card.revealed {
  transform: scale(1.02);
}

.focus-card.switching {
  animation: card-switch 120ms linear;
}

.focus-kicker {
  margin-bottom: 16px;
}

.focus-card h3 {
  margin: 0;
  font-size: clamp(48px, 9vw, 112px);
  line-height: 0.92;
  letter-spacing: -0.08em;
  color: var(--accent-strong);
}

.draw-stage-minimal .focus-card {
  width: min(980px, 100%);
  min-height: 0;
  padding: 0 12px;
  display: grid;
  place-items: center;
  text-align: center;
}

.draw-stage-minimal .focus-card h3 {
  font-size: clamp(72px, 11vw, 160px);
}

.focus-meta {
  margin: 16px 0 0;
  max-width: 36rem;
  line-height: 1.7;
}

.stage-result {
  width: min(900px, 100%);
  min-height: calc(100vh - 68px);
  margin: 0 auto;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 12px 24px;
  text-align: center;
  background: transparent;
  border: 0;
  color: var(--text);
}

.stage-result-kicker {
  margin: 0;
  color: var(--text);
  font-size: clamp(24px, 3.6vw, 42px);
  font-weight: 800;
  letter-spacing: -0.06em;
}

.stage-result h3 {
  margin: 0;
  font-size: clamp(52px, 7vw, 96px);
  line-height: 0.92;
  color: var(--accent-strong);
}

.stage-result-copy,
.stage-result-reasons {
  margin: 0;
  line-height: 1.7;
}

.stage-result-reasons {
  margin-top: 10px;
}

.stage-result-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 680px;
  margin-top: 10px;
}

.stage-result-tag {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(70, 168, 215, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.stage-result-tag::before {
  content: "#";
  margin-right: 6px;
  opacity: 0.7;
}

.stage-result .form-actions {
  justify-content: center;
  margin-top: 6px;
}

.stage-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 10px 16px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  background: #ffffff;
}

.stage-result .primary-button,
.stage-result .ghost-button {
  min-width: 168px;
  min-height: 48px;
  padding: 12px 18px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(214, 231, 241, 0.72);
}

.modal-panel {
  width: min(1180px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  margin: 12px auto;
  padding: 22px;
}

.admin-content,
.admin-grid,
.form-grid {
  display: grid;
  gap: 18px;
}

.admin-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 18px;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  padding: 12px 14px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox input {
  width: auto;
}

.search-input {
  max-width: 260px;
}

.food-item,
.history-item {
  padding: 16px;
}

.food-head,
.history-head,
.meta-row,
.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.food-head,
.history-head {
  justify-content: space-between;
  align-items: flex-start;
}

.food-head h3,
.history-head h3 {
  margin: 0;
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.36);
}

.inline-button,
.danger-link {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font-weight: 700;
}

.inline-button {
  color: var(--accent-strong);
}

.danger-link {
  color: var(--danger);
}

@keyframes card-switch {
  from {
    transform: scale(0.96);
    opacity: 0.24;
    filter: blur(6px);
  }

  to {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
  }
}

@media (max-width: 960px) {
  .landing-layout,
  .admin-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .draw-stage-shell {
    padding: 20px;
  }

  .stage-arena {
    min-height: 50vh;
  }
}

@media (max-width: 640px) {
  body[data-page="home"] {
    height: 100dvh;
    padding: 0 14px;
  }

  body[data-page="home"] .app-shell {
    height: calc(100dvh - 40px);
    align-content: center;
    padding-top: 0;
  }

  body[data-page="home"] .landing-layout {
    margin-top: 22px;
  }

  body[data-page="home"] .selector-shell {
    gap: 18px;
  }

  .selected-tags {
    margin-top: 16px;
    gap: 8px;
  }

  .selected-tags-label {
    width: 100%;
    text-align: center;
  }

  body[data-page="home"] .tag-cloud {
    justify-content: flex-start;
    padding: 10px 0 12px;
  }

  body[data-page="home"] .draw-toolbar {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: stretch;
  }

  body[data-page="home"] .big-button,
  body[data-page="home"] .ghost-button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 8px 18px rgba(74, 116, 145, 0.08);
  }

  body[data-page="home"] #drawButton {
    grid-column: 1 / -1;
    min-height: 58px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 14px 28px rgba(70, 168, 215, 0.18);
  }

  body[data-page="home"] #shuffleTagsButton,
  body[data-page="home"] #clearTagsButton {
    background: rgba(255, 255, 255, 0.9);
  }

  body[data-page="home"] .ghost-button:active,
  body[data-page="home"] .primary-button:active {
    transform: translateY(1px) scale(0.99);
  }

  body[data-page="home"] .site-footer {
    height: 40px;
    padding: 8px 14px 10px;
    font-size: 11px;
  }

  .draw-stage {
    padding: 0;
  }

  .draw-stage-shell {
    min-height: 100vh;
    padding: 18px 16px 24px;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
  }

  .stage-top {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
  }

  .stage-top .ghost-button {
    width: 100%;
    min-height: 48px;
    justify-self: stretch;
  }

  .stage-status-copy {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.6;
  }

  .stage-arena {
    min-height: 44vh;
    padding: 12px 0 8px;
  }

  .focus-card {
    width: 100%;
    min-height: 0;
    padding: 12px 4px;
  }

  .focus-kicker {
    margin-bottom: 12px;
    font-size: 10px;
    letter-spacing: 0.14em;
  }

  .focus-card h3 {
    font-size: clamp(42px, 15vw, 76px);
    line-height: 0.94;
    letter-spacing: -0.06em;
  }

  .focus-meta {
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.65;
  }

  .stage-result {
    width: 100%;
    min-height: calc(100vh - 40px);
    align-content: center;
    padding: 8px 0;
    gap: 10px;
  }

  .stage-footer {
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 14px 10px;
    font-size: 11px;
  }

  .stage-result-kicker {
    font-size: clamp(24px, 8vw, 34px);
  }

  .stage-result-label {
    margin-bottom: 10px;
  }

  .stage-result h3 {
    font-size: clamp(38px, 12vw, 60px);
    line-height: 0.94;
  }

  .stage-result-tags {
    gap: 8px;
  }

  .stage-result-tag {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 13px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 18px;
  }

  .form-actions .primary-button,
  .form-actions .ghost-button {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    font-size: 15px;
  }
}
