:root {
  --paper: #f8f6ef;
  --surface: #fffefb;
  --surface-soft: #f0eee3;
  --ink: #20372b;
  --muted: #777c70;
  --line: #deded2;
  --green: #1c4a35;
  --green-2: #2d6549;
  --green-soft: #e5ede3;
  --amber: #b87a32;
  --amber-soft: #f5e9d6;
  --shadow: 0 22px 70px rgba(52, 53, 39, .12);
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --tea-sprite: url("assets/tea-tile-sprite.png");
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 85px; scroll-padding-bottom: calc(88px + env(safe-area-inset-bottom)); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 215, 196, .35), transparent 42%),
    #eeede6;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(45, 101, 73, .35);
  outline-offset: 2px;
}
.app-shell {
  width: min(100%, 820px);
  min-height: 100vh;
  margin: 0 auto;
  overflow: clip;
  background: var(--paper);
  border-inline: 1px solid rgba(49, 67, 49, .08);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
}
.app-header {
  height: 78px;
  flex: 0 0 78px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 251, .93);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}
.header-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: var(--green);
  transition: background .18s ease, transform .18s ease;
}
.header-icon:hover { background: var(--green-soft); transform: translateY(-1px); }
.header-icon svg { width: 22px; height: 22px; }
.brand-title {
  text-align: center;
  font: 700 28px/1.1 var(--font-serif);
  letter-spacing: .06em;
  color: var(--green);
}
.brand-subtitle {
  margin-top: 5px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .16em;
}
.main-content { flex: 1; }
.screen { display: none; padding: 20px 28px 34px; animation: screen-in .24s ease both; }
.screen.active { display: block; }
@keyframes screen-in { from { opacity: .45; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.hero-photo {
  display: block;
  width: 100%;
  height: clamp(170px, 27vw, 224px);
  object-fit: cover;
  object-position: center 55%;
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(38, 38, 28, .11);
}
.welcome-row { display: flex; align-items: flex-start; gap: 15px; margin: 24px 8px 20px; }
.assistant-avatar {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: #fffdf4;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 6px 15px rgba(28, 74, 53, .17);
}
.assistant-avatar svg { width: 32px; height: 32px; }
.welcome-bubble {
  max-width: 660px;
  padding: 18px 21px;
  color: #25372d;
  background: #e9ecde;
  border-radius: 6px 22px 22px 22px;
  font-size: 16px;
  line-height: 1.8;
}
.chat-log { display: flex; flex-direction: column; gap: 12px; margin: 0 8px 14px; }
.chat-message { max-width: 86%; display: flex; gap: 9px; align-items: flex-start; animation: screen-in .2s ease both; }
.chat-message.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-message .mini-avatar {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: var(--green); font-size: 11px;
}
.chat-message.user .mini-avatar { background: #b57831; }
.message-content { min-width: 0; display: grid; gap: 7px; }
.message-meta { padding-inline: 3px; color: #566759; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.message-meta[hidden] { display: none; }
.chat-progress { padding-inline: 3px; color: #828479; font-size: 12px; line-height: 1.45; }
.chat-progress[hidden] { display: none; }
.message-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.message-actions:empty { display: none; }
.message-actions .small-button { min-width: 54px; min-height: 38px; text-align: left; max-width: 100%; }
.message-actions .small-button:disabled { opacity: .55; cursor: default; }
.message-actions .game-entry-action {
  min-height: 44px; padding-inline: 16px; color: #fff; background: var(--green); border-color: var(--green);
}
.message-actions .game-entry-action:hover { color: #fff; background: var(--green-2); }
.chat-message .message-text {
  padding: 10px 13px;
  border-radius: 4px 15px 15px 15px;
  background: #fffefb;
  border: 1px solid #ebe9df;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.chat-message.user .message-text { background: #e8efe6; border-color: #dce7d8; border-radius: 15px 4px 15px 15px; }
.topic-strip { display: flex; align-items: center; gap: 4px; min-width: 0; margin: 6px 8px 0; }
.topic-chips {
  display: flex;
  flex: 1 1 0%;
  flex-wrap: nowrap;
  min-width: 0;
  gap: 9px;
  padding: 4px 4px 7px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scroll-padding-inline: 4px;
  scroll-snap-type: x proximity;
  touch-action: pan-x pan-y;
}
.topic-step {
  display: grid;
  flex: 0 0 42px;
  place-items: center;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--green);
  cursor: pointer;
}
.topic-step:disabled { visibility: hidden; }
.topic-step::after {
  content: "";
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 2px 2px 0 0;
  transform: rotate(45deg);
}
.topic-step[data-at-end="true"]::after { transform: rotate(-135deg); }
.topic-chip {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 8px 15px;
  color: var(--green);
  border: 1px solid #81927b;
  border-radius: 16px;
  background: rgba(255, 254, 251, .72);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.topic-chip:hover { transform: translateY(-2px); background: var(--green-soft); border-color: var(--green); }
.chat-compose {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 8px 12px;
  padding: 7px 8px 7px 19px;
  border: 1px solid #789078;
  border-radius: 40px;
  background: var(--surface);
  box-shadow: 0 4px 13px rgba(32, 55, 43, .04);
}
.compose-symbol { width: 23px; height: 23px; color: var(--green); flex: 0 0 23px; }
.chat-compose input {
  min-width: 0; flex: 1; height: 46px; border: 0; outline: 0; background: transparent;
  color: var(--ink); font-size: 15px;
}
.chat-compose input::placeholder { color: #95958d; }
.send-button {
  flex: 0 0 48px; width: 48px; height: 48px; border: 0; border-radius: 50%;
  display: grid; place-items: center; color: white; background: var(--green); cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.send-button:hover { background: var(--green-2); transform: rotate(-6deg) scale(1.04); }
.send-button svg { width: 22px; height: 22px; }
.demo-note { margin: 0 10px; color: #828479; font-size: 11px; line-height: 1.6; text-align: center; }
.screen-heading { margin: 5px 2px 20px; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.screen-heading h1 { margin: 0; font: 700 28px/1.3 var(--font-serif); color: var(--green); letter-spacing: .03em; }
.screen-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.quiet-label { color: #858879; font-size: 12px; white-space: nowrap; }
.game-switch {
  display: flex; gap: 8px; padding: 5px; margin: 0 0 18px;
  border: 1px solid var(--line); background: #efede4; border-radius: 15px;
}
.game-switch button {
  flex: 1; min-height: 43px; border: 0; border-radius: 11px; background: transparent;
  color: #74796d; font-weight: 600; font-size: 13px; cursor: pointer; transition: all .2s ease;
}
.game-switch button.active { color: var(--green); background: var(--surface); box-shadow: 0 2px 7px rgba(43, 57, 38, .09); }
.game-panel { display: none; }
.game-panel.active { display: block; animation: screen-in .22s ease both; }
.game-intro {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 15px; padding: 14px 16px; background: #f0eee2; border-radius: 15px;
}
.game-intro strong { display: block; color: var(--green); font-size: 15px; }
.game-intro p { margin: 5px 0 0; color: #777a70; font-size: 12px; line-height: 1.6; }
.round-stats { display: flex; gap: 8px; flex: 0 0 auto; }
.stat { min-width: 67px; padding: 8px 10px; border-radius: 11px; background: #fffdf7; text-align: center; }
.stat span { display: block; color: #89897f; font-size: 10px; }
.stat b { display: block; margin-top: 2px; color: var(--green); font-size: 18px; line-height: 1.1; }
.game-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 1px 10px; }
.game-status { min-height: 20px; color: #757a6d; font-size: 12px; }
.small-button {
  min-height: 36px; padding: 0 13px; border: 1px solid #91a08a; border-radius: 20px;
  color: var(--green); background: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all .18s ease;
}
.small-button:hover { background: var(--green-soft); transform: translateY(-1px); }
.match-board {
  position: relative;
  width: min(100%, 520px); margin: 0 auto 14px; padding: 8px;
  display: grid; grid-template-columns: repeat(var(--match-columns, 7), minmax(0, 1fr)); gap: 6px;
  border: 1px solid #e2decf; border-radius: 17px; background: #ebe8dc;
  box-shadow: inset 0 1px 3px rgba(70, 61, 41, .07);
  touch-action: none;
  user-select: none;
}
.match-tile {
  position: relative;
  aspect-ratio: 1; min-width: 0; padding: 3px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid rgba(123, 132, 104, .18); border-radius: 11px; background: #fffdf8; cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border .16s ease, opacity .2s ease;
  touch-action: none;
  user-select: none;
}
.match-tile:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(42, 56, 40, .11); }
.match-tile.selected { border: 2px solid var(--green-2); box-shadow: 0 0 0 3px rgba(45, 101, 73, .12); transform: scale(1.04); }
.match-tile.swapping {
  z-index: 8;
  will-change: transform;
  box-shadow: 0 9px 18px rgba(28, 74, 53, .22);
  border-color: rgba(45, 101, 73, .58);
  transition: transform .22s cubic-bezier(.18,.72,.2,1), box-shadow .18s ease;
}
.match-tile.swap-offset {
  transform: translate3d(var(--swap-x), var(--swap-y), 0) scale(1.06);
}
.match-tile.clearing { opacity: 0; transform: scale(.3) rotate(12deg); }
.match-tile.clearing {
  z-index: 5;
  animation: tea-clear-impact .5s cubic-bezier(.16,.8,.22,1) both;
  border-color: rgba(218, 164, 77, .8);
}
.match-tile.clearing::before {
  content: ""; position: absolute; inset: -4px; z-index: 0; border: 2px solid rgba(224, 178, 92, .88);
  border-radius: 13px; animation: tea-clear-ring .48s ease-out both; pointer-events: none;
}
.match-tile.clearing::after {
  content: ""; position: absolute; inset: -11px; z-index: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 229, 163, .86) 0%, rgba(250, 191, 86, .34) 34%, transparent 72%);
  animation: tea-clear-aura .5s ease-out both; pointer-events: none;
}
.match-tile .tea-art, .match-tile .tile-label { position: relative; z-index: 1; }
.match-tile.clearing .tea-art { animation: tea-art-burst .48s cubic-bezier(.18,.7,.25,1) both; }
.match-tile.falling {
  animation: tea-tile-drop .38s cubic-bezier(.18,.72,.2,1.08) var(--fall-delay, 0ms) both;
}
.match-spark {
  position: absolute; z-index: 8; left: 50%; top: 50%; width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle, #fffdf0 0 18%, #ffd984 35%, rgba(232, 166, 65, .25) 70%, transparent 75%);
  box-shadow: 0 0 8px rgba(255, 210, 113, .9);
  pointer-events: none;
  animation: tea-spark-fly .52s cubic-bezier(.12,.65,.28,1) both;
}
.match-clear-points {
  position: absolute; z-index: 9; left: 50%; top: -9px; white-space: nowrap;
  color: #fffdf1; font-size: 11px; line-height: 1; font-weight: 800;
  padding: 5px 7px; border-radius: 20px; background: #b5792f;
  box-shadow: 0 3px 9px rgba(96, 64, 25, .3);
  transform: translateX(-50%);
  animation: score-rise .68s cubic-bezier(.16,.7,.22,1) both;
  pointer-events: none;
}
.match-board.impact { animation: board-impact .38s ease-out; }
@keyframes tea-clear-impact {
  0% { opacity: 1; transform: scale(1); filter: brightness(1); }
  24% { opacity: 1; transform: scale(1.18); filter: brightness(1.55) saturate(1.25); }
  58% { opacity: .9; transform: scale(1.08) rotate(4deg); filter: brightness(1.2) saturate(1.2); }
  100% { opacity: 0; transform: scale(.16) rotate(-16deg); filter: blur(3px) brightness(1.5); }
}
@keyframes tea-clear-ring {
  0% { opacity: .9; transform: scale(.55); }
  65% { opacity: .65; }
  100% { opacity: 0; transform: scale(1.4); }
}
@keyframes tea-clear-aura {
  0% { opacity: 0; transform: scale(.4); }
  22% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.4); }
}
@keyframes tea-art-burst {
  0% { transform: scale(1); filter: drop-shadow(0 2px 2px rgba(35,41,25,.1)); }
  28% { transform: scale(1.22); filter: drop-shadow(0 0 10px rgba(255,214,126,.95)) brightness(1.22); }
  100% { transform: scale(.18) rotate(14deg); opacity: 0; }
}
@keyframes tea-spark-fly {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.2); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--spark-x)), calc(-50% + var(--spark-y))) scale(.45); }
}
@keyframes score-rise {
  0% { opacity: 0; top: 34%; transform: translate(-50%, 8px) scale(.75); }
  18% { opacity: 1; }
  100% { opacity: 0; top: -26px; transform: translate(-50%, -5px) scale(1); }
}
@keyframes tea-tile-drop {
  0% { opacity: .35; transform: translateY(var(--fall-y, -100%)) scale(.92); }
  72% { opacity: 1; transform: translateY(5%) scale(1.025); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes board-impact {
  0%, 100% { transform: translateX(0); }
  24% { transform: translateX(-2px); }
  48% { transform: translateX(2px); }
  72% { transform: translateX(-1px); }
}
.tea-art {
  display: block; width: 78%; max-width: 54px; aspect-ratio: 1;
  background-image: var(--tea-sprite); background-repeat: no-repeat; background-size: 300% 200%;
  background-position: var(--tea-x, 0%) var(--tea-y, 0%);
  filter: drop-shadow(0 2px 2px rgba(35, 41, 25, .1));
}
.tile-label { margin-top: 1px; color: #64705f; font-size: 9px; line-height: 1; }
.game-footnote { margin: 0; color: #85877a; font-size: 11px; text-align: center; line-height: 1.6; }
.result-panel {
  margin: 14px auto 0; padding: 16px; max-width: 520px; border: 1px solid #d8e1d2;
  border-radius: 16px; background: #edf3e8; text-align: center; animation: screen-in .24s ease both;
}
.result-panel h3 { margin: 0; color: var(--green); font: 700 19px/1.4 var(--font-serif); }
.result-panel p { margin: 7px 0 12px; color: #647264; font-size: 13px; line-height: 1.6; }
.result-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.tea-review { margin-top: 15px; border-top: 1px solid #c8d4c4; padding-top: 7px; text-align: left; }
.tea-review summary { padding: 8px 2px; color: var(--green); font-size: 14px; font-weight: 700; cursor: pointer; }
.tea-review summary span { margin-left: 6px; color: #536551; font-size: 12px; font-weight: 500; }
.tea-review p { margin: 2px 0 9px; }
.tea-review-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 0; margin: 0; list-style: none; }
.tea-review-list button {
  display: grid; justify-items: center; align-content: center; gap: 4px; width: 100%; min-height: 74px;
  padding: 5px 2px; border: 1px solid #c8d4c4; border-radius: 9px; color: var(--green);
  background: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer;
}
.tea-review-list button:is(:hover, :focus-visible) { border-color: var(--green); }
.tea-review-list :is(.tea-art, .tea-art-custom, .tea-art-alt) { width: 34px; height: 34px; }
.tea-review-list .tea-art-alt { display: grid; place-items: center; border-radius: 50%; color: #fff8df; background: #82532d; font-size: 17px; }
.tea-review-list .tea-art-alt.herbal { background: #397153; }
.memory-board {
  width: min(100%, 480px); margin: 0 auto 14px; display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(7px, 2vw, 12px);
}
.memory-board.complete { display: none; }
.memory-card {
  position: relative; padding: 0; aspect-ratio: .92; border: 0; background: transparent; cursor: pointer;
  perspective: 600px; -webkit-tap-highlight-color: transparent;
}
.memory-inner {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .58s cubic-bezier(.18,.82,.22,1), filter .58s ease;
  will-change: transform;
}
.memory-card.open .memory-inner, .memory-card.matched .memory-inner { transform: rotateY(180deg); }
.memory-back, .memory-front {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column;
  overflow: hidden; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.memory-back {
  color: #f7f3e8; background: var(--green);
  border: 1px solid rgba(255, 255, 255, .24);
  box-shadow: 0 5px 12px rgba(40, 56, 39, .14);
}
.memory-back::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(241, 231, 203, .52); border-radius: 10px; }
.memory-back svg { width: 27px; height: 27px; position: relative; opacity: .96; }
.memory-back small { margin-top: 3px; font: 11px/1 var(--font-serif); letter-spacing: .12em; position: relative; }
.memory-front { transform: rotateY(180deg); background: #fffdf7; border: 1px solid #e6e1d1; box-shadow: 0 4px 12px rgba(40, 56, 39, .07); }
.memory-front::after {
  content: ""; position: absolute; z-index: 1; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(112deg, transparent 28%, rgba(255,255,255,.72) 48%, transparent 68%);
  transform: translateX(-120%); opacity: 0;
}
.memory-card.open .memory-front::after { opacity: 1; animation: memory-sheen .62s ease .12s both; }
.memory-front .tea-art, .memory-front strong { position: relative; z-index: 2; }
.memory-front .tea-art { width: 61%; max-width: 62px; }
.memory-front strong { margin-top: 2px; color: var(--green); font-size: clamp(10px, 2vw, 12px); font-weight: 600; }
.memory-card.matched {
  pointer-events: none;
  animation: memory-pair-found .48s cubic-bezier(.18,.72,.22,1) .34s both;
}
.memory-card.matched .memory-front { background: #e6efe3; border-color: #bad0b8; }
.memory-card:disabled { cursor: default; }
@keyframes memory-sheen {
  0% { transform: translateX(-120%); opacity: 0; }
  24% { opacity: .75; }
  100% { transform: translateX(120%); opacity: 0; }
}
@keyframes memory-pair-found {
  0% { opacity: 1; transform: scale(1); filter: drop-shadow(0 0 0 rgba(127,163,97,0)); }
  28% { opacity: 1; transform: scale(1.08); filter: drop-shadow(0 0 9px rgba(127,163,97,.55)); }
  100% { opacity: 0; transform: scale(.16) rotate(8deg); filter: blur(2px); }
}
.share-layout { display: grid; grid-template-columns: .95fr 1.05fr; gap: 18px; align-items: start; }
.poster-picker { min-inline-size: 0; margin: 0 0 16px; padding: 0; border: 0; }
.poster-picker legend { padding: 0; }
.poster-templates { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.poster-template {
  min-width: 0; display: grid; justify-items: center; align-content: start; gap: 7px;
  padding: 7px 3px 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); cursor: pointer;
  font-size: 12px; line-height: 1.25; font-weight: 600;
}
.poster-template canvas {
  display: block; width: min(100%, 62px); height: auto; border-radius: 3px; background: var(--surface-soft);
}
.poster-template:hover { border-color: #819883; }
.poster-template[aria-pressed="true"] { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); background: var(--green-soft); }
.share-form { padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.field-label { display: block; margin: 0 0 8px; color: #536151; font-size: 12px; font-weight: 700; }
.platform-switch { display: flex; gap: 8px; margin-bottom: 17px; }
.platform-button {
  flex: 1; min-height: 41px; border: 1px solid #d9dccf; border-radius: 12px;
  background: #fffefb; color: #73786d; font-size: 13px; font-weight: 600; cursor: pointer;
}
.platform-button.active { color: #fff; border-color: var(--green); background: var(--green); }
.theme-select {
  width: 100%; height: 42px; margin: 0 0 16px; padding: 0 12px;
  color: var(--ink); border: 1px solid #d9dccf; border-radius: 11px; background: #fffefb; font-size: 13px;
}
.share-version-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 8px; }
.share-version-row .field-label { margin: 0; }
.version-count { color: #73786d; font-size: 12px; font-weight: 600; }
.share-buttons.version-buttons { margin: 0 0 16px; gap: 6px; }
.version-buttons .primary-button, .version-buttons .outline-button { min-height: 39px; padding-inline: 8px; font-size: 12px; }
.share-input {
  width: 100%; height: 42px; margin: 0 0 14px; padding: 0 12px;
  border: 1px solid #d9dccf; border-radius: 11px; background: #fffefb; color: #354437; font-size: 13px;
}
.share-textarea {
  width: 100%; min-height: 165px; resize: vertical; padding: 12px;
  border: 1px solid #d9dccf; border-radius: 12px; background: #fffefb; color: #354437; font-size: 13px; line-height: 1.75;
}
.share-buttons { display: flex; gap: 8px; margin-top: 12px; }
.primary-button, .outline-button {
  min-height: 43px; padding: 0 15px; border-radius: 12px; font-weight: 700; font-size: 13px; cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.primary-button { border: 1px solid var(--green); background: var(--green); color: white; }
.primary-button:hover { background: var(--green-2); transform: translateY(-1px); }
.outline-button { border: 1px solid #8ca08b; background: #fffefb; color: var(--green); }
.outline-button:hover { background: var(--green-soft); transform: translateY(-1px); }
.share-buttons button { flex: 1; }
.poster-wrap { padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: #eeece2; }
.poster-preview-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.poster-preview-header h2 { margin: 0; color: var(--green); font: 700 17px/1.25 var(--font-serif); }
.poster-preview-actions { display: flex; gap: 5px; }
.poster-preview-header button { min-height: 36px; padding-inline: 12px; }
.poster-mobile-action { display: none; }
#share-canvas { display: block; width: 100%; height: auto; border-radius: 11px; background: #f8f5eb; box-shadow: 0 4px 12px rgba(49, 48, 35, .12); }
.share-hint { margin: 9px 1px 0; color: #777a70; font-size: 11px; line-height: 1.6; }
.bottom-nav {
  position: sticky; bottom: 0; z-index: 30; flex: 0 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
  padding: 9px 10px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 254, 251, .96);
  backdrop-filter: blur(14px);
}
.nav-button {
  position: relative; min-height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: transparent; color: #7d8178; cursor: pointer; transition: color .18s ease;
}
.nav-button svg { width: 25px; height: 25px; }
.nav-button span { font-size: 12px; font-weight: 600; }
.nav-button.active { color: var(--green); }
.nav-button.active::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 54px; height: 3px; border-radius: 8px; background: var(--green); transform: translateX(-50%); }
.nav-button:hover { color: var(--green-2); }
.menu-popover {
  position: absolute; top: 66px; left: 16px; width: min(280px, calc(100vw - 32px)); padding: 15px;
  border: 1px solid #e2dfd3; border-radius: 15px; background: #fffefb; box-shadow: 0 15px 40px rgba(35, 45, 34, .16);
  z-index: 50; animation: screen-in .16s ease both;
}
.menu-popover[hidden] { display: none; }
.menu-popover strong { display: block; margin-bottom: 6px; color: var(--green); font: 700 16px/1.4 var(--font-serif); }
.menu-popover p { margin: 0; color: #777a70; font-size: 12px; line-height: 1.65; }
.menu-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.menu-links button { min-width: 0; padding: 8px 5px; border: 1px solid #dce2d7; border-radius: 9px; color: var(--green); background: #f9faf5; font-size: 11px; cursor: pointer; }
.toast {
  position: fixed; z-index: 100; left: 50%; bottom: 102px; max-width: calc(100vw - 36px);
  padding: 10px 15px; color: #fff; background: rgba(31, 55, 41, .95); border-radius: 12px;
  font-size: 13px; text-align: center; line-height: 1.5; transform: translate(-50%, 8px);
  opacity: 0; pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }
@media (max-width: 650px), (pointer: coarse) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .app-shell {
    --app-header-height: 70px;
    --screen-gutter: clamp(12px, 4vw, 16px);
    position: fixed;
    inset-inline: 0;
    top: var(--app-viewport-top, 0px);
    height: var(--app-viewport-height, 100vh);
    height: var(--app-viewport-height, 100dvh);
    min-height: 0;
    overflow: hidden;
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  }
  .app-shell, .main-content, .chat-scroll { touch-action: pan-x pan-y; }
  .app-header {
    position: relative;
    height: calc(var(--app-header-height) + env(safe-area-inset-top));
    flex-basis: calc(var(--app-header-height) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }
  .main-content, .chat-scroll {
    min-width: 0;
    min-height: 0;
    overflow: hidden auto;
    overscroll-behavior: contain;
    scroll-padding-block: 10px;
  }
  .main-content[data-screen="chat"] { overflow: hidden; }
  #screen-chat.active { display: flex; flex-direction: column; height: 100%; padding: 0; animation: none; }
  .chat-scroll { flex: 1 1 auto; padding: 15px var(--screen-gutter) 0; }
  .chat-dock {
    flex: 0 0 auto;
    padding: 0 var(--screen-gutter) 8px;
    border-top: 1px solid var(--line);
    background: var(--paper);
  }
  .chat-dock .chat-compose { margin: 8px 0; }
  .bottom-nav { position: relative; }
  .app-shell :is(input, textarea, select) { font-size: max(16px, 1em); }
  .keyboard-open .bottom-nav, .keyboard-open #chat-note, .keyboard-open .topic-strip { display: none; }
  .keyboard-open .toast { bottom: calc(var(--app-viewport-bottom, 0px) + 72px); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .app-shell { --app-header-height: 52px; }
  .keyboard-open .chat-scroll { padding-block-start: 0; }
}
@media (max-width: 650px) {
  body { background: var(--paper); }
  .app-shell { border: 0; box-shadow: none; }
  .app-header { padding-inline: 14px; }
  .brand-title { font-size: 25px; }
  .screen { padding: 15px 16px 27px; }
  .hero-photo { height: clamp(155px, 48vw, 205px); border-radius: 14px; }
  .welcome-row { gap: 10px; margin: 19px 1px 16px; }
  .assistant-avatar { width: 44px; height: 44px; flex-basis: 44px; }
  .assistant-avatar svg { width: 27px; height: 27px; }
  .welcome-bubble { padding: 13px 15px; font-size: 14px; line-height: 1.75; }
  .chat-log { margin-inline: 0; }
  .topic-strip { margin-inline: 0; }
  .topic-chips { gap: 8px; }
  .topic-chip { min-height: 43px; border-radius: 13px; }
  .chat-compose { min-height: 59px; margin: 15px 0 10px; padding-left: 15px; }
  .send-button { flex-basis: 43px; width: 43px; height: 43px; }
  .screen-heading { align-items: flex-start; flex-direction: column; margin-bottom: 16px; }
  .screen-heading h1 { font-size: 25px; }
  .game-intro { align-items: flex-start; flex-direction: column; }
  .round-stats { width: 100%; }
  .stat { flex: 1; }
  .match-board { gap: 4px; padding: 6px; border-radius: 14px; }
  .match-tile { border-radius: 8px; }
  .tile-label { display: none; }
  .share-layout { grid-template-columns: 1fr; }
  .poster-template { font-size: 11px; }
  .poster-wrap { width: min(100%, 410px); margin-inline: auto; }
  .poster-mobile-action { display: inline-block; }
  .bottom-nav { padding-top: 6px; }
  .nav-button { min-height: 59px; }
}
@media (max-width: 380px) {
  .screen { padding-inline: 12px; }
  .poster-templates { gap: 4px; }
  .game-switch button { font-size: 12px; }
  .memory-board { gap: 6px; }
  .memory-back, .memory-front { border-radius: 10px; }
  .round-stats { gap: 5px; }
  .stat { min-width: 0; padding-inline: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.home-hero { border-radius: 22px; overflow: hidden; background: #efeee4; }
.home-hero-copy { padding: 20px; }
.home-hero h1 { margin: 0 0 8px; color: #173d2b; font-size: clamp(28px, 6vw, 42px); }
.home-hero p { margin: 0; color: #4e6154; }
.home-hero .hero-photo { display: block; width: 100%; height: clamp(150px, 38vw, 290px); border-radius: 0; object-fit: cover; }
.home-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.home-action { padding: 15px; text-align:left; border-radius: 16px; border: 1px solid #dbe2d5; background: #fffefa; color:#203d2e; cursor: pointer; min-height: 74px; }
.home-action strong, .home-action span { display: block; }
.home-action strong { font-size: 17px; }
.home-action span { margin-top: 4px; color: #4e6154; font-size: 13px; }
.wallet-list { display: grid; gap: 12px; margin-block: 14px; }
.wallet-card, .checkout { padding: 16px; border: 1px solid #dbe2d5; border-radius: 14px; background: #fffefa; }
.wallet-group > :is(h2, summary) { font-size: 16px; font-weight: 700; margin: 0 0 6px; }
.wallet-group summary { cursor: pointer; padding: 8px 0; }
.wallet-group .wallet-card + .wallet-card { margin-top: 8px; }
.wallet-card h3 { font-size: 16px; margin: 0 0 6px; }
.wallet-card p, .checkout p { margin: 5px 0 12px; overflow-wrap: anywhere; }
.checkout input { width: 100%; margin-bottom: 8px; }
.game-toolbar { flex-wrap: wrap; gap: 6px; }
.game-toolbar .small-button { min-height: 38px; }
.game-toolbar .small-button:disabled { opacity: .52; cursor: default; }
#wallet-notice, #share-notice { margin: 8px 0; }
#poster-image { display: block; width: 100%; border-radius: 10px; }
#poster-save[hidden], #share-canvas[hidden], .checkout[hidden] { display: none; }
#poster-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; margin-top: 8px; }
.tea-art-custom { display: inline-block; width: 100%; max-height: 100%; aspect-ratio: 1; object-fit: contain; }
.memory-front img.tea-art-custom { width: 65%; }
.result-tip { color: #355446; }
.inline-actions { display:flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.inline-actions button { min-height: 38px; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.consent { margin-block: 10px; color: #4e6154; font-size: 13px; }
#game-share-consent label:not([hidden]) { display: flex; align-items: center; gap: 8px; min-height: 40px; }
#game-share-consent select { width: auto; margin: 0; }
.match-board[aria-disabled="true"], .memory-board[aria-disabled="true"] { opacity:.65; }
.memory-front .tea-art-alt { display:grid; place-items:center; font-size:clamp(22px, 9vw, 43px); font-weight: 700; color:#fff8df; border-radius: 50%; width:65%; aspect-ratio:1; background: #82532d; }
.memory-front .tea-art-alt.herbal { background: #397153; }
@media (max-width: 560px) {
  .home-links { grid-template-columns: 1fr; gap: 8px; }
  .home-action { min-height: 62px; padding: 10px 14px; }
}

.match-tea {
  align-items: center;
  margin-top: 12px;
}
.match-tea :is(.tea-art, .tea-art-custom) { width: 32px; height: 32px; }
.tea-review-list .tasting-link { margin-top: 4px; min-height: 38px; padding: 4px 2px; font-size: 11px; }
