:root{
  --ink:#2c2418; --cream:#f7f1e3; --paper:#f1e8d6; --red:#a3331f; --mustard:#d9a63c; --green:#4e6b35;
  --ledgerH:clamp(52px,10dvh,92px);
  --stageW:min(100vw, max(62dvh, 480px));
  --trayH:clamp(96px, min(calc(var(--stageW) / 2.08), 24dvh), 240px);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;background:#1b2016;font-family:'Bitter',Georgia,serif;color:var(--ink);
  -webkit-user-select:none;user-select:none;touch-action:manipulation}
body::before{content:"";position:fixed;inset:-30px;background:url(assets/farm_backdrop.webp) center/cover no-repeat;
  filter:blur(16px) brightness(.55) saturate(.9);opacity:.9;pointer-events:none}
@media (max-width: 699px){body::before{filter:none;background:#26301f}}
#stage{position:fixed;top:0;bottom:0;left:50%;width:var(--stageW);transform:translateX(-50%);overflow:hidden;background:#71894e;
  box-shadow:0 0 0 1px rgba(0,0,0,.45),0 26px 90px rgba(0,0,0,.6)}
#game{position:absolute;inset:0}
#game canvas{display:block}
.hidden{display:none!important}

/* cinematic grade over the whole frame: soft vignette, fine grain */
#paper{position:absolute;inset:0;pointer-events:none;z-index:50;opacity:.72;
  background-image:radial-gradient(ellipse at 50% 44%,transparent 48%,rgba(18,22,14,.34) 100%),
    radial-gradient(rgba(255,255,255,.05) .6px,transparent .9px);
  background-size:100% 100%,3px 3px;background-position:0 0,0 0;mix-blend-mode:multiply}
#paper::after{content:"";position:absolute;inset:0;background:radial-gradient(ellipse at 50% 42%,rgba(255,232,180,.09),transparent 62%)}

/* ledger: a weathered oak board with brass fittings */
#ledger{position:absolute;top:0;left:0;right:0;height:var(--ledgerH);z-index:20;display:flex;align-items:center;
  background:url(assets/ledger_strip.webp) center/100% 100% no-repeat;padding:0 5.5%;
  filter:drop-shadow(0 3px 6px rgba(0,0,0,.28))}
#ledger .cell{height:62%;display:flex;align-items:center;justify-content:center;position:relative}
#ledger .cash{flex:1.35;min-width:0;justify-content:flex-start;gap:6px}
#ledger .day{flex:1.2;min-width:0;border-left:1px solid rgba(247,241,227,.22);border-right:1px solid rgba(247,241,227,.22);gap:6px;
  color:var(--cream);font-weight:700;font-size:clamp(11px,min(calc(var(--ledgerH)*.24),3.6vw),20px);white-space:nowrap;
  text-shadow:0 1px 2px rgba(0,0,0,.7)}
