:root{
  --paper:#F2DEB0;
  --paper-hi:#FBF0D4;
  --paper-lo:#E4CB96;
  --frame:#5A3A22;
  --frame-hi:#D7B77C;
  --frame-lo:#7A5634;
  --ink:#26325E;
  --red:#D8412B;
  --red-hi:#F26A50;
  --red-lo:#A82C1D;
  --gold:#F2C230;
  --jade:#4E9A3A;
  --cobalt:#2F6FD0;
  --blossom:#F07DB0;
  --slate:#5B7FA6;
  --milk:#F7F1DE;
  --shadow:#3E2918;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%;margin:0;overflow:hidden;background:#2F7FE0;}
body{
  font-family:'Zen Kaku Gothic New',sans-serif;
  color:var(--ink);
  -webkit-font-smoothing:antialiased;
  user-select:none;
}
#app{position:fixed;inset:0;overflow:hidden;}
#scene{position:absolute;inset:0;width:100%;height:100%;display:block;outline:none;z-index:0;}
#skyBand{position:absolute;left:0;right:0;top:0;height:clamp(40px,6.4vh,58px);z-index:1;pointer-events:none;overflow:hidden;background:#2F7FE0;transition:opacity .8s;}
#skyCanvas{width:100%;height:100%;display:block;image-rendering:pixelated;}
#daywash{position:absolute;inset:0;pointer-events:none;background:rgba(0,0,0,0);transition:background .9s linear;z-index:2;}
#weatherLayer{position:absolute;inset:0;pointer-events:none;opacity:0;transition:opacity .6s;z-index:3;}
#weatherLayer.rain{
  opacity:.42;
  background-image:repeating-linear-gradient(90deg,rgba(220,242,255,0) 0 12px,rgba(220,242,255,.85) 12px 15px);
  background-size:auto 28px;
  animation:rainfall .55s linear infinite;
  mix-blend-mode:screen;
}
#weatherLayer.snow{
  opacity:.55;
  background-image:
    radial-gradient(circle at 10% 10%,#fff 0 2px,transparent 2.6px),
    radial-gradient(circle at 40% 55%,#fff 0 2px,transparent 2.6px),
    radial-gradient(circle at 80% 25%,#fff 0 2px,transparent 2.6px),
    radial-gradient(circle at 65% 80%,#fff 0 2px,transparent 2.6px);
  background-size:90px 90px,130px 130px,110px 110px,150px 150px;
  animation:snowfall 9s linear infinite;
}
@keyframes rainfall{from{background-position:0 0}to{background-position:0 28px}}
@keyframes snowfall{from{background-position:0 0,0 0,0 0,0 0}to{background-position:22px 90px,-18px 130px,14px 110px,-10px 150px}}
#starLayer{position:absolute;inset:0;pointer-events:none;opacity:0;transition:opacity 1.2s;z-index:4;}
#starLayer.on{opacity:1;}
.star{position:absolute;width:4px;height:4px;background:#FDF6DC;box-shadow:0 0 0 1px rgba(255,246,220,.15);}

/* ---------- generic printed panel ---------- */
.panel{
  background:var(--paper);
  border:4px solid var(--frame);
  box-shadow:
    inset 0 0 0 4px var(--frame-hi),
    inset 0 0 0 7px var(--paper-hi),
    0 5px 0 var(--frame-lo),
    0 8px 0 var(--shadow);
  position:relative;
  image-rendering:pixelated;
}
.woodTab{
  font-family:'Shippori Mincho B1',serif;
  font-weight:800;
  letter-spacing:.04em;
  text-transform:uppercase;
  color:#33200F;
  background:#C99A58;
  border:3px solid #4A301A;
  box-shadow:inset 0 3px 0 #E6C489,inset 0 -3px 0 #A87838,0 3px 0 #4A301A;
  border-radius:0;
  cursor:pointer;
  padding:5px 10px;
  min-height:30px;
  font-size:12px;
}
.woodTab:active{transform:translateY(3px);box-shadow:inset 0 2px 0 #A87838,0 0 0 #4A301A;}
.woodTab:focus-visible,.actBtn:focus-visible,button:focus-visible{outline:3px dashed #FBF0D4;outline-offset:2px;}
.hidden{display:none !important;}

/* ---------- title ---------- */
#titleWrap{
  position:absolute;left:1.4%;top:1.2%;
  display:flex;align-items:flex-start;gap:2px;
  pointer-events:none;z-index:6;
  filter:drop-shadow(3px 4px 0 rgba(20,30,60,.18));
}
#wheatIcon{width:clamp(24px,3.2vw,52px);height:auto;image-rendering:pixelated;flex:none;margin-top:2px;}
#titleWrap h1{
  margin:0;
  font-family:'Shippori Mincho B1',serif;
  font-weight:800;
  font-size:clamp(26px,4.5vw,64px);
  line-height:.86;
  letter-spacing:-.01em;
  text-transform:uppercase;
  color:#E23A22;
  text-shadow:
    -2px -2px 0 #24479B,2px -2px 0 #24479B,-2px 2px 0 #24479B,2px 2px 0 #24479B,
    -3px 0 0 #24479B,3px 0 0 #24479B,0 -3px 0 #24479B,0 3px 0 #24479B,
    5px 6px 0 #1A2E63;
}
#titleWrap h1 span{display:block;}

/* ---------- left needs panel ---------- */
#needsPanel{
  position:absolute;left:1.4%;top:16.5%;
  width:clamp(136px,13.6vw,196px);
  padding:8px 8px 24px;
  z-index:5;
}
.portraitFrame{
  background:var(--paper-hi);
  border:3px solid var(--frame);
  box-shadow:inset 0 0 0 2px var(--frame-hi);
  width:100%;
  aspect-ratio:1/1;
  margin-bottom:7px;
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;
}
#portraitCanvas{width:100%;height:100%;image-rendering:pixelated;}
.needRow{display:flex;align-items:center;gap:4px;margin:4px 0;}
.needIcon{
  width:clamp(16px,1.8vw,23px);height:clamp(16px,1.8vw,23px);
  image-rendering:pixelated;flex:none;
  background:var(--paper-hi);
  border:2px solid var(--frame);
  box-shadow:inset 0 0 0 1px var(--frame-hi);
}
.needBar{
  flex:1;display:flex;gap:2px;height:clamp(14px,1.6vw,19px);
  background:#7E6136;border:2px solid var(--frame);
  box-shadow:inset 0 0 0 1px #4A301A;
  padding:2px;
}
.needBrick{flex:1;background:#AE8C58;border:1px solid #5A3A22;box-shadow:inset 0 -2px 0 rgba(60,38,20,.28);}
.needBrick.on{background:var(--bc,#5CB544);border-color:#2E1B0E;box-shadow:inset 0 2px 0 rgba(255,255,255,.42),inset 0 -2px 0 rgba(60,38,20,.24);}
#careerTag{
  margin-top:6px;
  font-family:'Cutive Mono',monospace;
  font-size:clamp(9px,1vw,12px);
  text-align:center;
  color:#5F4426;
  border-top:2px dashed rgba(90,58,34,.35);
  padding-top:4px;
  letter-spacing:.02em;
}
#storyTag{
  margin-top:2px;
  font-family:'Cutive Mono',monospace;
  font-size:clamp(8px,.9vw,11px);
  line-height:1.1;
  text-align:center;
  color:#7A4A1E;
  letter-spacing:.01em;
}
#journalBtn{
  position:absolute;left:7px;right:7px;bottom:-29px;
  font-size:clamp(9px,1vw,12px);
  padding:4px 4px;
}

/* ---------- clock / ledger ---------- */
#clockWrap{
  position:absolute;right:1.4%;top:1.2%;
  width:clamp(110px,13vw,196px);
  display:flex;flex-direction:column;align-items:stretch;
  z-index:6;
}
#clockFrame{
  align-self:flex-end;
  width:clamp(84px,9.4vw,138px);
  aspect-ratio:1/1;
  background:#C99A58;
  border:4px solid #4A301A;
  box-shadow:inset 0 0 0 3px #E6C489,inset 0 0 0 6px #8A5E2E,0 4px 0 #4A301A,0 6px 0 rgba(40,26,14,.4);
  padding:5px;
  position:relative;
}
#clockFace{width:100%;height:100%;display:block;border-radius:50%;image-rendering:pixelated;}
#clockHand{
  position:absolute;left:50%;bottom:50%;
  width:7px;height:38%;
  margin-left:-3.5px;
  background:#D8412B;
  border:2px solid #54201A;
  box-shadow:2px 0 0 rgba(84,32,26,.28);
  transform-origin:50% 100%;
  transform:rotate(0deg);
  pointer-events:none;
  z-index:2;
}
#clockHand::after{
  content:"";position:absolute;left:50%;top:-8px;transform:translateX(-50%);
  width:13px;height:13px;background:#D8412B;border:2px solid #54201A;
}
#ledger{
  margin-top:8px;
  padding:5px 8px 7px;
  font-family:'Cutive Mono',monospace;
  color:#1F3B7A;
  text-align:center;
}
.dateRow{
  font-family:'Shippori Mincho B1',serif;
  font-weight:800;
  font-size:clamp(14px,1.55vw,22px);
  line-height:1.05;
  color:#1E3C86;
  text-shadow:1px 1px 0 #FBF0D4;
}
#moneyLabel{
  font-size:clamp(13px,1.45vw,21px);
  font-weight:700;
  margin-top:1px;
  letter-spacing:.02em;
}
.subRow{
  display:flex;justify-content:space-between;gap:5px;
  font-size:clamp(8px,.9vw,11px);
  color:#6A4A2A;
  border-top:2px dashed rgba(90,58,34,.35);
  margin-top:4px;padding-top:3px;
  text-transform:uppercase;
}

