#pond{transform:scale(calc(var(--step-zoom,1) * var(--camera-zoom,1)));transition:transform 650ms ease-in-out,filter 1s ease}
#pond.camera-moving{transition:filter 1s ease}
#rotate-device{display:none;position:fixed;inset:0;z-index:1000;place-items:center;background:#15271e;color:var(--paper);padding:24px;text-align:center;touch-action:none}
#rotate-device .rotate-message{display:grid;justify-items:center;gap:clamp(12px,4vw,22px)}
#rotate-device img{display:block;width:clamp(130px,38vw,220px);height:auto;filter:brightness(0) invert(1)}
#rotate-device p{margin:0;font-size:clamp(17px,4.5vw,21px);line-height:1.25}
@media (any-pointer:coarse) and (orientation:portrait){
 #rotate-device{display:grid}
}
#touch-placement{position:absolute;z-index:2;width:22px;height:22px;translate:-50% -50%;border:2px solid #fffce6;border-radius:50%;box-shadow:0 0 0 1px #192419,0 0 8px #101109;pointer-events:none}
#touch-placement img{position:absolute;left:50%;bottom:100%;translate:-50% -12px;width:48px;height:38px;object-fit:contain;opacity:.78}
@media (any-pointer:coarse){
 #scene{--safe-left:max(8px,env(safe-area-inset-left));--safe-right:max(8px,env(safe-area-inset-right));--left:var(--safe-left);--bottom:max(8px,env(safe-area-inset-bottom));--edge:max(8px,env(safe-area-inset-top));--square:clamp(44px,4.3cqw,62px);--unit:clamp(44px,5cqw,62px);--gap:4px}
 #permanent,#settings-panel,#rock-preview,#ornament-tools{right:var(--safe-right)}
 #stage{top:var(--edge)}
 #selection{right:var(--safe-right)}
 #settings-panel.open{max-height:calc(100dvh - var(--edge) - var(--square) - var(--bottom) - 8px);overflow:auto}
 #settings-panel button,.plant-families button,#adjust{min-height:44px}
 #scene.hidden-ui #permanent #hide-interface{translate:none}
 #start-sound{right:max(10px,env(safe-area-inset-right));top:max(10px,env(safe-area-inset-top));min-width:44px}
 .sel-window{left:max(5.8%,env(safe-area-inset-left));top:max(8%,env(safe-area-inset-top));bottom:max(6%,env(safe-area-inset-bottom))}
 .sel-window nav{height:auto;min-height:44px}
 .sel-window nav button{width:auto;min-width:82px}
}
@media (any-pointer:coarse) and (max-height:540px){
 #scene{--unit:44px;--square:44px}
 #stage{padding:5px 10px;min-width:0;max-width:45%}
 #stage h1{font-size:clamp(18px,3.1cqw,28px)}
 .tool.large{height:48px}
 #tools .tool.wide,#ornament-tools .tool.wide{grid-column:span 1}
 #tools .tool.large,#ornament-tools .tool.large{height:44px}
 #selection:not(.rock-tray) .picker,#selection.rock-tray .picker{height:clamp(124px,33dvh,175px);max-height:none;padding:5px;grid-template-columns:minmax(0,1.6fr) minmax(92px,1fr)}
 #selection.rock-tray .picker{display:block;overflow:auto}
 #selection .items{flex-wrap:nowrap;overflow:auto}
 #selection .item{flex:0 0 69px;height:57px}
 #selection .picker h2,#selection .details h3{font-size:18px}
 #rock-preview{max-height:45dvh}
}

#touch-pan-guide{position:absolute;z-index:6;left:50%;top:54%;translate:-50% -50%;background:#0f261fef;color:var(--paper);padding:10px 16px;border-radius:6px;pointer-events:none;text-align:center;font-size:clamp(14px,2cqw,20px)}
#touch-pan-guide span{display:flex;justify-content:center;gap:0;margin-bottom:6px;animation:pan-demo 1.45s ease-in-out infinite}
#touch-pan-guide img{width:29px;height:auto}
@keyframes pan-demo{0%,100%{transform:translateX(-17px)}50%{transform:translateX(17px)}}