#ledger .lvl{flex:.75;gap:4px;flex-direction:column}
.coin{height:78%;aspect-ratio:1;object-fit:contain;filter:drop-shadow(0 1px 2px rgba(0,0,0,.5))}
.odo{font-family:'Rokkitt',serif;font-weight:800;font-size:clamp(16px,min(calc(var(--ledgerH)*.42),7.2vw),38px);line-height:1;display:inline-flex;
  height:1em;overflow:hidden;color:#fff6dc;text-shadow:0 1px 3px rgba(0,0,0,.75)}
.odo .d{display:inline-block;height:1em;overflow:hidden;position:relative;width:.5em;text-align:center}
.odo .d.comma{width:.25em}
.odo .d i{display:block;font-style:normal;transition:transform .45s cubic-bezier(.3,1.4,.5,1)}
.odo .d i b{display:block;height:1em;line-height:1em;font-weight:800}
.stampfx{position:absolute;left:28%;top:-4%;font-family:'Rokkitt',serif;font-weight:800;color:#ffe8b0;font-size:clamp(14px,calc(var(--ledgerH)*.3),26px);
  border:1px solid rgba(255,232,176,.65);border-radius:4px;padding:0 4px;background:rgba(30,24,16,.72);opacity:0;pointer-events:none;transform:rotate(-6deg);
  text-shadow:0 1px 2px rgba(0,0,0,.6)}
.stampfx.go{animation:stamp 1.2s ease-out forwards}
.stampfx.neg{color:#f4c9c0;border-color:rgba(244,201,192,.6)}
@keyframes stamp{0%{opacity:0;transform:translateY(8px) rotate(-6deg) scale(1.5)}12%{opacity:1;transform:translateY(0) rotate(-6deg) scale(.95)}
  20%{transform:rotate(-6deg) scale(1)}70%{opacity:1}100%{opacity:0;transform:translateY(-14px) rotate(-6deg)}}
.clock{width:1em;height:1em;border:2px solid rgba(247,241,227,.85);border-radius:50%;position:relative;background:rgba(28,24,18,.6);flex:none}
.clock i{position:absolute;left:50%;top:10%;width:2px;height:40%;background:#e6b45a;transform-origin:50% 100%;margin-left:-1px}
.star{position:relative;height:calc(var(--ledgerH)*.42);aspect-ratio:1;display:flex;align-items:center;justify-content:center}
.star img{position:absolute;inset:0;width:100%;height:100%;filter:drop-shadow(0 1px 2px rgba(0,0,0,.5))}
.star b{position:relative;font-family:'Rokkitt',serif;font-weight:800;font-size:calc(var(--ledgerH)*.22);margin-top:6%;color:#fff6dd;text-shadow:0 1px 2px rgba(0,0,0,.95),0 0 4px rgba(0,0,0,.7)}
.xp{width:70%;height:5px;border:1px solid rgba(247,241,227,.45);border-radius:3px;background:rgba(20,18,14,.55);overflow:hidden}
.xp i{display:block;height:100%;width:0;background:linear-gradient(90deg,#b5883b,#e6c477);transition:width .4s}
#lvlCell.pulse .star{animation:pulse .9s ease}
@keyframes pulse{30%{transform:scale(1.5) rotate(-12deg)}}

#gear{position:absolute;right:8px;top:calc(var(--ledgerH) + 6px);width:clamp(38px,9vw,48px);height:clamp(38px,9vw,48px);z-index:19;padding:0;border:0;background:none;
  filter:drop-shadow(0 3px 5px rgba(0,0,0,.45))}
#gear img{width:100%;height:100%}

/* tool tray: a real wooden crate resting at the bottom */
#tray{position:absolute;left:0;right:0;bottom:0;height:var(--trayH);z-index:20;background:url(assets/tool_tray.webp) center/100% 100% no-repeat;
  filter:drop-shadow(0 -4px 10px rgba(0,0,0,.35))}
#tools{position:absolute;left:8.5%;right:7%;top:5%;height:55%;display:flex;align-items:center;justify-content:space-between;gap:1%}
.tool{flex:1;height:100%;padding:0;border:0;background:none;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;
  transition:transform .15s;font:inherit;color:var(--cream)}
.tool{container-type:size}
.tool img{width:min(100cqw,76cqh);height:min(100cqw,76cqh);flex:none;object-fit:contain;border-radius:50%;transition:box-shadow .15s,filter .15s;
  filter:drop-shadow(0 2px 3px rgba(0,0,0,.45))}
.tool span{font-size:clamp(9px,calc(var(--trayH)*.075),15px);font-weight:800;line-height:1;margin-top:2px;color:#f8f1e2;background:rgba(28,23,16,.72);
  padding:2px 5px 3px;border:1px solid rgba(247,241,227,.18);border-radius:4px;letter-spacing:.02em;text-shadow:0 1px 1px rgba(0,0,0,.6)}
.tool.on{transform:translateY(-5px)}
.tool.on img{box-shadow:0 0 0 2px rgba(217,166,60,.95),0 0 16px rgba(230,180,90,.55)}
.tool em{position:absolute;right:2%;top:0;font-style:normal;font-family:'Rokkitt',serif;font-weight:800;font-size:12px;color:#fff6e2;background:linear-gradient(#b8402a,#8f2816);
  border:1px solid rgba(255,236,200,.5);border-radius:9px;min-width:18px;height:18px;line-height:16px;text-align:center;padding:0 3px}
#hint{position:absolute;left:14%;right:4%;top:59.5%;height:18.5%;display:flex;align-items:center;justify-content:center;text-align:center;
  font-size:clamp(10px,calc(var(--trayH)*.085),17px);font-weight:700;line-height:1.15;padding:0 2%;overflow:hidden;color:#fbf3e1;text-shadow:0 1px 3px rgba(0,0,0,.8)}
#hint b{color:#f0c35f}

/* presses feel like real buttons, not ink stamps */
.stampbtn{cursor:pointer;-webkit-appearance:none;appearance:none}
.stampbtn:active{transform:scale(.94,.9)!important}
.stampbtn.bleed img,.stampbtn.bleed{filter:brightness(1.18) drop-shadow(0 2px 4px rgba(0,0,0,.5))}

/* seed bar: a slim dark shelf holding seed packets */
#seedbar{position:absolute;left:4px;right:4px;bottom:calc(var(--trayH) - 4px);z-index:21;display:flex;gap:7px;overflow-x:auto;padding:5px 6px 7px;
  background:linear-gradient(180deg,rgba(38,31,22,.93),rgba(24,20,14,.95));border:1px solid rgba(230,196,130,.35);border-radius:9px 9px 0 0;
  box-shadow:0 -6px 18px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,244,215,.12);scrollbar-width:none}
#seedbar::-webkit-scrollbar{display:none}
.seed{flex:none;width:50px;height:50px;border:1px solid rgba(247,241,227,.22);border-radius:7px;background:rgba(246,239,224,.1);position:relative;padding:2px;font:inherit;color:var(--cream)}
.seed img{width:100%;height:100%;object-fit:cover;border-radius:5px;filter:drop-shadow(0 1px 2px rgba(0,0,0,.55))}
.seed b{position:absolute;right:-4px;bottom:-5px;font-family:'Rokkitt',serif;font-weight:800;font-size:14px;color:#2c2418;background:#f6eddc;border:1px solid rgba(44,36,24,.5);
  border-radius:8px;padding:0 4px;line-height:15px;text-shadow:none}
.seed.on{box-shadow:0 0 0 2px #d9a63c,0 0 12px rgba(217,166,60,.4);background:rgba(217,166,60,.22)}
.seed.zero{opacity:.45}
.seed.more{width:auto;padding:0 10px;font-weight:800;color:#eac873;font-size:13px;line-height:1.1}

/* catalogue: clean cream card stock, no ruled notebook */
#sheet{position:absolute;left:0;right:0;bottom:0;height:84%;z-index:40;transform:translateY(105%);transition:transform .38s cubic-bezier(.2,.9,.3,1);
  background-color:#efe3cc;
  background-image:linear-gradient(180deg,rgba(251,246,234,.9),rgba(239,227,204,.93) 70%,rgba(233,220,194,.95)),url(assets/paper_real.webp);
  background-size:100% 100%,420px 420px;background-repeat:no-repeat,repeat;
  border-top:1px solid rgba(80,60,35,.35);box-shadow:0 -10px 40px rgba(0,0,0,.45),inset 0 1px 0 rgba(255,255,255,.7);display:flex;flex-direction:column}
#sheet.open{transform:none}
.sheethead{display:flex;align-items:center;justify-content:space-between;padding:12px 14px 0 22px}
#sheet h2{margin:0;font-family:'Bitter',serif;font-weight:800;font-size:clamp(22px,7vw,32px);color:#38291b;letter-spacing:-.01em}
#sheetClose{width:44px;height:44px;border:1px solid rgba(70,52,32,.45);border-radius:50%;background:rgba(255,252,244,.8);font:400 26px 'Bitter',serif;color:#4a3823;line-height:1;
  padding:0;box-shadow:0 2px 6px rgba(60,42,24,.25)}
#sheetSub{margin:2px 14px 6px 22px;font-size:14px;font-weight:600;color:#5d4a34}
#sheetBody{flex:1;overflow-y:auto;padding:4px 12px calc(20px + env(safe-area-inset-bottom)) 22px;-webkit-overflow-scrolling:touch}
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px}
.card{position:relative;aspect-ratio:779/1024;border-radius:7px;overflow:hidden;
  background:url(assets/shop_card.webp) center/100% 100% no-repeat;
  box-shadow:0 5px 12px rgba(45,28,12,.28)}
.card .pic{position:absolute;left:4.5%;right:4.5%;top:3.6%;height:51%;display:flex;align-items:center;justify-content:center}
.card .pic img{max-width:88%;max-height:92%;object-fit:contain;filter:drop-shadow(0 7px 9px rgba(20,14,8,.4))}
.card .pic img.shot{width:100%;height:100%;max-width:none;max-height:none;object-fit:cover;border-radius:2px;filter:drop-shadow(0 4px 7px rgba(18,12,6,.32))}
.cards.builds .card{background:url(assets/build_card.webp) center/100% 100% no-repeat}
.cards.builds .card .pic img{max-width:86%;max-height:90%;object-fit:contain;filter:drop-shadow(0 8px 10px rgba(20,14,8,.45))}
.card .own{position:absolute;right:6%;top:4.2%;font-family:'Rokkitt',serif;font-weight:800;font-size:14px;color:#3a2a18;background:rgba(248,240,222,.94);
  border:1px solid rgba(96,72,44,.32);border-radius:4px;padding:1px 6px;transform:rotate(-2.5deg);box-shadow:0 2px 4px rgba(30,20,10,.25)}
.card .txt{position:absolute;left:8%;right:8%;top:58.5%;height:19%;display:flex;flex-direction:column;justify-content:space-around;line-height:1;color:#33271a}
.card .nm{font-weight:800;font-size:clamp(13px,4vw,17px)}
.card .meta{font-family:'Rokkitt',serif;font-weight:600;font-size:clamp(12px,3.6vw,15px);display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.card .meta img{height:1.1em;vertical-align:-2px}
.card .meta .p{color:#a3331f;font-weight:800}
.card .buy{position:absolute;left:9%;right:9%;top:81%;height:13.2%;border:1px solid rgba(70,25,12,.5);border-radius:4px;
  background-image:linear-gradient(rgba(166,54,32,.96),rgba(126,34,18,.98)),url(assets/paper_real.webp);
  background-size:100% 100%,150px 150px;background-position:center;color:#fff4e2;font-family:'Bitter',serif;font-weight:800;
  font-size:clamp(12px,3.6vw,16px);letter-spacing:.03em;padding:0;box-shadow:inset 0 1px 0 rgba(255,220,180,.3),0 2px 3px rgba(50,20,8,.4)}
.card .buy small{font-family:'Rokkitt',serif;font-weight:800;font-size:1em}
.card.locked .pic img{filter:saturate(.82) brightness(.95)}
.card.locked .pic img.shot{filter:saturate(.82) brightness(.95)}
.card.locked .pic::before{content:"LOCKED";position:absolute;left:2%;top:3%;z-index:1;font:800 10px 'Bitter',serif;letter-spacing:.08em;
  color:#f8eeda;background:rgba(30,24,16,.82);border:1px solid rgba(248,238,218,.35);border-radius:3px;padding:2px 6px}
.card.locked .buy,.card.cant .buy{opacity:.55}
.card.done .buy{background-image:linear-gradient(rgba(74,92,48,.97),rgba(55,70,34,.98)),url(assets/paper_real.webp);color:#f2e7c6}
.card .desc{font-size:clamp(11px,3.2vw,13px);font-weight:600}

.rows{display:flex;flex-direction:column;gap:0}
.row{display:flex;align-items:center;gap:10px;min-height:56px;border-bottom:1px solid rgba(70,52,32,.18);padding:4px 0;color:#33271a}
.row img{width:44px;height:44px;object-fit:contain;filter:drop-shadow(0 2px 3px rgba(60,40,20,.2))}
.row .nm{flex:1;font-weight:800;font-size:16px}
.row .nm small{display:block;font-family:'Rokkitt',serif;font-weight:600;font-size:15px}
.row .nm small .p{color:#a3331f;font-weight:800}
.redstamp{border:1px solid rgba(70,25,12,.4);background-image:linear-gradient(#b33d27,#8e2a17);color:#fff4e2;font:800 15px 'Bitter',serif;border-radius:7px;padding:8px 12px;min-height:44px;
  letter-spacing:.02em;box-shadow:inset 0 1px 0 rgba(255,220,180,.3),0 2px 4px rgba(70,30,15,.22)}
.redstamp:disabled{opacity:.45}
.redstamp small{font-family:'Rokkitt',serif;font-weight:800;font-size:16px}
.sellall{display:flex;justify-content:space-between;align-items:center;margin:10px 0;gap:10px;font-weight:800;color:#33271a}
.sellall .redstamp{font-size:18px;padding:10px 18px}
.empty{font-weight:600;font-size:15px;padding:16px 0;line-height:1.4;color:#4b3a28}
.help h3{font-family:'Bitter',serif;font-weight:800;color:#3b2c1d;margin:14px 0 4px;font-size:18px}
.help p,.help li{font-size:15px;line-height:1.38;margin:4px 0;color:#3a2d1f}
.help ul{padding-left:18px;margin:4px 0}
.optrow{display:flex;gap:10px;flex-wrap:wrap;margin:8px 0}
.optbtn{border:1px solid rgba(80,60,35,.35);background-image:linear-gradient(#fffaf0,#f0e4cd);color:#3b2c1d;font:700 15px 'Bitter',serif;border-radius:7px;padding:9px 14px;min-height:44px;
  box-shadow:0 2px 4px rgba(70,45,20,.16)}
.board{list-style:none;padding:0;margin:4px 0;font-family:'Rokkitt',serif;font-size:17px;font-weight:600;color:#3a2d1f}
.board li{display:flex;gap:8px;border-bottom:1px solid rgba(70,52,32,.2);padding:4px 0}
.board li.me{background:rgba(217,166,60,.22)}
.board a{color:#5a3f22}
.board .v{margin-left:auto;color:#a3331f;font-weight:800}

/* toast: a small dark plaque over the field */
#toast{position:absolute;left:50%;top:calc(var(--ledgerH) + 10px);transform:translate(-50%,-20px);z-index:45;
  background:linear-gradient(180deg,rgba(42,34,24,.95),rgba(25,20,14,.96));color:#f9f1df;border:1px solid rgba(230,196,130,.4);border-radius:8px;
  padding:8px 14px;font-weight:700;font-size:15px;opacity:0;transition:.25s;pointer-events:none;max-width:86%;text-align:center;
  box-shadow:0 6px 18px rgba(0,0,0,.4),inset 0 1px 0 rgba(255,240,205,.12)}
#toast.show{opacity:1;transform:translate(-50%,0)}
#toast b{color:#f0c35f}

/* flying things */
#fx{position:absolute;inset:0;pointer-events:none;z-index:48;overflow:hidden}
#fx img{position:absolute;left:0;top:0;width:34px;height:34px;object-fit:contain;will-change:transform}

/* splash: the farm itself, with the sign hanging over it */
#splash{position:absolute;inset:0;z-index:60;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;padding-top:8dvh;
  background:linear-gradient(rgba(10,14,9,.1) 34%,rgba(10,14,9,.5) 78%,rgba(10,14,9,.72));transition:opacity .5s}
#splash.gone{opacity:0;pointer-events:none}
#titleImg{width:min(92%,520px);filter:drop-shadow(0 12px 18px rgba(0,0,0,.45));animation:drop .8s cubic-bezier(.3,1.5,.5,1)}
@keyframes drop{0%{transform:translateY(-40px) scale(1.15);opacity:0}}
#splash .tag{font-weight:700;font-size:clamp(14px,4.2vw,19px);color:#f7f1e3;background:rgba(22,26,18,.62);border:1px solid rgba(245,236,214,.26);
  padding:5px 14px;border-radius:6px;margin:4px 0 0;text-shadow:0 1px 3px rgba(0,0,0,.7)}
.bigstamp{margin-top:auto;margin-bottom:4dvh;border:1px solid rgba(255,235,190,.45);background-image:linear-gradient(#b8402a,#8d2715);color:#fff5e3;
  font:800 clamp(21px,6.2vw,28px) 'Bitter',serif;padding:14px 30px;border-radius:9px;
  box-shadow:0 8px 22px rgba(0,0,0,.45),inset 0 1px 0 rgba(255,225,185,.35);letter-spacing:.01em}
#splash .small{font-weight:600;font-size:14px;margin:0 0 calc(var(--trayH) * 0.15 + 8px);color:#f3ebd9;background:rgba(22,26,18,.62);
  border:1px solid rgba(245,236,214,.2);padding:4px 10px;border-radius:5px;text-shadow:0 1px 2px rgba(0,0,0,.6)}
/* look over a farm that has grown past the screen */
.panbtn{position:absolute;right:8px;z-index:19;min-width:44px;height:40px;padding:0 12px;border:1.5px solid rgba(241,228,198,.85);border-radius:20px;
  background:rgba(36,29,20,.82);color:#f8eeda;font:800 14px 'Bitter',serif;white-space:nowrap;box-shadow:0 2px 6px rgba(0,0,0,.35);cursor:pointer}
#panUp{top:calc(var(--ledgerH) + 58px)}
#panDown{bottom:calc(var(--trayH) + 66px)}
#sheetBody h3.sec{margin:14px 0 8px;font:800 18px 'Bitter',serif;color:#38291b}
#sheetBody h3.sec:first-child{margin-top:4px}
#sheetBody h3.sec small{font:600 13px 'Bitter',serif;color:#6b5840;margin-left:6px}
.card .nm .cnt{font-family:'Rokkitt',serif;color:#a3331f}
