:root {
  color-scheme: light;
  font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --ink: #5f452f;
  --line: #806043;
  --paper: #fff9e8;
  --yellow: #f7bd43;
  --yellow-dark: #d99124;
  --cream: #f7edc7;
  --sage: #94aa68;
  --danger: #d86f45;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #4e4538; }
button { font: inherit; color: inherit; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.hidden { display: none !important; }

.game-shell {
  position: relative;
  width: min(100vw, 520px);
  height: 100dvh;
  min-height: 620px;
  margin: 0 auto;
  overflow: hidden;
  background: #f2e1ad;
  box-shadow: 0 0 50px #221b16;
  color: var(--ink);
  user-select: none;
}

.scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-image: linear-gradient(to bottom, transparent 0 81%, rgba(60, 39, 21, .06)), url("assets/restaurant-bg.png");
  background-size: cover;
  background-position: center;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(103, 73, 44, .16), inset 0 -50px 70px rgba(85, 54, 25, .08);
}

.hud {
  position: absolute;
  z-index: 20;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: minmax(108px, 1.4fr) minmax(82px, .8fr) auto;
  gap: 7px;
  align-items: center;
}

.resource {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 7px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 252, 236, .94);
  box-shadow: 0 3px 0 rgba(90, 61, 39, .18);
  font-size: 17px;
}

