/* Watercolor folios float over the scroll; controls live outside each illustration. */
#gameDialog{--folio-frame:var(--media-9f54bfbd2e);--folio-icons:var(--media-317763ae7e);--folio-rail:76px;--folio-control:76px}
#gameDialog.focused-game[open]{
  inset:auto;left:50%;top:50%;margin:0;padding:0;
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) var(--folio-rail);gap:0;
  width:min(1320px,calc(100vw - 32px));height:min(880px,calc(100dvh - 24px));max-width:none;max-height:none;
  border:0;border-radius:0;overflow:hidden;isolation:isolate;
  color:#294f40;background:transparent;transform:translate(-50%,-50%);box-shadow:none;
}
#gameDialog.drone-game[open]{width:100vw;height:100dvh;background:transparent;grid-template-rows:minmax(0,1fr)}
#gameDialog::backdrop,#gameDialog.drone-game::backdrop,.farmer-interview-dialog::backdrop{background:#193c307a;backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px)}
#gameDialog .game-scene-shell{position:relative;min-width:0;min-height:0;isolation:isolate;animation:folio-unfold .55s cubic-bezier(.2,.8,.2,1) both}
#gameDialog .game-scene-shell::before{content:'';position:absolute;inset:0;z-index:2;background:var(--folio-frame) center/100% 100% no-repeat;pointer-events:none;filter:drop-shadow(0 10px 10px #102d273d)}
/* Screen readers keep instructions; the illustrated view stays free of copy. */
#gameDialog .game-toolbar,#gameDialog.focused-game #gameFeedback,
#gameDialog .rope-instruction,#gameDialog .drone-lock{position:absolute;width:1px;height:1px;min-height:0;min-width:0;margin:0;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;pointer-events:none}
#gameDialog.focused-game #gameNote{display:none}
#gameDialog.focused-game .game-board{
  position:absolute;inset:10% 6%;z-index:1;display:flex;flex-direction:column;flex:1;
  width:88%;height:80%;min-height:0;min-width:0;margin:0;padding:0;gap:0;overflow:hidden;
  border:0;border-radius:0;box-shadow:none;background:#e7edce;
  clip-path:polygon(.15% 1%,14% .35%,28% .6%,46% 0,64% .4%,79% .1%,99.65% .7%,100% 24%,99.65% 52%,100% 78%,99.6% 99.4%,77% 100%,55% 99.6%,34% 100%,12% 99.6%,.4% 100%,0 77%,.25% 54%,0 28%);
}
#gameDialog.drone-game .game-scene-shell::before{display:none}
#gameDialog.drone-game .game-board{inset:0;width:100%;height:100%;clip-path:none}
#gameDialog.focused-game .game-foot,
#gameDialog.focused-game.focused-complete .game-foot,
#gameDialog.land-game.focused-complete:not(.land-results-ready) .game-foot{
  position:relative;inset:auto;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:14px;
  width:100%;height:var(--folio-rail);min-height:var(--folio-rail);margin:0;padding:0 5%;
  transform:none;animation:folio-controls-in .45s .15s both;background:transparent;z-index:2;
}
#gameDialog .game-secondary{grid-column:1;grid-row:1;justify-self:start;display:flex;align-items:center;min-width:0}
#gameDialog #gameTools,#gameDialog #gameTools>div{display:flex;align-items:center;gap:4px;flex:none}
#gameDialog #gameTools :is(.pk-controls,.farm-controls,.drying-controls){position:static;inset:auto;transform:none;margin:0;padding:0}
#gameDialog #gameTools button,#gameDialog.focused-game .game-foot .close,
#gameDialog.focused-game .game-foot #gameNext{
  --icon-x:33.333333%;--icon-y:0%;
  position:relative;inset:auto;display:grid;place-items:center;flex:none;
  width:var(--folio-control);height:var(--folio-control);min-width:var(--folio-control);min-height:var(--folio-control);
  margin:0;padding:0;border:0;border-radius:50%;background:none;box-shadow:none;
  font-size:0;color:transparent;touch-action:manipulation;
  filter:drop-shadow(0 4px 3px #102d274d);transition:filter .2s,transform .2s;
}
#gameDialog #gameTools button::before,#gameDialog .game-foot .close::before,#gameDialog .game-foot #gameNext::before{
  content:'';position:absolute;inset:0;background:var(--folio-icons) var(--icon-x) var(--icon-y)/400% 200% no-repeat;pointer-events:none;
}
#gameDialog.focused-game .game-foot .close{--icon-x:0%;grid-column:3;grid-row:1;justify-self:end;z-index:auto}
#gameDialog.focused-game .game-foot #gameNext{--icon-x:33.333333%;--icon-y:100%;grid-column:2;grid-row:1;justify-self:center;animation:none}
#gameDialog.focused-game .game-foot #gameNext::after{content:none}
#gameDialog #gameTools :is([data-pk-pause],[data-farm-pause]){--icon-x:66.666667%}
#gameDialog #gameTools :is([data-pk-pause],[data-farm-pause])[aria-pressed=true]{--icon-x:100%}
#gameDialog #gameTools [data-pk-view]{--icon-x:0%;--icon-y:100%}
#gameDialog #gameTools button:hover,#gameDialog .game-foot .close:hover,#gameDialog.focused-game .game-foot #gameNext:hover{background:none;box-shadow:none;transform:translateY(-3px) rotate(-4deg);filter:drop-shadow(0 6px 4px #102d2766) brightness(1.05)}
#gameDialog #gameTools button:active,#gameDialog .game-foot .close:active,#gameDialog.focused-game .game-foot #gameNext:active{transform:scale(.92);filter:drop-shadow(0 2px 2px #102d274d)}
#gameDialog #gameTools button:disabled{opacity:.4;cursor:default;transform:none}
#gameDialog :is(button,[tabindex]):focus-visible{outline:2px dashed #e2c57a;outline-offset:-5px}
/* Preserve the full road, and show the pollination takeaway on completion. */
#gameDialog.rope-game .rope-field{flex:1;min-height:0;border:0;border-radius:0}
#gameDialog.rope-game .rope-meter{flex:none;height:5px;margin:0;border-radius:0;background:#d7dfbb}
#gameDialog.rope-game .rope-success{width:min(78%,640px);height:auto;padding:clamp(18px,4vh,36px) 24px;gap:12px;border:1px solid #e8cd83;border-radius:18px;background:linear-gradient(140deg,#194b3af5,#103b31f5);box-shadow:0 0 0 6px #ffe8a425,0 16px 50px #123f2d77}
#gameDialog.rope-game .rope-success span{display:block;color:#f7d77c;font-size:32px}
#gameDialog.rope-game .rope-success strong{display:block;font:600 clamp(21px,3vw,34px)/1.6 'Songti SC',serif;white-space:normal;letter-spacing:.06em}
#gameDialog.land-game .land-photo-label{display:none}
#gameDialog.land-game .land-handle{border:0;border-radius:46% 54% 43% 57%;background:#f8ebc9;box-shadow:0 4px 12px #15382955;color:#5c6539}
#gameDialog.land-game .land-results{padding-bottom:40px}
#gameDialog .farm-heading,#gameDialog .farm-scene-note,#gameDialog .farm-drag-hint,
#gameDialog .farm-completion>span,#gameDialog .farm-completion>strong,
#gameDialog .drying-caption,
#gameDialog .drone-scan-label{display:none}
#gameDialog .farm-collection{right:18px;top:16px;min-width:0;padding:4px 10px 4px 4px;gap:8px;border:0;border-radius:45% 15% 35% 14%;background:#fff4cce0;box-shadow:0 4px 12px #43542a22}
#gameDialog .farm-collection img{width:48px;height:48px}
#gameDialog .farm-collection>div{min-width:0;width:48px}
#gameDialog .farm-collection>div>span,#gameDialog .farm-collection strong{display:none}