@media (any-pointer:coarse){
 #guidance-tools{top:var(--edge)}
 html[data-input=pointer] :is(dialog, #scene, #pond-picker, #start-screen) button:focus-visible{outline:none}
 #selection.rock-tray{right:auto;min-width:0;max-width:calc(100% - var(--left) - var(--unit)*2 - var(--safe-right) - 30%);overflow:hidden}
 #selection.rock-tray .picker{height:auto;max-height:none;padding:6px}
 #selection.rock-tray .items{justify-content:flex-start}
 #rock-preview:not([hidden]){display:grid;grid-template-rows:minmax(0,1fr) auto;gap:6px;bottom:calc(var(--bottom) + 48px);max-height:none;overflow:hidden;z-index:3}
 #rock-preview .rock-details{overflow:auto;overscroll-behavior:contain;min-height:0}
 #rock-preview #set{width:100%;min-height:44px}
 #scene #name-pond{inset:auto;left:50%;top:var(--save-top,50%);margin:0;translate:-50% -50%;max-height:var(--save-height,calc(100dvh - 16px));overflow:auto}
 #name-pond input{font-size:16px}
}

@media (any-pointer:coarse){
 #explanation.open{pointer-events:none}
 #explanation.open article{
  pointer-events:auto;
  right:max(2.5%,env(safe-area-inset-right));
  top:max(13%,calc(var(--edge) + var(--square) + var(--gap)));
  bottom:max(4%,env(safe-area-inset-bottom));
 }
 #explanation article>*{flex-shrink:0}
}