.resource strong { flex: 1; font-variant-numeric: tabular-nums; }
.resource button { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; color: white; background: #dc7650; font-weight: 900; }
.star-icon { color: #e5a52a; text-shadow: 0 1px 0 #7a552f; }
.fish-icon { position: relative; width: 24px; height: 12px; border-radius: 50% 60% 55% 50%; background: #9d8369; transform: rotate(-7deg); }
.fish-icon::before { content: ""; position: absolute; left: -7px; top: 2px; border: 5px solid transparent; border-right-color: #9d8369; border-left: 0; }
.fish-icon::after { content: ""; position: absolute; right: 4px; top: 3px; width: 3px; height: 3px; border-radius: 50%; background: #f8e7ba; }
.hud-actions { display: flex; gap: 5px; }
.paper-button { width: 35px; height: 35px; padding: 0; border: 2px solid var(--line); border-radius: 9px; background: #fff8e8; box-shadow: 0 3px 0 rgba(90, 61, 39, .18); font-weight: 900; }

.notice-ribbon {
  position: absolute;
  z-index: 12;
  top: calc(max(12px, env(safe-area-inset-top)) + 42px);
  left: 50%;
  width: min(88%, 430px);
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 14px;
  color: #715538;
  background: rgba(255, 248, 220, .82);
  text-align: center;
  font-size: 12px;
  transition: opacity .3s;
}

.tables-layer, .guests-layer, .particles { position: absolute; inset: 0; }
.tables-layer { z-index: 4; pointer-events: none; }
.guests-layer { z-index: 6; pointer-events: none; }
.particles { z-index: 30; pointer-events: none; }

.table-spot {
  position: absolute;
  width: 36%;
  height: 19%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.table-spot img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 5px 2px rgba(87, 55, 29, .15)); }
.table-spot.locked { width: 29%; height: 10%; border: 2px dashed rgba(125, 91, 53, .20); border-radius: 20px; }
.table-spot.locked::before { content: "+"; color: rgba(125, 91, 53, .3); font-size: 28px; }

.guest {
  position: absolute;
  width: 26%;
  height: 20%;
  transform: translate(-50%, -50%);
  transition: left 1.2s cubic-bezier(.2,.74,.25,1), top 1.2s cubic-bezier(.2,.74,.25,1), opacity .45s, transform .45s;
  pointer-events: auto;
}

.guest img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 5px 2px rgba(87, 55, 29, .17)); }
.guest.actionable { cursor: pointer; }
.guest.actionable:active img { transform: scale(.94); }
.guest.leaving { opacity: 0; transform: translate(-50%, -70%) scale(.7); }
.guest.eating img { animation: munch .48s ease-in-out infinite alternate; }
@keyframes munch { to { transform: translateY(3px) rotate(1.5deg); } }

.order-bubble {
  position: absolute;
  left: 50%;
  bottom: 78%;
  min-width: 118px;
  transform: translateX(-50%);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 7px 9px;
  background: #fffdf3;
  box-shadow: 0 3px 0 rgba(90, 61, 39, .18);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  animation: bob 1s ease-in-out infinite alternate;
}
.order-bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; background: #fffdf3; border-right: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: translateX(-50%) rotate(45deg); }
.order-bubble.busy { color: #936d42; animation: none; }
@keyframes bob { to { transform: translateX(-50%) translateY(-4px); } }

.cod-drop {
  position: absolute;
  left: 58%;
  top: 66%;
  min-width: 96px;
  padding: 7px 9px 7px 27px;
  border: 2px solid #72543b;
  border-radius: 18px;
  color: #5e432e;
  background: #fff7c8;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(107, 73, 43, .2);
  animation: rewardPop .5s cubic-bezier(.2,1.6,.4,1), bob .8s .5s ease-in-out infinite alternate;
  text-align: center;
}
.cod-drop::before { content: ""; position: absolute; left: 9px; top: 10px; width: 16px; height: 8px; border-radius: 50%; background: #9d8369; }
@keyframes rewardPop { from { transform: scale(.2); opacity: 0; } }

.tip-jar {
  position: absolute;
  z-index: 8;
  left: 4%;
  bottom: 17%;
  width: 70px;
  height: 58px;
  border: 2px solid var(--line);
  border-radius: 14px 14px 22px 22px;
  background: #d8b45f;
  box-shadow: inset 0 8px #806342, 0 4px 0 rgba(92, 60, 34, .2);
  font-size: 11px;
  font-weight: 900;
}
.tip-jar b { display: block; margin-top: 5px; color: #fff9da; }
.tip-jar.ready { animation: bob .7s infinite alternate; }

.coach {
  position: absolute;
  z-index: 15;
  left: 13px;
  right: 13px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 7px 12px 7px 8px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 250, 229, .94);
  box-shadow: 0 4px 0 rgba(86, 56, 34, .18);
  pointer-events: none;
}
.coach.done { opacity: 0; transform: translateY(20px); transition: .5s; }
.coach-mascot { position: relative; width: 42px; height: 39px; flex: 0 0 auto; border: 2px solid var(--line); border-radius: 48% 48% 42% 42%; background: #f7f0dc; }
.coach-mascot::before, .coach-mascot::after { content: ""; position: absolute; top: -9px; width: 14px; height: 18px; border: 2px solid var(--line); background: #f7f0dc; transform: rotate(28deg); z-index: -1; }
.coach-mascot::before { left: 2px; }
.coach-mascot::after { right: 2px; transform: rotate(-28deg); }
.coach-mascot span::before, .coach-mascot span::after { content: ""; position: absolute; top: 14px; width: 4px; height: 5px; border-radius: 50%; background: var(--ink); }
.coach-mascot span::before { left: 11px; } .coach-mascot span::after { right: 11px; }
.coach small { color: #a06f3f; } .coach p { margin: 2px 0 0; font-size: 12px; font-weight: 700; }

.bottom-bar {
  position: absolute;
  z-index: 18;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(76px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 76px 1fr 57px 57px;
  gap: 7px;
  align-items: start;
  padding: 8px 10px env(safe-area-inset-bottom);
  border-top: 2px solid rgba(123, 87, 51, .25);
  background: rgba(244, 224, 171, .93);
  backdrop-filter: blur(6px);
}

.bottom-bar button { height: 59px; border: 2px solid var(--line); box-shadow: 0 4px 0 rgba(84, 55, 31, .2); font-weight: 900; }
.big-menu { border-radius: 12px; background: #fff8e7; font-size: 17px; }
.book-lines { display: block; width: 26px; height: 13px; margin: 0 auto 3px; border: 2px solid var(--line); border-radius: 3px; box-shadow: inset 11px 0 #fff3ce; }
.promo-button { border-radius: 17px; color: #61442d; background: linear-gradient(#ffd96e, #f4b637); }
.promo-button b, .promo-button small { display: block; pointer-events: none; }
.promo-button small { font-size: 10px; font-weight: 600; }
.promo-button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(84, 55, 31, .2); }
.megaphone { display: inline-block; position: relative; width: 17px; height: 13px; margin-right: 6px; border-radius: 3px; background: #d66d42; vertical-align: -2px; clip-path: polygon(0 28%,100% 0,100% 100%,0 72%); }
.small-action { border-radius: 12px; background: #fff9e9; font-size: 11px; }
.small-action > span { display: block; margin: 0 auto 3px; }
.checkmark { width: 24px; height: 24px; border: 2px solid var(--line); border-radius: 5px; color: #71944a; font-size: 18px; }
.cap-icon { width: 26px; height: 18px; background: #775d47; clip-path: polygon(50% 0,100% 35%,82% 48%,82% 95%,18% 95%,18% 48%,0 35%); }

.toast {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -8px);
  max-width: 82%;
  padding: 9px 15px;
  border-radius: 17px;
  color: white;
  background: rgba(75, 56, 40, .9);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.float-number { position: absolute; color: #a26128; font-size: 21px; font-weight: 1000; text-shadow: 0 2px #fff8d8; animation: floatAway 1.1s forwards; }
@keyframes floatAway { to { transform: translateY(-55px); opacity: 0; } }

.sheet-backdrop, .modal-backdrop { position: absolute; z-index: 40; inset: 0; background: rgba(52, 40, 29, .52); backdrop-filter: blur(1px); }
.menu-sheet {
  position: absolute;
  z-index: 42;
  left: 10px;
  right: 10px;
  bottom: calc(7px + env(safe-area-inset-bottom));
  height: min(66vh, 560px);
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 24px 24px 16px 16px;
  background: #fffaf0;
  box-shadow: 0 8px 0 rgba(72, 45, 29, .3);
  animation: sheetUp .28s ease-out;
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-handle { width: 46px; height: 5px; margin: 7px auto 3px; border-radius: 4px; background: #d6ba91; }
.menu-sheet header { display: flex; align-items: center; padding: 0 10px 8px; border-bottom: 2px solid #dfcaa8; }
.tabs { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.tab { padding: 10px 4px; border: 0; border-radius: 10px; background: #ead7b4; font-weight: 900; }
.tab.active { color: #5c402c; background: var(--yellow); box-shadow: inset 0 -3px #db9629; }
.close-button, .modal-close { width: 37px; height: 37px; margin-left: 8px; padding: 0; border: 2px solid #934d31; border-radius: 50%; color: white; background: #ea7447; font-size: 28px; line-height: 28px; }
.menu-content { height: calc(100% - 66px); overflow-y: auto; padding: 12px; }
.menu-intro { margin: 0 0 10px; color: #8e6f50; font-size: 12px; }
.shop-list { display: grid; gap: 9px; }
.shop-item { display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 10px; min-height: 78px; padding: 8px; border: 2px solid #e1cca6; border-radius: 15px; background: #fffdf7; }
.shop-item img { width: 62px; height: 62px; object-fit: contain; }
.shop-item .icon-card { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 13px; color: white; background: #bb925d; font-weight: 1000; font-size: 22px; }
.shop-item h3 { margin: 0 0 4px; font-size: 15px; }
.shop-item p { margin: 0; color: #8e6f50; font-size: 11px; line-height: 1.45; }
.buy-button { min-width: 76px; padding: 9px 8px; border: 2px solid var(--line); border-radius: 12px; background: #ffd15a; font-weight: 900; box-shadow: 0 3px 0 #c88e32; }
.buy-button:disabled { color: #a1937e; border-color: #b9ac99; background: #ded5c5; box-shadow: none; }
.level { display: inline-block; margin-left: 5px; padding: 1px 5px; border-radius: 7px; color: #fff; background: #9b7b58; font-size: 9px; }

.modal {
  position: absolute;
  z-index: 55;
  left: 50%;
  top: 50%;
  width: min(86%, 390px);
  transform: translate(-50%, -50%);
  padding: 24px 20px 20px;
  border: 3px solid var(--line);
  border-radius: 22px;
  background: #fffaf0;
  box-shadow: 0 7px 0 rgba(72, 45, 29, .28);
}
.modal-close { position: absolute; right: -12px; top: -14px; }
.modal h2 { margin: 0 0 10px; text-align: center; }
.modal p, .modal li { font-size: 13px; line-height: 1.6; }
.modal ul { padding-left: 20px; }
.modal .wide-button { width: 100%; margin-top: 8px; padding: 11px; border: 2px solid var(--line); border-radius: 12px; background: #ffd15a; font-weight: 900; }
.modal .danger-button { background: #ef9c79; }

@media (max-height: 700px) {
  .coach { display: none; }
  .bottom-bar { height: calc(67px + env(safe-area-inset-bottom)); }
  .bottom-bar button { height: 50px; }
  .guest { width: 22%; height: 17%; }
}