/* The flight view fills the screen, with controls floating directly over the field. */
#gameDialog.drone-game .game-scene-shell{animation:none}
#gameDialog.drone-game .game-foot,#gameDialog.drone-game.focused-complete .game-foot{
  position:absolute;inset:0;width:100%;height:100%;min-height:0;margin:0;padding:0;
  display:block;transform:none;animation:none;background:none;backdrop-filter:none;-webkit-backdrop-filter:none;
  pointer-events:none;z-index:8;
}
#gameDialog.drone-game .game-secondary{display:none}
#gameDialog.drone-game .game-foot .close,#gameDialog.drone-game .game-foot #gameNext{
  position:absolute;pointer-events:auto;filter:none;font-size:13px;color:#fff;
  min-width:0;min-height:0;border-radius:4px;background:none;transform:none;box-shadow:none;
}
#gameDialog.drone-game .game-foot .close{inset:var(--drone-close-top,28px) var(--drone-close-right,32px) auto auto;width:48px;height:48px;border:1px solid #ffffffa0;border-radius:50%;background:#12392bcc;backdrop-filter:blur(8px);font-size:30px;line-height:1}
#gameDialog.drone-game .game-foot #gameNext{inset:auto auto 28px 50%;transform:translateX(-50%);width:var(--folio-control);height:var(--folio-control);padding:0;border:0;border-radius:50%;font-size:0;color:transparent;text-shadow:none;filter:drop-shadow(0 4px 3px #102d274d)}
#gameDialog.drone-game .game-foot .close::before{content:none}
#gameDialog.drone-game .game-foot .close:hover{border-color:#fff;filter:none;color:#c7ffdc}
#gameDialog.drone-game .game-foot #gameNext:hover{transform:translateX(-50%) translateY(-3px) rotate(-4deg);filter:drop-shadow(0 6px 4px #102d2766) brightness(1.05)}
#gameDialog.drone-game .game-foot #gameNext:active{transform:translateX(-50%) scale(.92);filter:drop-shadow(0 2px 2px #102d274d)}
#gameDialog.drone-game.drone-entering .game-foot{visibility:hidden}
#gameDialog.drone-game .drone-map-panel{top:74px}
#gameDialog.drone-game .drone-scan{min-width:84px;bottom:28px;gap:0}
/* The frame is outside the video; intrinsic aspect ratio always stays intact. */
.farmer-interview-dialog[open]{
  --folio-icons:var(--media-317763ae7e);
  inset:auto;left:50%;top:50%;margin:0;padding:0;
  width:var(--interview-frame-width,720px);height:auto;max-width:none;max-height:none;
  border:0;border-radius:0;overflow:hidden;background:transparent;box-shadow:none;transform:translate(-50%,-50%);
}
.farmer-interview-dialog .interview-heading{display:none}
.farmer-interview-dialog .interview-scene-shell{position:relative;width:var(--interview-frame-width);height:var(--interview-frame-height);isolation:isolate;animation:folio-unfold .55s cubic-bezier(.2,.8,.2,1) both;filter:drop-shadow(0 8px 10px #102d274d)}
.farmer-interview-dialog .interview-scene-shell::after{content:'';position:absolute;inset:0;z-index:2;background:var(--media-9f54bfbd2e) center/100% 100% no-repeat;pointer-events:none}
.farmer-interview-dialog video{position:absolute;z-index:1;left:6%;top:10%;width:var(--video-width);height:var(--video-height);max-height:none;aspect-ratio:auto;border-radius:2px;background:transparent;object-fit:contain}
.farmer-interview-dialog .interview-controls{display:flex;justify-content:flex-end;align-items:center;height:76px;padding:0 5%;background:none}
.farmer-interview-dialog .close{position:relative;inset:auto;display:grid;place-items:center;flex:none;width:76px;height:76px;padding:0;border:0;border-radius:50%;font-size:0;color:transparent;background:none;box-shadow:none;filter:drop-shadow(0 4px 3px #102d274d);transition:transform .2s}
.farmer-interview-dialog .close::before{content:'';position:absolute;inset:0;background:var(--folio-icons) 0 0/400% 200%;pointer-events:none}
.farmer-interview-dialog .close:hover{transform:rotate(-5deg)}
.farmer-interview-dialog .close:active{transform:scale(.92)}
.farmer-interview-dialog .farmer-interview-status{position:absolute;width:1px;height:1px;margin:0;padding:0;overflow:hidden;clip-path:inset(50%)}
@keyframes folio-unfold{from{opacity:0;transform:translateY(12px) scale(.96)}to{opacity:1;transform:none}}
@keyframes folio-controls-in{from{opacity:0;translate:0 6px}to{opacity:1;translate:0 0}}
@media(max-height:600px),(orientation:portrait) and (max-width:760px){
  #gameDialog{--folio-rail:60px;--folio-control:60px}
  #gameDialog.focused-game[open]{width:calc(100vw - 16px);height:calc(100dvh - 16px)}
  #gameDialog.drone-game[open]{width:100vw;height:100dvh}
  #gameDialog.focused-game .game-foot,
  #gameDialog.focused-game.focused-complete .game-foot,
  #gameDialog.land-game.focused-complete:not(.land-results-ready) .game-foot{padding:0 4%;gap:6px}
  #gameDialog #gameTools,#gameDialog #gameTools>div{gap:0}
  #gameDialog.rope-game .rope-meter{height:4px}
  #gameDialog.rope-game .rope-success{padding:16px 24px;gap:6px}
  #gameDialog .farm-collection{top:8px;right:12px}
  #gameDialog.drone-game .drone-map-panel{top:54px;width:112px}
  #gameDialog.drone-game .drone-mini-map{height:52px}
  #gameDialog.drone-game .drone-reticle{width:62px;height:62px}
  #gameDialog.drone-game .drone-scan{bottom:19px;gap:0}
  #gameDialog.drone-game .drone-evidence{bottom:14px;width:110px}
  #gameDialog.drone-game .drone-photo-list{height:62px}
  #gameDialog.drone-game .drone-photo-slot{width:90px;height:60px}
  #gameDialog.drone-game .game-foot .close{inset:var(--drone-close-top,22px) var(--drone-close-right,26px) auto auto;width:48px;height:48px;font-size:30px}
  #gameDialog.drone-game .game-foot #gameNext{bottom:19px}
  .farmer-interview-dialog .interview-controls{height:60px}
  .farmer-interview-dialog .close{width:60px;height:60px}
}
@media(orientation:portrait) and (max-width:760px){
  #gameDialog.focused-game[open]{left:50vw;top:50dvh;width:calc(100dvh - 16px);height:calc(100vw - 16px);transform:translate(-50%,-50%) rotate(90deg)}
  #gameDialog.drone-game[open]{width:100dvh;height:100vw}
  .farmer-interview-dialog[open]{left:50vw;top:50dvh;transform:translate(-50%,-50%) rotate(90deg)}
}
@media(prefers-reduced-motion:reduce){
  #gameDialog .game-scene-shell,.farmer-interview-dialog .interview-scene-shell,
  #gameDialog.focused-game .game-foot,
  #gameDialog.focused-game.focused-complete .game-foot,
  #gameDialog.land-game.focused-complete:not(.land-results-ready) .game-foot{animation:none}
  #gameDialog button,.farmer-interview-dialog .close{transition:none}
}

/* Full-screen games. Keep the flight view and other scroll windows independent. */
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game){
  --window-width:100vw;--window-height:100dvh;
  --window-top:env(safe-area-inset-top,0px);--window-right:env(safe-area-inset-right,0px);
  --window-bottom:env(safe-area-inset-bottom,0px);--window-left:env(safe-area-inset-left,0px);
  --window-gap:20px;--window-control:76px;
}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game)[open]{
  inset:auto;left:50vw;top:50dvh;margin:0;
  width:var(--window-width);height:var(--window-height);max-width:none;max-height:none;
  padding:0;border:0;border-radius:0;box-shadow:none;overflow:hidden;
  transform:translate(-50%,-50%);display:block;background:#e7edce;
}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-scene-shell{position:absolute;inset:0;animation:none}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-scene-shell::before{display:none}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-board{inset:0;width:100%;height:100%;clip-path:none}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-foot,
#gameDialog.focused-game.focused-complete:not(.drone-game):not(.land-game):not(.rope-game) .game-foot{
  position:absolute;inset:0;display:block;width:100%;height:100%;min-height:0;
  padding:0;margin:0;background:none;backdrop-filter:none;-webkit-backdrop-filter:none;
  transform:none;animation:none;pointer-events:none;z-index:8;
}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-secondary{
  position:absolute;left:calc(var(--window-left) + var(--window-gap));
  bottom:calc(var(--window-bottom) + var(--window-gap));pointer-events:auto;
}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-foot .close{
  position:absolute;inset:calc(var(--window-top) + var(--window-gap)) calc(var(--window-right) + var(--window-gap)) auto auto;
  pointer-events:auto;
}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-foot #gameNext{
  position:absolute;inset:auto auto calc(var(--window-bottom) + var(--window-gap)) 50%;
  transform:translateX(-50%);pointer-events:auto;
}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-foot #gameNext:hover{transform:translateX(-50%) translateY(-3px) rotate(-4deg)}
#gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game) .game-foot #gameNext:active{transform:translateX(-50%) scale(.92)}
#gameDialog.harvest-game .farm-collection{top:calc(var(--window-top) + var(--window-gap));right:calc(var(--window-right) + var(--window-gap) + var(--window-control) + 12px)}
#gameDialog.harvest-game .farm-drag-hint{bottom:auto;transform:none;padding:0;border:0;border-radius:0;background:none;box-shadow:none;max-width:calc(100% - 24px);width:max-content;z-index:4}
#gameDialog.harvest-game .farm-drag-hint:not([hidden]){display:block}
#gameDialog.harvest-game .farm-drag-copy{display:block;padding:9px 15px;border:1.5px solid #e6cf89;border-radius:24px;background:#fff9e8f2;color:#42613a;box-shadow:0 3px 10px #304b3540}
.farm-drag-gesture{position:absolute;left:0;bottom:calc(100% - 8px);width:120px;height:65px;pointer-events:none}
.farm-drag-hand{position:absolute;left:0;top:0;width:64px;height:64px;background:var(--media-c069c0cc98) 0 0/200% 100% no-repeat;filter:drop-shadow(0 1px 1px #25492f) drop-shadow(0 2px 3px #fff9dd);animation:farm-hand-drag 1.6s ease-in-out infinite}
.farm-drag-gesture svg{position:absolute;left:43px;top:2px;width:70px;height:32px;stroke:#fff7d0;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;filter:drop-shadow(0 1px 2px #375533)}
.farm-harvest-stage.is-paused .farm-drag-gesture{display:none}
body.tap-hints-paused .farm-drag-hand,.farm-drag-hint[hidden] .farm-drag-hand{animation-play-state:paused}
@keyframes farm-hand-drag{0%,15%,100%{transform:translate(0,0)}65%,80%{transform:translate(32px,-8px)}}
@media(prefers-reduced-motion:reduce){.farm-drag-hand{animation:none}}

@media(max-height:600px),(orientation:portrait) and (max-width:760px){
  #gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game){--window-gap:12px;--window-control:60px}
}
@media(orientation:portrait) and (max-width:760px){
  #gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game){
    --window-width:100dvh;--window-height:100vw;
    --window-top:env(safe-area-inset-right,0px);--window-right:env(safe-area-inset-bottom,0px);
    --window-bottom:env(safe-area-inset-left,0px);--window-left:env(safe-area-inset-top,0px);
  }
  #gameDialog.focused-game:not(.drone-game):not(.land-game):not(.rope-game)[open]{transform:translate(-50%,-50%) rotate(90deg)}
}

/* Comfortable touch targets, including when portrait screens rotate the scene. */
#gameDialog.drone-game{--drone-close-top:calc(env(safe-area-inset-top,0px) + 24px);--drone-close-right:calc(env(safe-area-inset-right,0px) + 28px)}
#gameDialog.drone-game .drone-hud.top{right:100px}
#gameDialog.drone-game .drone-map-panel{top:90px;right:28px}
@media(max-height:600px){#gameDialog.drone-game .drone-map-panel{top:84px;width:112px}}
@media(orientation:portrait) and (max-width:760px){
  #gameDialog.drone-game{--drone-close-top:calc(env(safe-area-inset-right,0px) + 22px);--drone-close-right:calc(env(safe-area-inset-bottom,0px) + 26px)}
  #gameDialog.drone-game .drone-map-panel{top:82px;width:112px}
}

/* The carts remain unframed even when the dialog gives the first one focus. */
#gameDialog.rope-game .rope-field .rope-cart:focus{outline:none;box-shadow:none;border:0;background:none}
#gameDialog.rope-game .rope-cart:focus-visible img{filter:drop-shadow(0 0 5px #fff0a0)}
#gameDialog.rope-game .rope-field{container-type:size}
#gameDialog.rope-game .rope-success{width:min(86%,640px);padding:clamp(14px,5cqh,32px) clamp(14px,4cqw,30px);gap:clamp(8px,3cqh,18px)}
#gameDialog.rope-game .rope-success .rope-success-check{font-size:clamp(24px,8cqh,38px);line-height:1}
#gameDialog.rope-game .rope-success strong{display:flex;flex-direction:column;gap:.35em;font-size:clamp(15px,4cqw,32px);line-height:1.45;letter-spacing:.03em}
#gameDialog.rope-game .rope-success strong>span{font:inherit;color:inherit;white-space:nowrap}