/* ---------- bottom hud ---------- */
#bottomHud{
  position:absolute;left:1.2%;right:1.2%;bottom:1.2%;
  display:flex;gap:.7%;
  height:clamp(72px,12.2vh,112px);
  z-index:7;
  align-items:stretch;
}
#bottomHud > .panel{padding:8px;}
#invPanel{flex:0 0 35.4%;}
#relPanel{flex:0 0 24.2%;}
#actPanel{flex:1 1 auto;}
.slotRow{display:flex;gap:clamp(3px,.45vw,6px);height:100%;}
.slot{
  flex:1 1 0;min-width:0;height:100%;
  background:var(--paper-hi);
  border:3px solid var(--frame);
  box-shadow:inset 0 0 0 2px var(--frame-hi);
  position:relative;
  display:flex;align-items:center;justify-content:center;
}
.slot canvas{width:78%;height:78%;image-rendering:pixelated;opacity:.28;filter:grayscale(1);}
.slot.has canvas{opacity:1;filter:none;}
.slot .count{
  position:absolute;right:2px;bottom:0;
  font-family:'Cutive Mono',monospace;
  font-size:clamp(8px,.85vw,11px);
  font-weight:700;
  color:#2A1A0E;
  background:var(--paper-hi);
  padding:0 2px;
  line-height:1.15;
  border:1px solid rgba(90,58,34,.5);
}
.relRow{display:flex;gap:clamp(3px,.4vw,5px);height:100%;}
.relBtn{
  flex:1 1 0;min-width:0;
  background:var(--paper-hi);
  border:3px solid var(--frame);
  box-shadow:inset 0 0 0 2px var(--frame-hi);
  padding:2px;
  display:flex;flex-direction:column;align-items:center;justify-content:flex-end;
  cursor:pointer;
}
.relBtn canvas{width:100%;flex:1;min-height:0;object-fit:contain;image-rendering:pixelated;}
.relBtn .hearts{
  display:flex;gap:1px;height:clamp(5px,.65vw,7px);width:100%;
  justify-content:center;margin-top:2px;
}
.relBtn .hp{flex:1;max-width:8px;background:#B99A6B;border:1px solid #5A3A22;}
.relBtn .hp.on{background:#D8412B;}
.actRow{display:grid;grid-template-columns:repeat(8,1fr);gap:clamp(2px,.35vw,5px);height:100%;}
.actBtn{
  position:relative;
  background:var(--red);
  border:3px solid #54201A;
  box-shadow:inset 0 3px 0 var(--red-hi),inset 0 -4px 0 var(--red-lo),0 4px 0 #54201A;
  border-radius:0;
  cursor:pointer;
  padding:2px;
  display:flex;align-items:center;justify-content:center;
  min-width:0;
  overflow:hidden;
}
.actBtn canvas{width:82%;height:82%;object-fit:contain;image-rendering:pixelated;filter:drop-shadow(1px 1px 0 rgba(40,20,10,.35));}
.actBtn.active{transform:translateY(4px);box-shadow:inset 0 3px 0 var(--red-lo),inset 0 -3px 0 var(--red-hi),0 0 0 #54201A;filter:brightness(.94);}
.actBtn:active{transform:translateY(4px);box-shadow:inset 0 3px 0 var(--red-lo),inset 0 -3px 0 var(--red-hi),0 0 0 #54201A;}
.actBtn .keycap{
  position:absolute;left:2px;top:1px;
  font-family:'Cutive Mono',monospace;font-size:8px;color:#FFE9D6;opacity:.65;
}

/* ---------- hint, toast, speech ---------- */
#hint{
  position:absolute;left:50%;bottom:calc(clamp(72px,12.2vh,112px) + 20px);
  transform:translateX(-50%);
  width:max-content;max-width:min(680px,88vw);
  padding:6px 12px;
  font-size:clamp(10px,1vw,13px);
  text-align:center;
  color:#3E2918;
  z-index:8;
  transition:opacity .5s;
}
#hint.fade{opacity:0;pointer-events:none;}
#toast{
  position:absolute;left:50%;top:12%;
  transform:translateX(-50%) translateY(-8px);
  min-width:180px;max-width:min(560px,86vw);
  padding:8px 14px;
  text-align:center;
  font-size:clamp(11px,1.05vw,14px);
  color:#33200F;
  z-index:30;
  opacity:0;pointer-events:none;
  transition:opacity .25s,transform .25s;
}
#toast.show{opacity:1;transform:translateX(-50%) translateY(0);}
#speech{
  position:absolute;left:50%;bottom:calc(clamp(72px,12.2vh,112px) + 16px);
  transform:translateX(-50%);
  width:min(660px,92vw);
  z-index:25;
  padding:9px 11px;
  display:grid;grid-template-columns:64px 1fr;gap:10px;
}
#speech .speechPortrait{
  width:64px;height:70px;
  background:var(--paper-hi);border:3px solid var(--frame);
  box-shadow:inset 0 0 0 2px var(--frame-hi);
  display:flex;align-items:center;justify-content:center;
}
#speech .speechPortrait canvas{width:100%;height:100%;image-rendering:pixelated;}
#speech .speechName{font-family:'Shippori Mincho B1',serif;font-weight:800;font-size:15px;color:#1E3C86;line-height:1.1;}
#speech .speechRole{font-family:'Cutive Mono',monospace;font-size:10px;color:#6A4A2A;margin-bottom:3px;}
#speech .speechText{font-size:13px;line-height:1.35;color:#33200F;min-height:34px;}
#speech .speechBtns{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px;}
#speech .woodTab{font-size:10px;padding:4px 8px;min-height:0;}
#speech .woodTab[disabled]{opacity:.45;cursor:default;transform:none;}

