@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url(/fonts/nunito-latin.woff2) format('woff2');
}
:root {
  --cream: #ecd2aa;
  --paper: #fffdf8;
  --dough: #f4d9a8;
  --crust: #c98a45;
  --cocoa: #5a3417;
  --cocoa-soft: #6b4529;
  --berry: #e2556b;
  --mint: #2f9e7e;
  --gold: #ffd35c;
  --line: #e2c49b;
  --shadow: 0 8px 24px rgba(90, 52, 23, .12);
  --radius: 20px;
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; background: #e6c697; }
body { min-height: 100vh; }
body {
  margin: 0; font-family: var(--font); font-weight: 600; color: var(--cocoa); line-height: 1.6;
  background:
    radial-gradient(circle at 15% -5%, rgba(255,230,190,.55) 0, transparent 38%),
    radial-gradient(circle at 100% 0%, rgba(226,150,90,.22) 0, transparent 40%),
    radial-gradient(rgba(122,74,35,.10) 1.2px, transparent 1.6px) 0 0 / 22px 22px,
    linear-gradient(180deg, #efd6b0 0%, #e6c697 100%) fixed;
}
a { color: #b3541e; }
img, svg { max-width: 100%; }
.ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.ico-xs { width: .95em; height: .95em; vertical-align: -0.12em; }
.ico-sm { width: 1.35em; height: 1.35em; vertical-align: -0.3em; }

/* ---------- Header / footer ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 1200px; margin: 0 auto; padding: .8rem 1rem; }
.logo { display: flex; align-items: center; gap: .55rem; font-weight: 900; font-size: 1.5rem; color: var(--cocoa); text-decoration: none; white-space: nowrap; letter-spacing: -.02em; }
.logo-text b { color: #c0582a; font-weight: 900; }
.logo:hover svg { transform: rotate(-12deg) scale(1.06); }
.logo svg { width: 42px; height: 42px; filter: drop-shadow(0 3px 4px rgba(90,52,23,.3)); transition: transform .2s ease; }
.topbar nav { display: flex; gap: .4rem; flex-wrap: wrap; }
.topbar nav a { color: var(--cocoa-soft); text-decoration: none; font-weight: 800; padding: .35rem .8rem; border-radius: 999px; }
.topbar nav a:hover { background: #fff; color: var(--cocoa); box-shadow: 0 2px 8px rgba(90,52,23,.08); }
.site-footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 2rem 1rem; text-align: center; font-size: .9rem; color: var(--cocoa-soft); }
.site-footer nav { display: flex; justify-content: center; gap: 1.25rem; flex-wrap: wrap; margin-bottom: .5rem; }

/* ---------- Game layout ---------- */
.game { display: grid; grid-template-columns: minmax(320px, 5fr) 6fr; gap: 1.1rem; max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Bake area: a warm kitchen wall with a counter shelf */
.bake-area {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--radius); box-shadow: var(--shadow), inset 0 0 0 1px rgba(201,138,69,.25);
  display: flex; flex-direction: column; align-items: center; padding: 1.1rem 1rem 1.25rem; min-height: 580px; text-align: center;
  background:
    radial-gradient(ellipse at 50% 58%, rgba(255,240,205,.95) 0, rgba(255,240,205,0) 55%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(201,138,69,.10) 39px 41px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(201,138,69,.10) 39px 41px),
    linear-gradient(180deg, #fff1d9 0%, #ffe3bb 100%);
}
.bakery-name {
  position: relative; z-index: 2;
  background: rgba(255,255,255,.7); border: 1px solid rgba(201,138,69,.35); border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 1rem; color: var(--cocoa-soft); padding: .2rem .9rem;
}
.bakery-name:hover { background: #fff; color: var(--cocoa); }
.count { position: relative; z-index: 2; font-size: clamp(2.1rem, 5vw, 3rem); font-weight: 900; line-height: 1.05; margin: .55rem 0 .2rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-shadow: 0 2px 0 #fff; }
.count small { display: block; font-size: .95rem; font-weight: 800; color: var(--cocoa-soft); letter-spacing: .02em; text-shadow: none; }
#cookie-count { display: inline-block; }
#cookie-count.tick { animation: tick .18s ease; }
@keyframes tick { 50% { transform: scale(1.06); } }
.rates { position: relative; z-index: 2; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin: .3rem 0 .4rem; }
.rate { display: inline-flex; align-items: center; gap: .3rem; background: rgba(255,255,255,.75); border: 1px solid rgba(201,138,69,.3); border-radius: 999px; padding: .2rem .7rem; font-size: .88rem; color: var(--cocoa-soft); font-variant-numeric: tabular-nums; }
.rate b { color: var(--cocoa); font-weight: 900; }

.cookie-stage { position: relative; width: min(330px, 74vw); aspect-ratio: 1; margin: .6rem auto .2rem; display: grid; place-items: center; z-index: 1; }
.halo { position: absolute; inset: calc(-14% - var(--combo, 0) * 10%); filter: saturate(calc(1 + var(--combo, 0) * 1.5)) brightness(calc(1 + var(--combo, 0) * .25)); border-radius: 50%; background: radial-gradient(circle, rgba(255,214,120,.75) 0, rgba(255,214,120,.25) 45%, transparent 68%); animation: halo 3.2s ease-in-out infinite; z-index: -1; }
@keyframes halo { 50% { transform: scale(1.08); opacity: .8; } }
.steam { position: absolute; top: -6%; left: 50%; width: 60%; height: 40%; transform: translateX(-50%); pointer-events: none; z-index: -1; }
.steam span { position: absolute; bottom: 0; width: 16px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.85); filter: blur(6px); opacity: 0; animation: steam 4.5s ease-in infinite; }
.steam span:nth-child(1) { left: 20%; }
.steam span:nth-child(2) { left: 48%; animation-delay: 1.5s; }
.steam span:nth-child(3) { left: 75%; animation-delay: 3s; }
@keyframes steam { 0% { transform: translateY(20px) scaleX(1); opacity: 0; } 25% { opacity: .7; } 100% { transform: translateY(-70px) scaleX(1.8); opacity: 0; } }

.big-cookie {
  width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none;
  filter: drop-shadow(0 16px 18px rgba(90, 52, 23, .35)); transition: transform .12s ease, filter .12s ease;
}
.big-cookie:hover { transform: scale(1.04) rotate(-2deg); filter: drop-shadow(0 20px 22px rgba(90, 52, 23, .38)); }
.big-cookie:active { transform: scale(.94); }
.big-cookie.bump { animation: squash .18s ease; }
.big-cookie:focus-visible { outline: 4px solid var(--berry); outline-offset: 6px; }
.big-cookie svg { width: 100%; height: 100%; display: block; animation: wobble 8s ease-in-out infinite; }
@keyframes squash { 40% { transform: scale(1.07, .91); } 70% { transform: scale(.96, 1.04); } }
@keyframes wobble { 50% { transform: rotate(6deg); } }

.buffs { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; min-height: 1.9rem; position: relative; z-index: 2; }
.buff { background: linear-gradient(135deg, #ef6b80, var(--berry)); color: #fff; padding: .15rem .7rem; border-radius: 999px; font-weight: 900; font-size: .85rem; box-shadow: 0 3px 10px rgba(226,85,107,.35); }
.rebake { position: relative; z-index: 2; padding: .5rem 0 .3rem; }
.counter-shelf { position: relative; align-self: stretch; margin: .5rem -1rem -1.25rem; padding: 0 .75rem 46px; z-index: 0;
  background: linear-gradient(180deg, #d79a5a 0, #c98a45 10px, #b67a3a 11px, #c98a45 22px, #bd8140 100%) bottom / 100% 56px no-repeat; }
.counter-shelf::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56px; background: repeating-linear-gradient(90deg, transparent 0 90px, rgba(90,52,23,.12) 90px 92px); }
.shelf-items { position: relative; z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: .55rem .5rem; }
.bake-area { justify-content: flex-start; }
.cookie-stage { flex: 0 0 auto; margin-top: auto !important; margin-bottom: auto !important; }
.shelf-item { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.9); box-shadow: 0 3px 0 rgba(90,52,23,.25); animation: popIn .35s ease; }
.shelf-item .ico { width: 34px; height: 34px; }
.shelf-item b { position: absolute; right: -6px; top: -6px; min-width: 20px; padding: 0 4px; border-radius: 999px; background: var(--cocoa); color: #fff; font-size: .68rem; line-height: 18px; }
.shelf-empty { color: var(--cocoa-soft); font-weight: 800; font-size: .85rem; background: rgba(255,255,255,.75); padding: .2rem .8rem; border-radius: 999px; }
@keyframes popIn { from { transform: scale(.3); opacity: 0; } }
#rebake-btn { background: linear-gradient(135deg, #ffe08a, #f2b632); color: var(--cocoa); box-shadow: 0 4px 0 #c98a2e, 0 8px 18px rgba(242,182,50,.35); }
#rebake-btn:disabled { background: rgba(255,255,255,.85); box-shadow: none; color: var(--cocoa-soft); opacity: 1; }

.lucky-star { position: absolute; z-index: 5; width: 68px; height: 68px; border: 0; padding: 0; background: none; cursor: pointer; animation: twinkle 1.2s ease-in-out infinite; filter: drop-shadow(0 0 12px #ffd34d); }
.lucky-star svg { width: 100%; height: 100%; }
@keyframes twinkle { 50% { transform: scale(1.18) rotate(14deg); } }

.audio-ctl { position: absolute; top: .7rem; right: .7rem; z-index: 4; display: flex; gap: .35rem; }
.round-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(201,138,69,.35); background: rgba(255,255,255,.85); cursor: pointer; padding: 7px; display: grid; place-items: center; transition: transform .1s; }
.round-btn:hover { background: #fff; transform: scale(1.06); }
.round-btn .ico { width: 22px; height: 22px; }
.round-btn.off { opacity: .7; }

/* Customer order card */
.order { position: relative; z-index: 3; display: flex; gap: .7rem; align-items: flex-start; width: min(100%, 420px); margin: .5rem auto 0; padding: .7rem .8rem;
  background: #fff; border-radius: 18px; text-align: left; box-shadow: 0 8px 22px rgba(90,52,23,.16), inset 0 0 0 1.5px #f0d9b5; animation: orderIn .35s cubic-bezier(.2,.9,.3,1.3); }
.order::after { content: ""; position: absolute; left: 34px; bottom: -9px; width: 18px; height: 18px; background: #fff; transform: rotate(45deg); box-shadow: 3px 3px 0 0 #f0d9b5; border-radius: 0 0 4px 0; }
@keyframes orderIn { from { transform: translateY(-10px) scale(.92); opacity: 0; } }
.order.order-delivered { background: #f2fbf6; box-shadow: 0 8px 22px rgba(47,158,126,.18), inset 0 0 0 1.5px #a8dcc3; }
.order.order-delivered::after { background: #f2fbf6; box-shadow: 3px 3px 0 0 #a8dcc3; }
.order.urgent { box-shadow: 0 8px 22px rgba(226,85,107,.25), inset 0 0 0 2px var(--berry); }
.order.urgent .o-time { color: var(--berry); }
.o-face { width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%; background: #fff3df; display: grid; place-items: center; overflow: hidden; }
.o-face .ico { width: 48px; height: 48px; margin-top: 6px; }
.o-body { flex: 1; min-width: 0; }
.o-name { margin: 0; font-weight: 900; line-height: 1.2; }
.o-name span { font-weight: 700; color: var(--cocoa-soft); font-size: .85rem; margin-left: .3rem; }
.o-text { margin: .15rem 0 .3rem; font-size: .95rem; line-height: 1.35; }
.o-meta { margin: 0; display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .85rem; color: var(--cocoa-soft); font-variant-numeric: tabular-nums; }
.o-meta b { color: var(--cocoa); }
.o-bar { height: 10px; border-radius: 999px; background: #f3e7d4; overflow: hidden; margin: .1rem 0 .3rem; }
.o-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7ec8a0, #2f9e7e); transition: width .2s ease; }
.o-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.o-actions .btn { padding: .45rem .85rem; font-size: .88rem; }
.o-wait { font-size: .78rem; color: var(--cocoa-soft); margin-left: auto; }
.ad-mini { display: inline-flex; align-items: center; gap: .35rem; background: linear-gradient(135deg, #ffe08a, #ffb340); color: var(--cocoa); box-shadow: 0 3px 0 #d18a1f; }

/* ---------- Shop ---------- */
.shop { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); display: flex; flex-direction: column; min-height: 580px; max-height: 82vh; overflow: hidden; }
.tabs { display: flex; gap: .25rem; padding: .45rem; background: #fff3df; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; background: none; border: 0; border-radius: 12px;
  padding: .55rem .4rem; font: inherit; font-size: .92rem; font-weight: 800; color: var(--cocoa-soft); cursor: pointer; white-space: nowrap;
}
.tabs button:hover { background: rgba(255,255,255,.7); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--cocoa); box-shadow: 0 2px 8px rgba(90,52,23,.12); }
.badge { display: inline-block; min-width: 1.4em; background: var(--berry); color: #fff; border-radius: 999px; font-size: .72rem; line-height: 1.4em; padding: 0 .35em; }
.badge:empty { display: none; }
.tab-panel { overflow-y: auto; padding: .8rem; flex: 1; }
.buy-amount { display: flex; gap: .35rem; align-items: center; margin-bottom: .7rem; font-weight: 800; font-size: .9rem; }
.buy-amount button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: .25rem .7rem; font: inherit; font-weight: 900; cursor: pointer; color: var(--cocoa); }
.buy-amount button.active { background: var(--cocoa); color: #fff; border-color: var(--cocoa); }

.building, .upgrade {
  position: relative; display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left; font: inherit; color: inherit;
  background: #fff; border: 1.5px solid var(--line); border-radius: 16px; padding: .65rem .8rem; margin-bottom: .55rem;
  cursor: pointer; opacity: .62; transition: transform .1s, opacity .2s, border-color .2s, box-shadow .2s;
}
.building.affordable, .upgrade.affordable { opacity: 1; border-color: #7ec8a0; box-shadow: 0 0 0 3px rgba(126,200,160,.18), 0 4px 12px rgba(47,158,126,.10); }
.building.affordable:hover, .upgrade.affordable:hover { transform: translateY(-2px); box-shadow: 0 0 0 3px rgba(126,200,160,.28), 0 8px 18px rgba(47,158,126,.16); }
.building.affordable:active, .upgrade.affordable:active { transform: scale(.98); }
.building.mystery { cursor: default; opacity: .45; border-style: dashed; }
.b-icon, .u-icon { width: 3.1rem; height: 3.1rem; flex-shrink: 0; display: grid; place-items: center; border-radius: 14px; background: #fff3df; overflow: hidden; }
.b-icon .ico, .u-icon .ico { width: 2.4rem; height: 2.4rem; }
.b-main, .u-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.b-top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.b-name, .u-name { font-weight: 900; }
.b-desc, .u-desc { font-size: .8rem; color: var(--cocoa-soft); line-height: 1.35; }
.b-cost, .u-cost { font-weight: 900; font-size: .9rem; color: var(--mint); white-space: nowrap; }
.building:not(.affordable) .b-cost, .upgrade:not(.affordable) .u-cost { color: var(--berry); }
.b-progress { display: block; height: 6px; border-radius: 999px; background: #f3e7d4; overflow: hidden; margin-top: .25rem; }
.b-progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #f2c14e, #e98c3b); transition: width .3s ease; }
.b-owned { font-size: 1.9rem; font-weight: 900; color: var(--dough); -webkit-text-stroke: 1.2px var(--crust); min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--cocoa-soft); text-align: center; padding: 2rem 1rem; }

.ach-head p { margin: 0 0 .5rem; }
.ach-head small { color: var(--cocoa-soft); }
.ach.secret.got { border-color: #c9a7f0; background: linear-gradient(135deg, #fbf7ff, #f1e8ff); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; }
.ach { display: flex; gap: .6rem; align-items: center; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: .5rem .6rem; opacity: .55; }
.ach.got { opacity: 1; border-color: #f0c36a; background: linear-gradient(135deg, #fffaf0, #fff3d6); }
.ach strong { display: block; font-size: .9rem; font-weight: 900; }
.ach small { display: block; font-size: .75rem; color: var(--cocoa-soft); line-height: 1.3; }
.a-icon { width: 2.3rem; height: 2.3rem; flex-shrink: 0; display: grid; place-items: center; }
.a-icon .ico { width: 2rem; height: 2rem; }

.stats-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.stats-table th, .stats-table td { padding: .45rem .3rem; border-bottom: 1px solid var(--line); text-align: left; font-weight: 700; }
.stats-table td { text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; }
.options { margin-top: 1rem; display: grid; gap: .6rem; }
.options label { display: flex; gap: .5rem; align-items: center; font-weight: 800; }
.options select { font: inherit; font-weight: 800; color: var(--cocoa); border: 1px solid var(--line); border-radius: 10px; padding: .3rem .6rem; background: #fff; cursor: pointer; }
.options textarea { width: 100%; min-height: 70px; font-family: monospace; font-size: .75rem; border: 1px solid var(--line); border-radius: 10px; padding: .5rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn { border: 0; border-radius: 12px; padding: .6rem 1.1rem; font: inherit; font-weight: 900; cursor: pointer; background: var(--dough); color: var(--cocoa); transition: transform .1s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--cocoa); color: #fff; box-shadow: 0 3px 0 #3a1f0d; }
.btn.danger { background: #fde2e2; color: #a12b2b; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---------- Effects ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.float-num { position: fixed; transform: translate(-50%, -50%); font-weight: 900; font-size: 1.5rem; color: #fff; -webkit-text-stroke: 1px var(--cocoa); paint-order: stroke fill; text-shadow: 0 3px 0 var(--cocoa); animation: floatUp .9s ease-out forwards; }
@keyframes floatUp { 0% { transform: translate(-50%, -50%) scale(.7); } 20% { transform: translate(-50%, -70%) scale(1.1); } 100% { transform: translate(-50%, -190%) scale(1); opacity: 0; } }
.crumb { position: fixed; width: 8px; height: 7px; border-radius: 40%; background: var(--crust); animation: crumbFly .7s ease-out forwards; }
@keyframes crumbFly { to { transform: translate(var(--dx), var(--dy)) rotate(200deg); opacity: 0; } }
.confetti { position: fixed; width: 9px; height: 14px; border-radius: 2px; animation: confetti 1.3s cubic-bezier(.2,.7,.4,1) forwards; }
@keyframes confetti { to { transform: translate(var(--dx), calc(var(--dy) + 160px)) rotate(var(--rot)); opacity: 0; } }
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: .4rem; align-items: center; width: min(92vw, 420px); }
.toast { background: var(--cocoa); color: #fff; padding: .6rem 1.1rem; border-radius: 14px; font-weight: 800; box-shadow: 0 10px 30px rgba(58,31,13,.35); transition: opacity .4s, transform .4s; text-align: center; animation: toastIn .3s ease; }
@keyframes toastIn { from { transform: translateY(12px) scale(.96); opacity: 0; } }
.toast.out { opacity: 0; transform: translateY(8px); }

dialog { border: 0; border-radius: 22px; padding: 1.6rem; max-width: min(92vw, 420px); text-align: center; color: var(--cocoa); box-shadow: 0 24px 70px rgba(0,0,0,.3); background: linear-gradient(180deg, #fffdf8, #fff3df); }
dialog::backdrop { background: rgba(60, 35, 15, .5); backdrop-filter: blur(2px); }
dialog h2 { margin-top: 0; font-weight: 900; }
.big-gain { font-size: 2rem; font-weight: 900; margin: .25rem 0; }
.muted { color: var(--cocoa-soft); font-size: .85rem; }
#modal-actions { display: flex; gap: .5rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }

/* ---------- Ads ---------- */
.ad-slot { max-width: 1200px; margin: 1.25rem auto; padding: 0 1rem; }
.content .ad-slot { padding: 0; }
.ad-slot:empty { display: none; }
.ad-slot.filled { min-height: 120px; }
.ad-slot.filled::before { content: "Advertisement"; display: block; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--cocoa-soft); text-align: center; margin-bottom: .25rem; }
.mock-banner { border: 2px dashed var(--crust); border-radius: 12px; min-height: 100px; display: grid; place-items: center; font-weight: 800; color: var(--cocoa-soft); background: #fff; }
.mock-ad { position: fixed; inset: 0; z-index: 100; background: rgba(20, 12, 5, .88); display: grid; place-items: center; color: #fff; text-align: center; }
.mock-ad > div { background: #2b1a0c; padding: 2rem 2.5rem; border-radius: 16px; }
.mock-ad .mock-count { font-size: 2.5rem; font-weight: 900; margin: .5rem 0; }
.mock-ad button { font: inherit; font-weight: 800; border: 0; border-radius: 10px; padding: .5rem 1rem; cursor: pointer; }
.ad-boost {
  position: relative; z-index: 2; display: inline-flex; align-items: center; gap: .45rem; margin-top: .3rem; font-size: .9rem;
  background: linear-gradient(135deg, #ffe08a, #ffb340); color: var(--cocoa); box-shadow: 0 4px 0 #d18a1f, 0 8px 18px rgba(255,170,40,.4);
  animation: offerPulse 2s ease-in-out infinite;
}
@keyframes offerPulse { 50% { transform: scale(1.04); } }

/* ---------- Content pages ---------- */
.content { max-width: 820px; margin: 2.5rem auto 0; padding: 0 1rem; }
.content h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); line-height: 1.2; font-weight: 900; letter-spacing: -.01em; }
.content h2 { margin-top: 2.2rem; font-size: 1.5rem; font-weight: 900; border-bottom: 2px solid var(--line); padding-bottom: .3rem; }
.content h3 { margin-top: 1.5rem; font-weight: 900; }
.content table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .95rem; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.content th, .content td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; }
.content thead th { background: var(--dough); font-weight: 900; }
.content .tip { background: #fff; border-left: 4px solid var(--crust); padding: .75rem 1rem; border-radius: 0 14px 14px 0; }
.content details { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .75rem 1rem; margin: .5rem 0; }
.content summary { font-weight: 900; cursor: pointer; }
.table-wrap { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) {
  .big-cookie svg, .halo, .steam span, .lucky-star, .ad-boost { animation: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .game { grid-template-columns: minmax(0, 1fr); }
  .bake-area { min-height: 0; padding-bottom: 1rem; }
  .cookie-stage { width: min(260px, 66vw); }
  .shop { max-height: none; min-height: 0; overflow: visible; }
  .tabs { position: sticky; top: 0; z-index: 10; border-radius: var(--radius) var(--radius) 0 0; }
  .tabs button { padding: .55rem .4rem; font-size: .88rem; }
  .tab-panel { max-height: 70vh; }
}
@media (max-width: 1100px) and (min-width: 821px) {
  .tabs button .ico-sm { display: none; }
}
@media (max-width: 480px) {
  .topbar nav a:not(:first-child) { display: none; }
  .tabs button .ico-sm { display: none; }
  .b-icon, .u-icon { width: 2.7rem; height: 2.7rem; }
  .b-icon .ico, .u-icon .ico { width: 2.1rem; height: 2.1rem; }
  .shelf-item { width: 38px; height: 38px; }
  .shelf-item .ico { width: 29px; height: 29px; }
}

/* ---------- Combo meter ---------- */
.combo { position: absolute; top: 4%; right: -4%; z-index: 3; display: flex; flex-direction: column; align-items: center; padding: .35rem .7rem; border-radius: 14px;
  background: #fff; box-shadow: 0 6px 16px rgba(90,52,23,.2); transform: rotate(6deg); animation: comboIn .2s ease; pointer-events: none; }
.combo .c-num { font-weight: 900; font-size: 1.4rem; line-height: 1; color: var(--cocoa); }
.combo .c-bonus { font-size: .68rem; font-weight: 800; color: var(--cocoa-soft); }
.combo .c-bar { width: 64px; height: 5px; border-radius: 999px; background: #f3e7d4; overflow: hidden; margin-top: .2rem; }
.combo .c-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb340, #e2556b); }
.combo.hot { background: linear-gradient(135deg, #fff1c9, #ffd9a0); animation: comboHot .5s ease-in-out infinite alternate; }
.combo.hot .c-num { color: #c2410c; }
@keyframes comboIn { from { transform: rotate(6deg) scale(.5); opacity: 0; } }
@keyframes comboHot { to { transform: rotate(-3deg) scale(1.08); } }

/* ---------- Daily gift ---------- */
.daily-btn { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: .4rem; margin-top: .4rem; font-size: .9rem;
  background: linear-gradient(135deg, #ff8fa3, #e2556b); color: #fff; box-shadow: 0 4px 0 #b83a50, 0 8px 18px rgba(226,85,107,.35); animation: giftWiggle 2.4s ease-in-out infinite; }
@keyframes giftWiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-4deg) scale(1.05); } 90% { transform: rotate(4deg) scale(1.05); } 95% { transform: rotate(-2deg); } }
.streak { display: flex; justify-content: center; gap: .35rem; margin: .5rem 0; }
.streak .day { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 900; background: #f3e7d4; color: var(--cocoa-soft); }
.streak .day.done { background: linear-gradient(135deg, #ffe08a, #f2b632); color: var(--cocoa); box-shadow: 0 3px 0 #c98a2e; }

/* ---------- Legacy ---------- */
.legacy-head { margin: 0 0 .4rem; font-size: .88rem; color: var(--cocoa-soft); }
.legacy-crumbs { margin: 0 0 .7rem; font-weight: 800; }
.legacy-item.owned { opacity: 1; border-color: #f0c36a; background: linear-gradient(135deg, #fffaf0, #fff3d6); cursor: default; }
.legacy-item.owned .u-cost { color: #b9770e; }
.legacy-item.locked { opacity: .45; cursor: default; }
.legacy-item .u-cost { color: #b9770e; }

/* ---------- Purchase feedback ---------- */
.building.bought { animation: boughtFlash .45s ease; }
@keyframes boughtFlash { 0% { background: #d8f5e7; transform: scale(1.02); } 100% { background: #fff; transform: scale(1); } }
.shelf-item.bump { animation: shelfBump .45s cubic-bezier(.3,1.6,.5,1) !important; }
@keyframes shelfBump { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-14px) scale(1.2); } 100% { transform: translateY(0) scale(1); } }

/* ---------- Buff visuals ---------- */
.bake-area::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .5s; z-index: 0; }
.bake-area.fx-rush::after { opacity: 1; background: radial-gradient(circle at 50% 50%, rgba(255,214,90,.45), rgba(255,200,60,.15) 60%, transparent 80%); box-shadow: inset 0 0 0 4px rgba(255,190,50,.7); animation: rushPulse 1.2s ease-in-out infinite; }
.bake-area.fx-fever::after { opacity: 1; background: radial-gradient(circle at 50% 50%, rgba(255,120,80,.35), transparent 70%); box-shadow: inset 0 0 0 4px rgba(226,85,107,.75); animation: rushPulse .6s ease-in-out infinite; }
@keyframes rushPulse { 50% { filter: brightness(1.15); } }
.sprinkle { position: absolute; top: -12px; width: 5px; height: 13px; border-radius: 3px; z-index: 1; pointer-events: none; transform: rotate(var(--rot)); animation: sprinkleFall 2.6s linear forwards; }
@keyframes sprinkleFall { to { transform: translateY(640px) rotate(calc(var(--rot) + 540deg)); opacity: .2; } }

/* ---------- Achievement popup ---------- */
.ach-pop { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: .4rem; pointer-events: none; width: min(92vw, 360px); }
.ach-card { display: flex; gap: .7rem; align-items: center; padding: .65rem .9rem; border-radius: 16px; background: linear-gradient(135deg, #fffaf0, #ffeec2);
  box-shadow: 0 12px 30px rgba(90,52,23,.3), inset 0 0 0 2px #f0c36a; animation: achIn .45s cubic-bezier(.2,1.4,.4,1); transition: transform .35s, opacity .35s; }
.ach-card.secret { background: linear-gradient(135deg, #fbf7ff, #ecdcff); box-shadow: 0 12px 30px rgba(90,52,23,.3), inset 0 0 0 2px #c9a7f0; }
.ach-card .a-icon { width: 2.8rem; height: 2.8rem; }
.ach-card .a-icon .ico { width: 2.5rem; height: 2.5rem; animation: achSpin .8s ease; }
.ach-card small { display: block; font-size: .72rem; font-weight: 800; color: #b9770e; text-transform: uppercase; letter-spacing: .04em; }
.ach-card strong { display: block; font-weight: 900; font-size: 1.02rem; line-height: 1.2; }
.ach-card em { display: block; font-style: normal; font-size: .78rem; color: var(--cocoa-soft); font-weight: 700; }
.ach-card.out { transform: translateY(-120%); opacity: 0; }
@keyframes achIn { from { transform: translateY(-120%) scale(.9); opacity: 0; } }
@keyframes achSpin { from { transform: rotate(-30deg) scale(.4); } }

/* ---------- Celebration banner ---------- */
.banner { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; pointer-events: none; }
.banner.show::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255,236,180,.75), rgba(255,236,180,0) 65%); animation: flash 1.2s ease forwards; }
.banner-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: .2rem; text-align: center; padding: 1.1rem 1.8rem; border-radius: 24px;
  background: linear-gradient(135deg, #fffdf8, #ffe9b8); box-shadow: 0 20px 60px rgba(90,52,23,.35), inset 0 0 0 3px #f0c36a; animation: bannerIn 2.9s cubic-bezier(.2,1.3,.4,1) forwards; max-width: min(90vw, 460px); }
.banner-card .ico { width: 56px; height: 56px; }
.banner-card strong { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 900; line-height: 1.15; }
.banner-card span { font-weight: 700; color: var(--cocoa-soft); font-size: .95rem; }
@keyframes bannerIn { 0% { transform: scale(.3); opacity: 0; } 12% { transform: scale(1.08); opacity: 1; } 18% { transform: scale(1); } 85% { transform: scale(1); opacity: 1; } 100% { transform: scale(.9) translateY(-20px); opacity: 0; } }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .daily-btn, .combo.hot, .bake-area.fx-rush::after, .bake-area.fx-fever::after { animation: none; }
  .sprinkle { display: none; }
}

/* ---------- Coming soon ---------- */
.upcoming-title { margin: 1rem 0 .5rem; font-size: .95rem; font-weight: 900; color: var(--cocoa-soft); text-transform: uppercase; letter-spacing: .05em; }
.upgrade.upcoming { cursor: default; opacity: .7; border-style: dashed; background: #fffdf8; }
.upgrade.upcoming .u-icon { filter: grayscale(.6); }
.upgrade.upcoming .u-cost { color: var(--cocoa-soft) !important; }

/* ---------- Missions ---------- */
.mission { display: flex; align-items: center; gap: .8rem; background: #fff; border: 1.5px solid var(--line); border-radius: 16px; padding: .7rem .8rem; margin-bottom: .55rem; }
.mission .u-main { gap: .25rem; }
.mission.ready { border-color: #7ec8a0; box-shadow: 0 0 0 3px rgba(126,200,160,.2); animation: readyPulse 1.6s ease-in-out infinite; }
.mission.claimed { opacity: .6; }
.mission .b-progress { height: 8px; }
.mission.ready .b-progress i, .mission.claimed .b-progress i { background: linear-gradient(90deg, #7ec8a0, #2f9e7e); }
.m-actions .btn { padding: .45rem .8rem; font-size: .88rem; }
.m-done { color: var(--mint); white-space: nowrap; }
@keyframes readyPulse { 50% { box-shadow: 0 0 0 6px rgba(126,200,160,.12); } }
.mission-chest { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 16px; border: 1.5px dashed #f0c36a; background: #fffaf0; }
.mission-chest .ico { width: 2.6rem; height: 2.6rem; }
.mission-chest strong { display: block; font-weight: 900; }
.mission-chest small { display: block; color: var(--cocoa-soft); font-size: .8rem; }
.mission-chest.open { border-style: solid; background: linear-gradient(135deg, #fffaf0, #ffeec2); }

/* ---------- Skins ---------- */
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .5rem; margin: .8rem 0; max-height: 52vh; overflow-y: auto; padding: 2px; }
.skin { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .5rem .3rem; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font: inherit; color: inherit; }
.skin > svg { width: 64px; height: 64px; animation: none !important; filter: drop-shadow(0 4px 5px rgba(90,52,23,.25)); }
.skin:not(.owned) > svg { filter: grayscale(.2) drop-shadow(0 4px 5px rgba(90,52,23,.25)); opacity: .85; }
.skin strong { font-size: .78rem; font-weight: 900; line-height: 1.2; text-align: center; }
.skin.equipped { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(126,200,160,.3); }
.skin:hover { transform: translateY(-2px); }
.sk-eq { color: var(--mint); font-size: .72rem; }
.sk-tag { font-size: .72rem; font-weight: 800; color: var(--cocoa-soft); }
.sk-cost { font-size: .78rem; font-weight: 900; color: var(--berry); }
.sk-cost.ok { color: var(--mint); }
.sk-need { font-size: .66rem; line-height: 1.25; color: var(--cocoa-soft); text-align: center; }
dialog:has(.skin-grid) { width: min(94vw, 560px); max-width: none; }
.skin .ico-xs { width: .95em; height: .95em; }

/* ---------- Install app ---------- */
.install-btn { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .8rem; font-size: .88rem; background: #fff; color: var(--cocoa); box-shadow: 0 2px 8px rgba(90,52,23,.12); }
.install-btn .ico-sm { width: 1.2em; height: 1.2em; }

/* ---------- Embedded game ---------- */
.embed-wrap { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.embed-frame { position: relative; width: 100%; height: clamp(520px, 78vh, 820px); border-radius: var(--radius); overflow: hidden; background: #1b120b; box-shadow: var(--shadow), inset 0 0 0 1px rgba(201,138,69,.25); }
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.embed-frame:fullscreen { border-radius: 0; height: 100%; }
.embed-bar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .6rem; color: var(--cocoa-soft); font-size: .9rem; }
.embed-bar .btn { padding: .45rem .9rem; font-size: .9rem; }
@media (max-width: 820px) { .embed-frame { height: clamp(460px, 72vh, 720px); } }

/* Darker page: keep content blocks readable */
.topbar nav a:hover { background: rgba(255,255,255,.7); }
.site-footer { border-top-color: rgba(90,52,23,.2); }
.content table, .content details, .content .tip { background: #fffaf2; }

/* ---------- Breadcrumb, byline, table of contents, author box ---------- */
.breadcrumb { font-size: .88rem; color: var(--cocoa-soft); margin-bottom: .5rem; }
.breadcrumb a { color: var(--cocoa-soft); }
.byline { margin-top: -.4rem; font-size: .9rem; color: var(--cocoa-soft); }
.byline a { color: inherit; }
.toc { background: #fffaf2; border: 1px solid var(--line); border-radius: 14px; padding: .8rem 1.1rem; margin: 1.2rem 0; }
.toc ol { margin: .4rem 0 0; padding-left: 1.3rem; columns: 2; column-gap: 2rem; }
.toc li { margin: .15rem 0; }
@media (max-width: 560px) { .toc ol { columns: 1; } }
.author-box { display: flex; gap: 1rem; align-items: flex-start; margin-top: 2.5rem; padding: 1rem 1.1rem; background: #fffaf2; border: 1px solid var(--line); border-radius: 16px; }
.author-box svg, .author-box img { width: 56px; height: 56px; flex-shrink: 0; }
.author-box p { margin: .25rem 0 0; font-size: .92rem; }

.guide-links { list-style: none; padding: 0; }
.guide-links li { margin: .5rem 0; }
.guide-links a { display: block; padding: .8rem 1rem; background: #fffaf2; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--cocoa); }
.guide-links a:hover { border-color: var(--crust); box-shadow: 0 4px 12px rgba(90,52,23,.12); }
.guide-links strong { color: #b3541e; }

.logo-img { width: 44px; height: 44px; display: block; transition: transform .2s ease; }
.logo:hover .logo-img { transform: rotate(-12deg) scale(1.06); }