/* Keep each panel inside the scene and give its content the scrolling area. */
@media (any-pointer:coarse){
 #scene{--panel-top:calc(var(--edge) + var(--square) + 12px)}
 #scene:not(.free){--panel-top:calc(var(--edge) + max(var(--square),var(--header-height,44px)) + 8px)}
 #scene #selection:not(.rock-tray){
  top:auto;bottom:var(--bottom);height:auto;
  max-height:calc(100% - var(--panel-top) - var(--bottom));
  right:var(--safe-right);
 }
 #scene #selection.ornament-menu:not(.rock-tray){
  right:calc(var(--safe-right) + var(--unit)*2 + 8px);
 }
 #scene.free #selection.ornament-menu:not(.rock-tray){right:var(--safe-right)}
 #scene #selection:not(.rock-tray) .picker{
  height:auto;
  min-height:min(460px,calc(100dvh - var(--panel-top) - var(--bottom)));
  max-height:calc(100dvh - var(--panel-top) - var(--bottom));
  grid-template-columns:minmax(0,1.65fr) minmax(0,1fr);
  grid-template-rows:minmax(0,1fr);
 }
 :is(#selection,#feed-menu) :is(.picker-main,.details){min-height:0;min-width:0;overscroll-behavior:contain}
 #scene #selection:not(.rock-tray) .items{flex-wrap:wrap;overflow:visible}
 #scene :is(#selection,#feed-menu) .item{
  flex:0 0 auto;width:clamp(78px,10cqw,120px);height:auto;
  display:grid;grid-template-rows:clamp(45px,5.5cqw,76px) minmax(2.3em,auto);
  justify-items:center;align-items:center;padding:4px;font-size:clamp(13px,1.55cqw,16px);
 }
 #scene :is(#selection,#feed-menu) .item::before{transform:translateY(35%)}
 #scene :is(#selection,#feed-menu) .item[aria-pressed=true]::before{transform:translateY(0)}
 #scene :is(#selection,#feed-menu) .item img{height:100%;max-width:100%;padding:0}
 #scene :is(#selection,#feed-menu) .item span{width:100%;font-size:inherit;line-height:1.15;text-align:center;overflow-wrap:break-word}
 #scene #selection .plant-families{padding-bottom:2px}
 #scene #selection .plant-families button[aria-pressed=true]{color:var(--paper)}
 #scene.free #tools{--unit:var(--square)}
 #scene.free [data-tool=back]{display:none}

 #journal header{z-index:1}
 #journal header img{width:clamp(84px,9.3cqw,180px)}
 #journal .journal-pages{position:absolute;inset:var(--panel-top) var(--safe-right) var(--bottom) var(--safe-left);overflow:auto;overscroll-behavior:contain}
 #journal #book{position:relative;left:auto;bottom:auto;margin-inline:auto;width:min(100%,calc((100dvh - var(--book-top,var(--panel-top)) - var(--bottom)) * 1478 / 1064))}
 #journal .journal-pages{top:var(--book-top,var(--panel-top));inset-inline:max(var(--safe-left),var(--safe-right))}
 #journal :is(#page-prev,#page-next){min-height:36px;min-width:36px}
 .journal-pages #book{container-type:inline-size}
 .journal-pages #book .entry{font-size:2.3cqw;padding-top:5.4cqw}
 .journal-pages #book .entry img{height:19.4cqw;flex-basis:19.4cqw}
 .journal-pages #book .page-marks{height:5.4cqw}
 .journal-pages #book .page-marks img{height:auto;max-width:12cqw;max-height:5.4cqw;flex:none}
 .journal-pages #book .page-marks img:last-child{width:3.5cqw}
 .journal-pages #book .entry h2{font-size:4.1cqw}
 .journal-pages #book .entry i{font-size:2.15cqw}
 .journal-pages #book .entry p{font-size:1.65cqw}
 .journal-pages #book .contents-links h2{font-size:4.2cqw}
 .journal-pages #book .contents-links button{font-size:3.1cqw}
 .journal-pages #book .ownership strong{font-size:1.2cqw}
 .journal-pages #book .ownership p{font-size:1.1cqw}
 .journal-pages #book :is(.ownership>em,.counts em){font-size:2cqw}
 .journal-pages #book .ownership input{font-size:2.85cqw}

 #population-panel{
  left:50%;translate:-50% 0;top:var(--panel-top);bottom:var(--bottom);
  width:min(560px,calc(100% - var(--safe-left) - var(--safe-right)));height:auto;padding:12px;
 }
 #population-panel{background:#090909;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;scrollbar-width:thin;scrollbar-color:#514b40 #080808}
 #population-panel header{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:8px;margin-bottom:8px;flex:none}
 #population-panel .population-capacity{gap:6px}
 #population-summary{flex:none}
 #population-list{min-width:0;overflow:visible;flex:none}
 .pop-row i{min-width:0;overflow-wrap:anywhere}
 #population-panel h2{font-size:clamp(21px,3cqw,36px)}
 #population-panel .capacity small{font-size:11px}
 #population-panel .capacity strong{font-size:14px}
 #population-panel .capacity-ring{width:28px;height:28px;flex:none}
 #population-close{width:52px;height:44px;flex:none}
 #population-summary{grid-template-columns:repeat(4,minmax(0,94px));justify-content:center;gap:clamp(4px,1cqw,8px)}
 #population-summary .pop-counter{aspect-ratio:1;min-width:0;padding:8px}
 .pop-counter i,.pop-counter small{font-size:clamp(10px,1.55cqw,14px);overflow-wrap:anywhere}
 .pop-counter strong{font-size:clamp(22px,4cqw,44px)}
 #population-list h3{font-size:clamp(16px,2.1cqw,25px)}
 #population-panel .pop-row{
  display:grid;grid-template-columns:40px minmax(0,1fr) minmax(44px,auto);
  height:auto;min-height:54px;margin-bottom:6px;padding:4px 10px;gap:8px;
  border:1px solid #50483e;background:#10100e;
 }
 .pop-row i{font-size:clamp(14px,1.8cqw,22px)}
 .pop-row img{width:100%;height:36px}
 .pop-row button{height:auto;min-width:44px;min-height:44px;padding:0 4px;font-size:16px;font-variant-numeric:tabular-nums}

 #scene #selection .details img{display:block;height:clamp(68px,27dvh,170px);width:100%;object-fit:contain}
 #scene #selection .details img.texture{object-fit:cover}
 #scene #wild-card:not([hidden]){
  top:var(--panel-top);bottom:var(--bottom);right:var(--safe-right);
  width:clamp(236px,39%,420px);height:auto;
  justify-content:flex-start;gap:9px;padding:12px;
  overflow:auto;overscroll-behavior:contain;
 }
 #scene #wild-card>*{flex:none}
 #scene #wild-card h2{font-size:clamp(21px,3cqw,36px)}
 #scene #wild-card :is(small,i,p){font-size:clamp(14px,1.7cqw,18px)}
 #scene #wild-card img{height:clamp(68px,23dvh,150px)}
 #scene #wild-card #wild-record{min-height:44px;font-size:16px;padding:5px 9px;gap:8px;text-align:left}
 #scene #wild-card .record-count{font-size:13px}
 #scene #wild-card .record-count svg{width:15px;height:15px}
 #scene #wild-card #wild-close{min-height:44px}
 #feed-menu{top:var(--panel-top);bottom:var(--bottom);left:max(12%,var(--safe-left));right:max(12%,var(--safe-right));width:auto;height:auto;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);padding:10px}
 #feed-menu .items{display:flex;flex-wrap:wrap}
 #feed-menu .details{display:block}
 #feed-menu .details img{height:clamp(68px,24dvh,155px);max-height:none}
 #feed-menu .picker-main h2{font-size:clamp(20px,3cqw,36px)}
 #scene :is(#selection,#feed-menu) .details{
  padding:clamp(12px,2.2cqw,25px);
  min-height:0;overflow:auto;overscroll-behavior:contain;
 }
 #scene :is(#selection,#feed-menu) .details h3,#scene #rock-preview h2{
  font-size:clamp(23px,3.2cqw,39px);line-height:1.08;margin:0;
 }
 #scene #selection .details h3+i{display:block;margin-top:4px;color:#d0bfad;font-size:clamp(12px,1.55cqw,16px)}
 #scene :is(#selection,#feed-menu) .details img,#scene #rock-preview img{margin-block:clamp(14px,2.2cqw,23px)}
 #scene :is(#selection,#feed-menu) .details p,#scene #rock-preview p{
  margin:0 0 1em;font-size:clamp(14px,1.75cqw,18px);line-height:1.5;overflow-wrap:anywhere;
 }
 #scene #selection .details footer{padding-top:.85em;margin-bottom:1em}
 #scene #rock-preview:not([hidden]){top:var(--panel-top);bottom:var(--bottom);width:clamp(200px,30%,400px);padding:clamp(12px,2cqw,23px)}
 #scene #rock-preview img{height:auto;object-fit:contain}
 #scene #name-pond[open]{
  inset:auto;
  top:var(--save-center-y,50%);left:var(--save-center-x,50%);
  translate:-50% -50%;margin:0;
  min-width:0;width:min(360px,calc(var(--save-width,100vw) - var(--safe-left) - var(--safe-right)));
  max-height:calc(var(--save-height,100dvh) - 2 * max(8px,env(safe-area-inset-top),env(safe-area-inset-bottom)));
  overflow:auto;overscroll-behavior:contain;
 }
 #name-pond input{min-height:32px;margin-bottom:8px}
 #name-pond form{padding:10px 16px}
 #name-pond form h2{margin-bottom:4px}
 #name-pond footer button{min-height:44px}
 #scene #name-pond.short-viewport[open]{
  width:min(520px,calc(var(--save-width,100vw) - var(--safe-left) - var(--safe-right)));
  max-height:calc(var(--save-height) - max(4px,env(safe-area-inset-top)) - max(4px,env(safe-area-inset-bottom)));
 }
 #name-pond.short-viewport form{display:flex;align-items:center;gap:8px;padding:4px 12px}
 #name-pond.short-viewport :is(h2,label){position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
 #name-pond.short-viewport input{flex:1;min-width:0;width:auto;margin:0;text-align:left}
 #name-pond.short-viewport footer{flex:none;gap:6px}
 #name-pond.short-viewport footer button{padding-inline:12px}

 .photography{position:fixed;inset:0;translate:none;width:100%;height:100dvh;aspect-ratio:auto}
 .photography{--photo-controls:clamp(244px,35vw,360px);--photo-right:max(8px,env(safe-area-inset-right))}
 .photography .photo-stage{
  left:max(8px,env(safe-area-inset-left));right:calc(var(--photo-controls) + var(--photo-right) + 8px);
  top:env(safe-area-inset-top);bottom:env(safe-area-inset-bottom);
 }
 .photography.quiet-photo .photo-stage{right:var(--photo-right)}
 .photography .photo-panel{
  right:max(8px,env(safe-area-inset-right));top:max(8px,env(safe-area-inset-top));bottom:max(8px,env(safe-area-inset-bottom));
  width:var(--photo-controls);max-width:calc(100% - 16px);gap:8px;padding:10px;font-size:15px;
 }
 .photography .photo-panel h2{font-size:22px}
 .photography .photo-panel :is(button,label){min-height:44px}
 .photography .photo-panel button:is([data-act=grid],[data-act=hide]){min-width:44px;flex:none}
 .photography .photo-scroll{overflow-x:hidden}
 .photography .photo-panel :is(.aids,.ratios){gap:4px}
 .photography .photo-panel .photo-zoom input{min-width:0}
 .photography .photo-panel label{overflow-wrap:anywhere}
 .photography .photo-panel label:has([role=switch]){gap:6px}
 .photography .photo-panel button[role=switch]{
  flex:0 0 44px;width:44px;height:44px;min-width:44px;
  background:transparent;padding:0;
 }
 .photography .photo-panel button[role=switch]::before{
  content:'';position:absolute;left:5px;top:13px;width:34px;height:18px;
  border-radius:999px;background:#737478;transition:background .2s;
 }
 .photography .photo-panel button[role=switch]::after{
  left:7px;top:15px;width:14px;height:14px;opacity:1;
 }
 .photography .photo-panel button[role=switch][aria-checked=true]::before{background:#ffde17}
 .photography .photo-panel button[role=switch][aria-checked=true]::after{transform:translateX(16px)}
 .photography .photo-panel fieldset{min-width:0;margin:8px 0;padding:8px}
 .photography .photo-panel :is(legend,.recipes button){font-size:16px}
 .photography .photo-panel [data-act=capture]{font-size:20px}
 .photography .photo-panel input[type=range]{height:44px;width:55%}
 .photography .photo-panel input[type=range]::-webkit-slider-thumb{width:22px;height:22px;margin-top:-10px}
 .photography .photo-panel input[type=range]::-moz-range-thumb{width:22px;height:22px}
 .photography .photo-restore{right:max(8px,env(safe-area-inset-right));top:max(8px,env(safe-area-inset-top));min-width:44px;min-height:44px}
}

@media (any-pointer:coarse) and (min-aspect-ratio:19/10){
 #scene #journal{--book-top:var(--edge);--book-width:calc((100dvh - var(--edge) - var(--bottom)) * 1478 / 1064)}
 #journal header{
  flex-wrap:wrap;
  max-width:max(var(--square),calc((100% - var(--book-width)) / 2 - var(--safe-left) - 8px));
  gap:5px;padding:4px;
 }
 #journal header img{max-width:100%;height:auto}
 #scene.journal-open #permanent{visibility:hidden}
}