/* ---------- modal ---------- */
#modal{
  position:fixed;inset:0;z-index:60;
  background:rgba(18,24,48,.20);
  display:flex;align-items:flex-end;justify-content:center;
  padding:14px 14px calc(clamp(72px,12.2vh,112px) + 16px);
}
#modalCard{
  width:min(680px,96vw);
  max-height:60vh;
  overflow:auto;
  padding:14px 16px 16px;
  background:var(--paper);
}
#modalBody{font-size:13px;line-height:1.4;color:#33200F;}
#modalBody h2{
  font-family:'Shippori Mincho B1',serif;
  font-weight:800;font-size:clamp(18px,2vw,26px);
  color:#1E3C86;margin:0 0 4px;
  text-transform:uppercase;letter-spacing:.01em;
  text-shadow:1px 1px 0 var(--paper-hi);
}
#modalBody h3{
  font-family:'Shippori Mincho B1',serif;font-weight:800;
  font-size:14px;margin:12px 0 4px;color:#5A3A22;
  text-transform:uppercase;letter-spacing:.04em;
}
#modalBody p{margin:5px 0 8px;}
#modalBody .muted{color:#6A4A2A;font-size:12px;}
#modalClose{position:absolute;right:10px;top:-14px;min-width:34px;font-size:14px;z-index:2;}
.tabRow{display:flex;gap:5px;margin:2px 0 10px;flex-wrap:wrap;}
.tabBtn{
  font-family:'Shippori Mincho B1',serif;font-weight:800;font-size:11px;
  background:#E4CB96;border:3px solid #5A3A22;color:#3E2918;
  padding:4px 9px;cursor:pointer;text-transform:uppercase;
  box-shadow:inset 0 2px 0 #F7EACB;
}
.tabBtn.on{background:#D8412B;color:#FFF0E2;box-shadow:inset 0 3px 0 #F26A50,inset 0 -3px 0 #A82C1D;}
.rowCard{
  background:#F8EBCB;
  border:3px solid #7A5634;
  box-shadow:inset 0 0 0 2px #D7B77C;
  padding:8px 10px;margin:7px 0;
}
.rowCard .titleLine{font-family:'Shippori Mincho B1',serif;font-weight:800;font-size:14px;color:#1E3C86;display:flex;justify-content:space-between;gap:8px;}
.rowCard .small{font-size:11px;color:#6A4A2A;}
.rowCard .num{font-family:'Cutive Mono',monospace;font-weight:700;}
.miniBar{display:flex;gap:2px;height:10px;margin:5px 0 2px;}
.miniBar .mb{flex:1;background:#D3B889;border:1px solid #8A6B44;}
.miniBar .mb.on{background:var(--bc,#4E9A3A);border-color:#2F5E22;}
.vneeds{display:grid;grid-template-columns:1fr 1fr;gap:4px 12px;margin:6px 0 4px;}
.vneed{display:flex;align-items:center;gap:6px;font-size:11px;color:#5A3A22;}
.vneed b{font-family:'Cutive Mono',monospace;font-weight:700;min-width:44px;font-size:10px;}
.vneed .miniBar{flex:1;margin:0;height:9px;}
.bigBtn{
  font-family:'Shippori Mincho B1',serif;font-weight:800;font-size:12px;
  background:#D8412B;color:#FFF0E2;border:3px solid #54201A;
  box-shadow:inset 0 3px 0 #F26A50,inset 0 -3px 0 #A82C1D,0 3px 0 #54201A;
  padding:5px 12px;cursor:pointer;text-transform:uppercase;
}
.bigBtn:active{transform:translateY(3px);box-shadow:inset 0 2px 0 #A82C1D,0 0 0 #54201A;}
.bigBtn[disabled]{opacity:.45;cursor:default;}
.bigBtn.green{background:#4E9A3A;box-shadow:inset 0 3px 0 #79C05C,inset 0 -3px 0 #2F5E22,0 3px 0 #2A2010;}
.bigBtn.green:active{box-shadow:inset 0 2px 0 #2F5E22,0 0 0 #2A2010;}
.itemRow{display:flex;align-items:center;gap:8px;padding:5px 0;border-bottom:2px dashed rgba(90,58,34,.28);}
.itemRow:last-child{border-bottom:0;}
.itemRow canvas{width:30px;height:30px;image-rendering:pixelated;flex:none;}
.itemRow .grow{flex:1;font-size:12px;}
.itemRow .price{font-family:'Cutive Mono',monospace;font-weight:700;font-size:12px;color:#1E3C86;min-width:52px;text-align:right;}
.itemRow .bigBtn{padding:3px 8px;font-size:10px;}
.needKey{display:inline-block;width:10px;height:10px;border:1px solid #5A3A22;margin:0 3px -1px 0;}
.vcard .vhead{display:flex;gap:8px;align-items:flex-start;}
.vcard h2{font-size:clamp(15px,1.8vw,22px);margin:0 0 1px;}
.vcard .small{font-size:9.5px;line-height:1.25;}
.vcard .vneeds{grid-template-columns:1fr 1fr;gap:2px 8px;margin:4px 0 1px;}
.vcard .vneed{font-size:8.5px;}
.vcard .vneed b{min-width:34px;font-size:7.5px;}
.vcard .vneed .miniBar{height:7px;}
.vcard .bigBtn{margin-top:2px;padding:2px 8px;font-size:9px;}
.vcard .cardPortrait{width:64px !important;height:64px !important;}
.chapterDone{opacity:.65;}
.chapterDone .titleLine::after{content:"DONE";font-family:'Cutive Mono',monospace;font-size:9px;background:#4E9A3A;color:#FFF;padding:1px 4px;}

/* ---------- load ---------- */
#load{
  position:fixed;inset:0;z-index:100;
  background:#2F7FE0;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  color:#FBF0D4;text-align:center;
  transition:opacity .55s;
}
#load.gone{opacity:0;pointer-events:none;}
.loadTitle{
  font-family:'Shippori Mincho B1',serif;font-weight:800;
  font-size:clamp(26px,5vw,58px);letter-spacing:.02em;
  color:#E23A22;
  text-shadow:-2px -2px 0 #24479B,2px -2px 0 #24479B,-2px 2px 0 #24479B,2px 2px 0 #24479B,5px 6px 0 #1A2E63;
}
.loadSub{font-family:'Cutive Mono',monospace;margin-top:14px;font-size:13px;color:#DDE9FF;}

/* ---------- help button ---------- */
#helpBtn{position:absolute;left:50%;top:1.1%;transform:translateX(-50%);z-index:9;min-width:34px;min-height:32px;font-size:16px;}

/* ---------- responsive ---------- */
@media (max-width: 860px) and (min-aspect-ratio: 1/1), (max-height: 620px) and (min-aspect-ratio: 1/1){
  #bottomHud{height:clamp(66px,16vh,92px);}
  #hint{bottom:calc(clamp(66px,16vh,92px) + 16px);}
  #speech{bottom:calc(clamp(66px,16vh,92px) + 12px);}
  #needsPanel{width:clamp(126px,16vw,168px);top:19%;}
  #titleWrap h1{font-size:clamp(22px,4vw,38px);}
}
@media (max-aspect-ratio: 1/1){
  #titleWrap{left:6px;top:6px;gap:1px;}
  #wheatIcon{width:22px;margin-top:1px;}
  #titleWrap h1{font-size:clamp(19px,6.4vw,30px);text-shadow:-1.5px -1.5px 0 #24479B,1.5px -1.5px 0 #24479B,-1.5px 1.5px 0 #24479B,1.5px 1.5px 0 #24479B,3px 4px 0 #1A2E63;}
  #needsPanel{left:5px;top:68px;width:102px;padding:5px 5px 22px;border-width:3px;box-shadow:inset 0 0 0 3px var(--frame-hi),inset 0 0 0 5px var(--paper-hi),0 4px 0 var(--frame-lo),0 6px 0 var(--shadow);}
  .portraitFrame{border-width:2px;margin-bottom:4px;}
  .needRow{gap:2px;margin:2px 0;}
  .needIcon{width:14px;height:14px;border-width:1px;}
  .needBar{height:13px;padding:1px;gap:1px;border-width:1px;}
  .needBrick{border-width:1px;}
  #careerTag{font-size:7px;margin-top:3px;padding-top:2px;}
  #storyTag{font-size:6.5px;margin-top:1px;}
  #journalBtn{left:3px;right:3px;bottom:-22px;font-size:8px;padding:3px 2px;min-height:22px;border-width:2px;}
  #clockWrap{right:5px;top:5px;width:104px;}
  #clockFrame{width:72px;padding:3px;border-width:3px;}
  #clockHand{width:5px;margin-left:-2.5px;border-width:1px;}
  #clockHand::after{width:9px;height:9px;border-width:1px;top:-6px;}
  #ledger{margin-top:4px;padding:3px 4px 4px;border-width:3px;box-shadow:inset 0 0 0 3px var(--frame-hi),inset 0 0 0 5px var(--paper-hi),0 3px 0 var(--frame-lo),0 5px 0 var(--shadow);}
  .dateRow{font-size:11px;}
  #moneyLabel{font-size:10px;}
  .subRow{font-size:7px;margin-top:2px;padding-top:2px;}
  #helpBtn{left:auto;right:116px;top:5px;min-width:26px;min-height:26px;font-size:13px;transform:none;border-width:2px;padding:2px 6px;}
  #bottomHud{left:4px;right:4px;bottom:4px;height:auto;flex-wrap:wrap;gap:4px;}
  #bottomHud > .panel{padding:4px;border-width:3px;box-shadow:inset 0 0 0 3px var(--frame-hi),inset 0 0 0 5px var(--paper-hi),0 3px 0 var(--frame-lo),0 5px 0 var(--shadow);}
  #invPanel{flex:0 0 calc(55% - 2px);height:48px;}
  #relPanel{flex:1 1 auto;height:48px;}
  #actPanel{flex:0 0 100%;height:44px;}
  .slot{border-width:2px;box-shadow:inset 0 0 0 1px var(--frame-hi);}
  .slot .count{font-size:7px;}
  .relBtn{border-width:2px;box-shadow:inset 0 0 0 1px var(--frame-hi);padding:1px;}
  .relBtn .hearts{height:4px;margin-top:1px;}
  .actRow{gap:3px;}
  .actBtn{border-width:2px;box-shadow:inset 0 2px 0 var(--red-hi),inset 0 -3px 0 var(--red-lo),0 3px 0 #54201A;padding:1px;}
  .actBtn.active,.actBtn:active{transform:translateY(3px);box-shadow:inset 0 2px 0 var(--red-lo),inset 0 -2px 0 var(--red-hi),0 0 0 #54201A;}
  .actBtn .keycap{display:none;}
  #hint{bottom:104px;font-size:9px;padding:4px 7px;max-width:94vw;border-width:3px;box-shadow:inset 0 0 0 2px var(--frame-hi),inset 0 0 0 4px var(--paper-hi),0 3px 0 var(--frame-lo);}
  #toast{top:174px;font-size:10px;padding:5px 8px;border-width:3px;max-width:88vw;}
  #speech{bottom:104px;width:calc(100vw - 12px);grid-template-columns:42px 1fr;gap:6px;padding:6px;border-width:3px;}
  #speech .speechPortrait{width:42px;height:48px;border-width:2px;}
  #speech .speechName{font-size:12px;}
  #speech .speechRole{font-size:8px;}
  #speech .speechText{font-size:10.5px;min-height:26px;}
  #speech .woodTab{font-size:8px;padding:3px 6px;}
  #modal{padding:8px 8px 104px;}
  #modalCard{width:100%;max-height:46vh;padding:10px;border-width:3px;box-shadow:inset 0 0 0 3px var(--frame-hi),inset 0 0 0 5px var(--paper-hi),0 4px 0 var(--frame-lo),0 6px 0 var(--shadow);}
  #modalClose{right:6px;top:-12px;min-width:28px;font-size:11px;}
  #modalBody{font-size:11px;}
  #modalBody h2{font-size:17px;}
  #modalBody h3{font-size:12px;}
  .rowCard{padding:6px 7px;margin:5px 0;border-width:2px;}
  .rowCard .titleLine{font-size:11px;}
  .rowCard .small{font-size:9px;}
  .bigBtn{font-size:10px;padding:4px 8px;border-width:2px;}
  .itemRow canvas{width:24px;height:24px;}
  .itemRow .grow{font-size:10px;}
  .itemRow .price{font-size:10px;min-width:40px;}
  .tabBtn{font-size:9px;padding:3px 6px;border-width:2px;}
}
@media (max-width: 380px){
  #needsPanel{width:94px;top:54px;}
  #titleWrap h1{font-size:18px;}
  #clockWrap{width:96px;}
  #clockFrame{width:66px;}
  #helpBtn{right:108px;}
  #ledger{padding:2px 3px;}
  .dateRow{font-size:10px;}
}

/* ---------- extra game layers ---------- */
#seasonWash{position:absolute;inset:0;pointer-events:none;background:transparent;mix-blend-mode:soft-light;transition:background .8s;z-index:1;}
.nameTag{
  position:absolute;z-index:12;pointer-events:none;
  transform:translate(-50%,-100%);
  background:var(--paper-hi);color:#33200F;
  border:2px solid var(--frame);
  box-shadow:inset 0 0 0 1px var(--frame-hi),0 2px 0 rgba(62,41,24,.35);
  font-family:'Shippori Mincho B1',serif;font-weight:800;
  font-size:10px;padding:1px 5px;white-space:nowrap;
  opacity:0;transition:opacity .18s;
}
.nameTag.on{opacity:1;}
#journalBtn.pulse{animation:tabPulse 1.1s ease-in-out 4;}
@keyframes tabPulse{0%,100%{background:#C99A58}50%{background:#F2C230}}
#flash{position:absolute;inset:0;background:#FBF0D4;opacity:0;pointer-events:none;z-index:40;transition:opacity .35s;}
#flash.on{opacity:.72;}
#hint,#toast{pointer-events:none;}

/* ---------- short landscape phones: keep the valley and the farmer visible ---------- */
@media (max-height: 500px) and (min-aspect-ratio: 1/1){
  #titleWrap{left:5px;top:4px;gap:2px;}
  #wheatIcon{width:22px;margin-top:0;}
  #titleWrap h1{font-size:22px;line-height:.82;text-shadow:-1px -1px 0 #2E5FD1,1px -1px 0 #2E5FD1,-1px 1px 0 #2E5FD1,1px 1px 0 #2E5FD1,3px 4px 0 #173A8E;}
  #needsPanel{left:5px;top:46px;width:94px;padding:4px 4px 18px;border-width:3px;box-shadow:inset 0 0 0 3px var(--frame-hi),inset 0 0 0 5px var(--paper-hi),0 3px 0 var(--frame-lo),0 5px 0 var(--shadow);}
  .portraitFrame{width:44px;height:44px;margin:0 auto 3px;border-width:2px;box-shadow:inset 0 0 0 1px var(--frame-hi);}
  .needRow{gap:2px;margin:1px 0;}
  .needIcon{width:12px;height:12px;border-width:1px;}
  .needBar{height:11px;padding:1px;gap:1px;border-width:1px;box-shadow:inset 0 0 0 1px #4A301A;}
  .needBrick{border-width:1px;}
  #careerTag{font-size:6px;margin-top:1px;padding-top:1px;}
  #storyTag{font-size:6px;margin-top:0;}
  #journalBtn{bottom:-18px;font-size:7px;padding:2px;min-height:16px;border-width:2px;}
  #clockWrap{width:92px;right:5px;top:4px;}
  #clockFrame{width:56px;padding:2px;border-width:3px;box-shadow:inset 0 0 0 2px #E6C489,inset 0 0 0 4px #8A5E2E,0 3px 0 #4A301A;}
  #clockHand{width:4px;margin-left:-2px;border-width:1px;}
  #clockHand::after{width:7px;height:7px;border-width:1px;top:-5px;}
  #ledger{margin-top:3px;padding:2px 3px 3px;border-width:3px;box-shadow:inset 0 0 0 2px var(--frame-hi),inset 0 0 0 4px var(--paper-hi),0 2px 0 var(--frame-lo),0 4px 0 var(--shadow);}
  .dateRow{font-size:10px;line-height:1;}
  #moneyLabel{font-size:9px;}
  .subRow{font-size:6px;margin-top:1px;padding-top:1px;}
  #helpBtn{left:auto;right:102px;top:4px;min-width:24px;min-height:22px;font-size:12px;border-width:2px;padding:1px 5px;transform:none;}
  #bottomHud{left:4px;right:4px;bottom:4px;height:60px;gap:4px;}
  #bottomHud > .panel{padding:3px;border-width:3px;box-shadow:inset 0 0 0 3px var(--frame-hi),inset 0 0 0 5px var(--paper-hi),0 2px 0 var(--frame-lo),0 4px 0 var(--shadow);}
  #invPanel{flex:0 0 37%;}
  #relPanel{flex:0 0 22%;}
  #actPanel{flex:1 1 auto;}
  .slotRow{gap:2px;}
  .slot{border-width:2px;box-shadow:inset 0 0 0 1px var(--frame-hi);}
  .slot canvas{width:84%;height:84%;}
  .slot .count{font-size:6px;padding:0 1px;}
  .relRow{gap:2px;}
  .relBtn{border-width:2px;padding:1px;box-shadow:inset 0 0 0 1px var(--frame-hi);}
  .relBtn .hearts{height:3px;margin-top:1px;}
  .actRow{gap:2px;}
  .actBtn{border-width:2px;padding:1px;box-shadow:inset 0 2px 0 var(--red-hi),inset 0 -2px 0 var(--red-lo),0 3px 0 #54201A;}
  .actBtn canvas{width:84%;height:84%;}
  .actBtn .keycap{display:none;}
  #hint{bottom:68px;font-size:8px;padding:3px 6px;border-width:3px;box-shadow:inset 0 0 0 2px var(--frame-hi),inset 0 0 0 4px var(--paper-hi),0 2px 0 var(--frame-lo);max-width:70vw;}
  #toast{top:64px;font-size:9px;padding:3px 7px;border-width:3px;max-width:60vw;}
  #speech{bottom:68px;width:min(560px,72vw);grid-template-columns:42px 1fr;gap:5px;padding:4px;border-width:3px;box-shadow:inset 0 0 0 3px var(--frame-hi),inset 0 0 0 5px var(--paper-hi),0 3px 0 var(--frame-lo),0 5px 0 var(--shadow);}
  #speech .speechPortrait{width:42px;height:46px;border-width:2px;}
  #speech .speechName{font-size:11px;}
  #speech .speechRole{font-size:7px;margin-bottom:1px;}
  #speech .speechText{font-size:9.5px;line-height:1.3;min-height:22px;}
  #speech .speechBtns{gap:4px;margin-top:2px;}
  #speech .woodTab{font-size:7px;padding:2px 5px;min-height:0;}
  .nameTag{font-size:8px;padding:0 3px;border-width:1px;}
  #modal{padding:4px 6px 68px;}
  #modalCard{max-height:52vh;padding:8px 10px;border-width:3px;}
  #modalBody{font-size:10px;}
  #modalBody h2{font-size:16px;}
  #modalBody h3{font-size:11px;}
  .rowCard{padding:5px 6px;margin:4px 0;}
  .bigBtn{font-size:9px;padding:3px 7px;}
  .tabBtn{font-size:8px;padding:2px 5px;}
}


/* ---------- landscape: keep the world and the controlled farmer visible ---------- */
@media (min-aspect-ratio: 1/1) and (min-height: 501px){
  #modal{justify-content:flex-end;align-items:flex-start;padding:220px 10px 150px 10px;}
  #modalCard{width:min(410px,32vw);max-height:calc(100vh - 370px);}
  #modalClose{top:4px;right:6px;}
  #titleWrap h1{font-size:clamp(22px,3.4vw,46px);}
  #needsPanel{top:19%;}
}
@media (min-aspect-ratio: 1/1) and (max-height: 500px){
  #modal{justify-content:flex-end;align-items:flex-start;padding:104px 6px 70px 6px;}
  #modalCard{width:min(310px,38vw);max-height:calc(100vh - 178px);}
  #modalClose{top:4px;right:6px;}
  #titleWrap{left:8px;}
  #titleWrap h1{font-size:20px;}
  #skyBand{height:38px;}
}


/* compact villager card for short landscape */
@media (min-aspect-ratio: 1/1) and (max-height: 500px){
  .vcard h2{font-size:15px;margin:0 0 1px;}
  .vcard .vhead{gap:7px;}
  .vcard .cardPortrait{width:58px !important;height:58px !important;}
  .vcard .small{font-size:8.5px;line-height:1.2;}
  .vcard .vneeds{gap:2px 7px;margin:4px 0 1px;}
  .vcard .vneed{font-size:8px;gap:3px;}
  .vcard .vneed b{min-width:32px;font-size:7px;}
  .vcard .vneed .miniBar{height:7px;}
  .vcard .bigBtn{font-size:9px;padding:2px 7px;margin-top:1px;}
}
