:root {
  --cream: #F5F0E8;
  --paper: #FAF7F2;
  --wood: #C4B5A0;
  --wood-deep: #A89078;
  --ink: #2C2A28;
  --ink-muted: #6B6560;
  --coral: #D9897A;
  --sage: #8FA38A;
  --taupe: #B5A99A;
  --fs-app: 30px;
  --fs-sub: 14px;
  --fs-roast: 16px;
  --fs-btn: 16px;
  --stroke-object: 3px;
  --stroke-bubble: 1.75px;
  --font: "WenQuanYi Micro Hei", "PingFang TC", "Noto Sans TC", "Droid Sans Fallback", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
}

button { font: inherit; color: inherit; }

.stage {
  width: min(420px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 16px 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen.has-tabs { padding-bottom: 76px; }

.brand h1 {
  margin: 0;
  font-size: var(--fs-app);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.brand .zh {
  font-size: 0.72em;
  font-weight: 600;
}

.subtitle {
  margin: 4px 0 0;
  font-size: var(--fs-sub);
  font-weight: 400;
  color: var(--ink-muted);
}

.cabinet {
  margin-top: 16px;
  padding: 12px 10px 14px;
  border: 12px solid transparent;
  border-radius: 22px;
  background:
    linear-gradient(var(--cream), var(--cream)) padding-box,
    linear-gradient(165deg, var(--wood), var(--wood-deep)) border-box;
}

.tier { margin-bottom: 8px; }
.tier:last-child { margin-bottom: 0; }

.slots {
  display: flex;
  justify-content: space-evenly;
  align-items: flex-end;
  gap: 8px;
}

.slot {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
  padding: 0 2px;
  cursor: pointer;
}

.figure {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: -8px;
  z-index: 1;
}

.figure-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.board {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--wood), var(--wood-deep));
}

.bubble {
  background: var(--paper);
  color: var(--ink);
  border: var(--stroke-bubble) solid var(--ink);
  border-radius: 14px;
  position: relative;
}

.shelf-bubble {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  padding: 4px 7px 7px;
  max-width: 100%;
}

.shelf-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  background: var(--paper);
  border-right: var(--stroke-bubble) solid var(--ink);
  border-bottom: var(--stroke-bubble) solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}

.shelf-index {
  margin: 8px 0 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding: 14px 0 8px;
}

.btn {
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  font-size: var(--fs-btn);
  font-weight: 600;
  cursor: pointer;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--coral); color: var(--ink); }
.btn-secondary { background: var(--sage); color: var(--ink); }
.btn-tertiary { background: var(--taupe); color: var(--ink); }
.btn.is-on { box-shadow: inset 0 0 0 2px var(--ink); }

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--paper);
  border-top: 1.5px solid var(--wood-deep);
  z-index: 2;
}

.tab {
  background: transparent;
  border: 0;
  padding: 14px 4px 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-muted);
  cursor: pointer;
}

.tab[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -3px 0 var(--ink);
}

.back {
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 0 0 8px;
  color: var(--ink-muted);
  font-size: 14px;
  cursor: pointer;
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 4px;
}

.eyebrow {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.hero-figure {
  position: relative;
  width: 180px;
  height: 180px;
}

.roast-bubble,
.share-roast {
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  font-size: var(--fs-roast);
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}

.guess-chip {
  margin: 0;
  padding: 6px 10px;
  background: var(--paper);
  border: var(--stroke-bubble) solid var(--ink);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}

.hand-flag {
  position: absolute;
  right: -4px;
  bottom: 6px;
  padding: 2px 6px;
  background: var(--taupe);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.paper-card,
.history-item,
.share-card {
  background: var(--paper);
  border: var(--stroke-bubble) solid var(--ink);
}

.paper-card {
  margin-top: 18px;
  border-radius: 16px;
  padding: 16px;
}

.home-line {
  margin: 0;
  font-size: var(--fs-roast);
  font-weight: 600;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
}

.history-figure {
  width: 48px;
  height: 48px;
  flex: none;
}

.history-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-name {
  font-size: 13px;
  color: var(--ink-muted);
}

.history-roast {
  font-size: 15px;
  font-weight: 600;
}

.share-card {
  border-width: 3px;
  border-radius: 18px;
  padding: 20px 16px 16px;
  text-align: center;
  box-shadow: 6px 8px 0 var(--wood);
}

.share-brand {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.share-figure {
  width: 148px;
  height: 148px;
  margin: 8px auto;
}

.share-name {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.share-card .subtitle { margin-bottom: 2px; }

.copy-status {
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--ink-muted);
}

.particle {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  pointer-events: none;
  z-index: 3;
  animation: particle-float 560ms ease-out forwards;
}

.particle.wood { background: var(--wood-deep); }

.is-bump { animation: bump 280ms ease; }

@keyframes bump {
  40% { transform: translateY(-5px); }
}

@keyframes particle-float {
  to { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .is-bump,
  .particle { animation: none; }
}
