:root {
  color-scheme: light;
  --ink: #2f2a24;
  --muted: #8b7f71;
  --cream: #fff7e8;
  --paper: #fffdf8;
  --orange: #f58645;
  --green: #4f8a6f;
  --line: #eadcca;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 8%, #ffe8b5 0 7%, transparent 20%),
    linear-gradient(165deg, #fffaf0, #f6ead4);
}

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

.app {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: auto;
  padding: 24px 18px 32px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; }
.eyebrow { margin: 0 0 3px; color: var(--orange); font-size: 10px; font-weight: 900; letter-spacing: 1.7px; }
h1 { margin: 0; font-family: Georgia, "STSong", serif; font-size: 29px; letter-spacing: 2px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.65); font-size: 20px; font-weight: 900; cursor: pointer; }
.icon-button.off { opacity: .4; }

.status-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 20px 0 16px;
  padding: 12px 8px;
  border: 1px solid rgba(234,220,202,.8);
  border-radius: 18px;
  background: rgba(255,253,248,.72);
  box-shadow: 0 8px 25px rgba(82,59,27,.06);
}
.status-card div { text-align: center; border-right: 1px solid var(--line); }
.status-card div:last-child { border: 0; }
.status-card span { display: block; color: var(--muted); font-size: 11px; }
.status-card strong { display: block; margin-top: 2px; font-size: 20px; }
.status-card strong i { font-style: normal; }
.tester-panel > strong i { color: var(--orange); font-size: 9px; font-style: normal; }

