:root {
  --lagoon: #4FC1C7; --deep: #2E8FA8; --meadow: #A6D96A; --dune: #F5DDA0;
  --wood: #8B5E3C; --wood-dark: #6B4429; --ink: #5A3E2B; --paper: #FFFDF6; --paper-2: #FFF3DA;
  --carrot: #FF8C42; --carrot-dark: #D9691F; --clover: #4CB76A; --clover-dark: #32914E;
  --berry: #F06A8A; --muted: #A08670;
  --display: "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  --body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--deep); color: var(--ink); font-family: var(--body);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
#game { position: fixed; inset: 0; touch-action: none; }
#game canvas { display: block; touch-action: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- HUD */
.hud { position: fixed; z-index: 10; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-tl { top: calc(12px + var(--safe-t)); left: calc(12px + var(--safe-l)); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hud-tr { top: calc(12px + var(--safe-t)); right: calc(12px + var(--safe-r)); display: flex; gap: 10px; }
.hud-b { bottom: calc(14px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: flex-end; }
.res-row { display: flex; gap: 8px; }
.res { display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px 0 8px; border-radius: 22px; background: var(--paper);
  border: 3px solid var(--wood); box-shadow: 0 4px 0 rgba(107,68,41,.35); font-family: var(--display); font-size: 22px; min-width: 104px; }
.res .ico { font-size: 24px; width: 30px; text-align: center; }
.res.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }

.round { width: 54px; height: 54px; border-radius: 50%; background: var(--paper); border: 3px solid var(--wood); box-shadow: 0 4px 0 rgba(107,68,41,.35);
  font-size: 26px; display: grid; place-items: center; position: relative; }
.round:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(107,68,41,.35); }
.dot { position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; border-radius: 50%; background: var(--berry); border: 2px solid #fff; }

.dock-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 92px; padding: 10px 0 8px; border-radius: 24px; background: var(--paper);
  border: 3px solid var(--wood); box-shadow: 0 5px 0 var(--wood-dark); font-family: var(--display); font-size: 17px; position: relative; }
.dock-btn .ico { font-size: 34px; line-height: 1; }
.dock-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--wood-dark); }
.dock-btn.primary { background: var(--carrot); color: #fff; border-color: var(--carrot-dark); box-shadow: 0 5px 0 var(--carrot-dark); }
.dock-btn .count { position: absolute; top: -10px; right: -6px; background: var(--berry); color: #fff; font-size: 14px; border-radius: 12px; padding: 1px 8px; border: 2px solid #fff; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.guests { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; padding: 2px; }
.guest { width: 54px; height: 54px; border-radius: 50%; background: var(--paper-2); border: 3px solid #fff; box-shadow: 0 3px 0 rgba(0,0,0,.15); overflow: hidden; position: relative; }
.guest img { width: 120%; margin: -6% 0 0 -10%; }
.guest.res { border-color: var(--clover); }
.guest .tag { position: absolute; bottom: -1px; right: -1px; font-size: 16px; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; z-index: 60; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 20px; background: var(--paper); border: 3px solid var(--wood);
  box-shadow: 0 4px 0 rgba(107,68,41,.3); font-size: 17px; animation: tin .3s ease; }
.toast img { width: 40px; height: 40px; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(-14px) scale(.96); } }

/* ---------------------------------------------------------------- modal */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(30,60,70,.45); display: grid; place-items: center; padding: calc(20px + var(--safe-t)) 16px calc(20px + var(--safe-b)); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { position: relative; width: min(94vw, 640px); max-height: calc(100dvh - 60px - var(--safe-t) - var(--safe-b)); display: flex; flex-direction: column;
  background: var(--paper); border: 4px solid var(--wood); border-radius: 30px; box-shadow: 0 8px 0 var(--wood-dark); animation: pop .26s cubic-bezier(.2,1.4,.5,1); }
.modal.wide { width: min(96vw, 860px); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.modal-title { position: absolute; top: -24px; left: 50%; transform: translateX(-50%); background: var(--wood); color: #fff; font-family: var(--display); font-size: 24px;
  padding: 6px 28px; border-radius: 20px; white-space: nowrap; box-shadow: 0 4px 0 var(--wood-dark); }
.modal-x { position: absolute; top: -18px; right: -14px; width: 48px; height: 48px; border-radius: 50%; background: var(--berry); color: #fff; font-size: 24px; font-weight: 700;
  border: 3px solid #fff; box-shadow: 0 4px 0 #c64a68; }
.modal-x:active { transform: translateY(3px); box-shadow: 0 1px 0 #c64a68; }
.modal-body { padding: 34px 22px 22px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 20px; border-radius: 18px; font-family: var(--display); font-size: 19px;
  background: var(--carrot); color: #fff; border: 3px solid var(--carrot-dark); box-shadow: 0 4px 0 var(--carrot-dark); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--carrot-dark); }
.btn.green { background: var(--clover); border-color: var(--clover-dark); box-shadow: 0 4px 0 var(--clover-dark); }
.btn.plain { background: var(--paper-2); color: var(--ink); border-color: var(--wood); box-shadow: 0 4px 0 rgba(107,68,41,.4); }
.btn:disabled { filter: grayscale(.9); opacity: .55; transform: none; }
.btn.sm { min-height: 40px; font-size: 16px; padding: 0 14px; border-radius: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.center { justify-content: center; text-align: center; }
.muted { color: var(--muted); font-size: 15px; }
h3 { font-family: var(--display); font-weight: 400; font-size: 21px; margin: 18px 0 10px; }
p { line-height: 1.6; margin: 8px 0; }

/* tabs */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.tab { flex: none; padding: 8px 18px; border-radius: 16px; background: var(--paper-2); border: 3px solid transparent; font-family: var(--display); font-size: 18px; }
.tab.on { border-color: var(--wood); background: #fff; }

/* shop */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.card { position: relative; background: #fff; border: 3px solid #EEDCC0; border-radius: 22px; padding: 10px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.card .emo { font-size: 52px; line-height: 1.15; height: 64px; display: grid; place-items: center; }
.card .nm { font-size: 16px; font-weight: 600; }
.card .own { position: absolute; top: 6px; left: 8px; font-size: 13px; color: var(--muted); }
.card .tagline { font-size: 12px; color: var(--muted); min-height: 16px; }
.card .deal { position: absolute; top: -8px; right: -6px; background: var(--berry); color: #fff; font-size: 13px; padding: 2px 8px; border-radius: 10px; }
.swatch { width: 54px; height: 54px; border-radius: 14px; border: 4px solid; }
.price { width: 100%; }
.note { background: var(--paper-2); border-radius: 16px; padding: 10px 14px; font-size: 15px; margin-bottom: 12px; }

/* bunny profile */
.prof { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
@media (max-width: 560px) { .prof { grid-template-columns: 1fr; justify-items: center; } }
.prof-portrait { width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle at 50% 70%, #fff 0, #FFF3DA 60%, #F9E2B8 100%); display: grid; place-items: center; overflow: hidden; border: 4px solid #F1DDBC; }
.prof-portrait canvas { width: 92%; }
.prof h2 { font-family: var(--display); font-weight: 400; font-size: 32px; margin: 0; }
.stars { color: #F5B83D; letter-spacing: 2px; font-size: 18px; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 16px; margin: 10px 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.hearts { display: flex; gap: 3px; font-size: 20px; }
.bar { height: 12px; border-radius: 6px; background: #F2E3CB; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #FFA0B6, var(--berry)); border-radius: 6px; transition: width .4s; }
.favs { display: flex; gap: 10px; }
.fav { width: 58px; height: 58px; border-radius: 16px; background: var(--paper-2); display: grid; place-items: center; font-size: 34px; border: 3px dashed #E6CFAA; }
.fav.known { border-style: solid; border-color: #F2D7A5; background: #fff; }
.fav .item-img { display: block; }
.keep-row { display: inline-flex; align-items: center; gap: 6px; }
.keep-row .item-img { display: block; }
.keep-hero { min-height: 120px; display: grid; place-items: center; font-size: 90px; }
.offline-got { display: block; font-size: 22px; margin-top: 4px; }
.quote { font-style: normal; background: var(--paper-2); border-radius: 16px; padding: 8px 14px; display: inline-block; }
.acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 18px; background: #fff; border: 3px solid #EEDCC0; font-size: 15px; font-weight: 600; box-shadow: 0 4px 0 #EEDCC0; }
.act .ico { font-size: 32px; }
.act:active { transform: translateY(3px); box-shadow: 0 1px 0 #EEDCC0; }
.act.done { opacity: .5; }
.act.done::after { content: "✓"; color: var(--clover); font-size: 14px; }

/* mini games */
.mg { position: fixed; inset: 0; z-index: 50; background: radial-gradient(circle at 50% 40%, #FFF8E6 0, #FCE7C1 70%, #F5D69C 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); touch-action: none; animation: fade .2s; }
.mg-title { font-family: var(--display); font-size: 30px; }
.mg-stage { position: relative; width: min(78vw, 60vh, 440px); aspect-ratio: 1; touch-action: none; }
.mg-stage canvas { width: 100%; height: 100%; }
.mg-fx { position: absolute; pointer-events: none; font-size: 34px; animation: rise 1s ease-out forwards; }
@keyframes rise { to { transform: translateY(-80px) scale(1.3); opacity: 0; } }
.mg-brush { position: absolute; font-size: 54px; pointer-events: none; transform: translate(-30%, -70%) rotate(-30deg); }
.mg-foods { display: flex; gap: 20px; }
.food { width: 84px; height: 84px; border-radius: 24px; background: #fff; border: 3px solid var(--wood); font-size: 50px; display: grid; place-items: center; box-shadow: 0 5px 0 var(--wood-dark); touch-action: none; }
.food-drag { position: fixed; z-index: 55; font-size: 58px; pointer-events: none; transform: translate(-50%, -50%); }
.progress { width: min(70vw, 420px); height: 18px; border-radius: 10px; background: #fff; border: 3px solid var(--wood); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #FFD36E, var(--carrot)); transition: width .15s; }
.mg-close { position: absolute; top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r)); }

/* photo */
.viewfinder { position: relative; width: min(86vw, 560px); aspect-ratio: 4/3; border-radius: 18px; overflow: hidden; background: #000; border: 6px solid #fff; box-shadow: 0 8px 0 rgba(0,0,0,.2); }
.viewfinder canvas { width: 100%; height: 100%; display: block; }
.viewfinder::before, .viewfinder::after { content: ""; position: absolute; inset: 14px; border: 3px solid rgba(255,255,255,.75); border-radius: 10px; pointer-events: none;
  clip-path: polygon(0 0, 18% 0, 18% 3px, 3px 3px, 3px 18%, 0 18%, 0 82%, 3px 82%, 3px calc(100% - 3px), 18% calc(100% - 3px), 18% 100%, 82% 100%, 82% calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) 82%, 100% 82%, 100% 18%, calc(100% - 3px) 18%, calc(100% - 3px) 3px, 82% 3px, 82% 0, 100% 0, 100% 100%, 0 100%); }
.flash { position: fixed; inset: 0; background: #fff; z-index: 70; animation: flash .5s ease-out forwards; pointer-events: none; }
@keyframes flash { to { opacity: 0; } }
.shutter { width: 84px; height: 84px; border-radius: 50%; background: #fff; border: 6px solid var(--wood); box-shadow: 0 5px 0 var(--wood-dark); font-size: 36px; }
.polaroid { background: #fff; padding: 10px 10px 30px; border-radius: 6px; box-shadow: 0 6px 16px rgba(0,0,0,.18); text-align: center; font-size: 13px; color: var(--muted); }
.polaroid img { width: 100%; display: block; border-radius: 3px; margin-bottom: 6px; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.album .polaroid:nth-child(odd) { transform: rotate(-2deg); }
.album .polaroid:nth-child(even) { transform: rotate(1.5deg); }

/* dex */
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.dex-card { background: #fff; border: 3px solid #EEDCC0; border-radius: 20px; padding: 6px 4px 8px; text-align: center; font-size: 15px; }
.dex-card img { width: 90px; height: 90px; }
.dex-card.unseen img { filter: brightness(0) opacity(.18); }
.dex-card .lv { font-size: 12px; color: var(--berry); }

/* tasks */
.stamps { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.stamp { aspect-ratio: 1; border-radius: 14px; border: 3px dashed #E6CFAA; display: grid; place-items: center; font-size: 13px; text-align: center; line-height: 1.2; background: #fff; }
.stamp.got { border-style: solid; border-color: var(--berry); background: #FFF0F3; }
.stamp.got::before { content: "🐰"; font-size: 26px; display: block; }
.stamp.today { border-color: var(--carrot); border-style: solid; animation: pulse 1.4s infinite; }
.task { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-bottom: 2px dashed #F1E2C8; }
.task:last-child { border-bottom: 0; }
.task .bar { grid-column: 1; }
.ach { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 2px dashed #F1E2C8; }
.ach .ico { font-size: 30px; text-align: center; }
.ach.locked { opacity: .5; }

/* edit bar */
.editbar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; padding: 10px calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l));
  background: var(--paper); border-top: 4px solid var(--wood); border-radius: 26px 26px 0 0; box-shadow: 0 -4px 0 rgba(107,68,41,.2); animation: up .25s ease; }
@keyframes up { from { transform: translateY(100%); } }
.editbar .top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.editbar .hint { flex: 1; font-size: 16px; }
.inv { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.inv-item { flex: none; width: 82px; height: 92px; border-radius: 18px; background: #fff; border: 3px solid #EEDCC0; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; font-size: 13px; }
.inv-item .emo { font-size: 40px; line-height: 1.1; }
.inv-item .n { position: absolute; top: 2px; right: 6px; font-size: 13px; color: var(--muted); }
.inv-item.on { border-color: var(--carrot); background: #FFF1E4; }
.inv-empty { padding: 18px; color: var(--muted); }

/* welcome */
.welcome-hero { text-align: center; }
.welcome-hero canvas { width: 180px; }
.steps { display: grid; gap: 10px; margin: 14px 0; }
.step { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; background: var(--paper-2); border-radius: 18px; padding: 10px 14px; }
.step .ico { font-size: 34px; text-align: center; }
input.code { font: inherit; font-family: var(--display); font-size: 22px; letter-spacing: 4px; text-transform: uppercase; padding: 8px 12px; border-radius: 14px; border: 3px solid var(--wood); width: 180px; text-align: center; background: #fff; color: var(--ink); }

@media (max-width: 600px) {
  .dock-btn { width: 76px; font-size: 15px; } .dock-btn .ico { font-size: 28px; }
  .res { min-width: 86px; font-size: 19px; height: 40px; }
  .acts { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; } }