.order-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  margin: -4px 0 24px;
  padding: 10px 12px;
  border: 1px solid #d9e7d9;
  border-radius: 15px;
  background: rgba(246,255,246,.8);
}
.customer { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #ddefd8; font-size: 23px; }
.order-copy > div:first-child { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.order-copy strong { font-size: 12px; }
.order-copy span { color: var(--muted); font-size: 9px; }
.order-card > b { color: var(--green); font-size: 12px; }
.progress-track { height: 7px; margin-top: 7px; overflow: hidden; border-radius: 5px; background: #dce9d9; }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7db98e, var(--green)); transition: width .35s ease; }

.shop {
  position: relative;
  padding: 35px 14px 17px;
  border: 2px solid #9a6847;
  border-radius: 18px 18px 10px 10px;
  background: #e8bb80;
  box-shadow: inset 0 0 0 5px #f8d49e, 0 12px 25px rgba(86,51,24,.13);
}
.shop-sign { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; width: max-content; padding: 7px 16px; border: 2px solid #80553b; border-radius: 8px; background: #fff3d5; font-family: Georgia, "STSong", serif; font-size: 13px; font-weight: bold; letter-spacing: 2px; }
.shop-sign span { width: 18px; height: 1px; background: #b79469; }
.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 7px; min-height: 0; align-content: start; transition: min-height .25s ease; }
.board.sparse { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 340px; margin-inline: auto; }
.item-stack { position: relative; aspect-ratio: 1; }
.item, .tray-slot {
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: clamp(25px, 8vw, 34px);
}
.product-icon { display: inline-grid; width: 72%; height: 72%; vertical-align: middle; }
.product-icon svg { display: block; width: 100%; height: 100%; overflow: visible; }
.order-copy strong .product-icon { width: 24px; height: 24px; margin: -5px 2px -6px 4px; }
.order-copy strong > span:last-child { font-size: 11px; }
.item { position: absolute; inset: 0; width: 100%; background: #fffaf0; box-shadow: 0 4px 0 #c6935e, 0 6px 9px rgba(85,50,22,.12); cursor: pointer; animation: pop .22s both; transition: filter .2s, transform .2s, opacity .2s; }
.item.back { transform: translate(4px, -5px) scale(.94); filter: saturate(.5) brightness(.82); opacity: .72; pointer-events: none; }
.item.front { z-index: 2; }
.item.suggested { outline: 3px solid #85bd8e; animation: breathe 1.15s ease-in-out infinite; }
.item.reveals-target { outline: 3px solid #f0ad62; }
.item.reveals-target::before { content: "↓ 目标"; position: absolute; top: -7px; right: -5px; z-index: 4; padding: 2px 5px; border-radius: 8px; color: white; background: var(--orange); font-size: 8px; font-weight: 900; }
.item:active { transform: translateY(3px); box-shadow: 0 1px 0 #c6935e; }
.item::after { content: ""; position: absolute; inset: auto 7px 5px; height: 2px; border-radius: 2px; background: rgba(139,90,54,.16); }

.tray-wrap { margin-top: 19px; }
.tray-wrap p { display: flex; justify-content: space-between; margin: 0 3px 8px; font-size: 13px; font-weight: 800; }
.tray-wrap p span { color: var(--muted); font-size: 10px; font-weight: 500; }
.tray { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 8px; border: 2px solid #b8976f; border-radius: 14px; background: #d7b181; box-shadow: inset 0 3px 8px rgba(72,40,14,.15); }
.tray-slot { background: rgba(255,255,255,.55); border: 1px dashed rgba(128,85,59,.25); font-size: clamp(21px, 6vw, 29px); }
.tray-slot.filled { background: #fffaf0; border-style: solid; animation: pop .18s both; }
.tray-slot.clearing { animation: clear .35s both; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.secondary-button { padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,253,248,.8); font-size: 13px; font-weight: 800; cursor: pointer; }
.secondary-button b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; border-radius: 10px; color: white; background: var(--green); font-size: 11px; }
.secondary-button:disabled { opacity: .4; cursor: default; }
.autosave-note { margin: 12px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.autosave-note a { color: inherit; }
.hidden { display: none !important; }
.tester-panel { margin-top: 14px; padding: 13px; border: 1px dashed #c9af8d; border-radius: 14px; background: rgba(255,250,238,.78); }
.tester-panel > strong, .tester-panel > span { display: block; }
.tester-panel > strong { font-size: 12px; }
.tester-panel > span { margin: 2px 0 9px; color: var(--muted); font-size: 10px; }
.tester-panel > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tester-panel button { padding: 8px 4px; border: 1px solid var(--line); border-radius: 9px; background: white; font-size: 10px; cursor: pointer; }
.tester-panel .copy-report { width: 100%; margin-top: 7px; color: white; border-color: var(--green); background: var(--green); }
.report-link { display: block; margin-top: 9px; color: var(--green); font-size: 10px; text-align: center; text-decoration: none; }
.upgrade-card { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,253,248,.72); }
.upgrade-card span { display: block; color: var(--muted); font-size: 9px; }
.upgrade-card strong { font-size: 12px; }
.upgrade-card button { padding: 8px 11px; border: 0; border-radius: 10px; color: white; background: var(--green); font-size: 10px; font-weight: 800; cursor: pointer; }
.upgrade-card button:disabled { opacity: .45; }
.shop.upgraded { background: #cfa77b; border-color: #6f543e; box-shadow: inset 0 0 0 5px #edd1aa, 0 12px 25px rgba(86,51,24,.13); }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 5; transform: translate(-50%, 18px); padding: 9px 15px; border-radius: 20px; color: white; background: rgba(47,42,36,.9); opacity: 0; pointer-events: none; transition: .2s; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.rewarded-ad { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(47,42,36,.58); backdrop-filter: blur(5px); }
.rewarded-ad-card { position: relative; width: min(100%, 340px); padding: 20px; border-radius: 20px; background: var(--paper); text-align: center; box-shadow: 0 25px 70px rgba(0,0,0,.25); animation: pop .25s both; }
.ad-close { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: rgba(255,255,255,.82); font-size: 24px; line-height: 1; cursor: pointer; }
.ad-kicker { margin: 1px 0 12px; color: var(--orange); font-size: 10px; font-weight: 900; letter-spacing: 2px; }
.ad-visual { display: grid; place-items: center; min-height: 125px; padding: 18px; border: 1px solid #d2e5d5; border-radius: 12px; color: white; background: #4f8a6f; overflow: hidden; }
.ad-visual::before { content: ""; width: 54px; height: 54px; margin-bottom: 8px; border: 9px solid #fff7e8; border-top: 0; border-radius: 6px 6px 14px 14px; box-shadow: inset 0 0 0 4px rgba(255,255,255,.18); }
.ad-visual span { font-size: 10px; opacity: .82; }
.ad-visual strong { margin-top: 3px; font-family: Georgia, "STSong", serif; font-size: 20px; letter-spacing: 1px; }
.rewarded-ad h2 { margin: 16px 0 4px; font-family: Georgia, "STSong", serif; font-size: 24px; }
.rewarded-ad-card > p:not(.ad-kicker) { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.ad-progress { height: 6px; margin: 0 0 14px; overflow: hidden; border-radius: 4px; background: #e8e0d5; }
.ad-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .35s linear; }
.rewarded-ad .primary-button:disabled { box-shadow: none; opacity: .45; cursor: default; }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: rgba(47,42,36,.47); backdrop-filter: blur(4px); }
.modal.hidden { display: none; }
.modal-card { width: min(100%, 340px); padding: 30px 24px 22px; border-radius: 24px; background: var(--paper); text-align: center; box-shadow: 0 25px 70px rgba(0,0,0,.2); animation: pop .25s both; }
.modal-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: -4px auto 16px; border-radius: 50%; color: white; background: var(--orange); font-size: 31px; }
.modal-kicker { margin: 0; color: var(--orange); font-size: 11px; font-weight: 900; letter-spacing: 2px; }
.modal h2 { margin: 7px 0 8px; font-family: Georgia, "STSong", serif; font-size: 27px; }
.modal-card > p:not(.modal-kicker) { margin: 0 0 21px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.primary-button { width: 100%; padding: 14px; border: 0; border-radius: 14px; color: white; background: var(--orange); box-shadow: 0 5px 0 #c96435; font-weight: 900; cursor: pointer; }
.text-button { margin-top: 16px; border: 0; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }

.celebration {
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 8;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 3px;
  min-width: 165px;
  padding: 13px 20px;
  border: 2px solid #f0c578;
  border-radius: 18px;
  background: rgba(255,253,248,.96);
  box-shadow: 0 15px 45px rgba(90,57,25,.2);
  text-align: center;
  pointer-events: none;
  animation: reward .9s both;
}
.celebration strong { color: var(--orange); font-size: 16px; }
.celebration span { color: var(--green); font-size: 11px; font-weight: 800; }

@keyframes pop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
@keyframes clear { to { opacity: 0; transform: translateY(-15px) scale(.45) rotate(10deg); } }
@keyframes reward {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(.72); }
  18%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -78%) scale(.92); }
}
@keyframes breathe { 50% { transform: translateY(-3px) scale(1.035); box-shadow: 0 7px 0 #79a982, 0 10px 18px rgba(79,138,111,.25); } }
@media (max-height: 720px) { .app { padding-top: 14px; } .status-card { margin: 12px 0 14px; } }
