main>#studio{width:min(100%,1100px);margin:auto;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto 60px 40px 18px;max-height:calc(100vw + 310px)}
#studio>.boardrow{grid-row:1}
#frogPanel{grid-row:2;position:relative;justify-self:center;width:min(100%,610px);height:clamp(71px,10vh,108px);pointer-events:none;z-index:6}
#frogActor{--size:clamp(124px,17.5vh,186px);--aim:0deg;--sway:0px;position:absolute;width:var(--size);height:var(--size);left:clamp(4px,2%,16px);bottom:-2px;pointer-events:none;user-select:none;transition:translate .42s cubic-bezier(.18,.62,.25,1);translate:var(--sway) 0}
.frog-bounce,.frog-pose{width:100%;height:100%;position:relative;transform-origin:50% 96%}
.frog-pose{transition:transform .4s cubic-bezier(.19,.8,.32,1.18)}
#frogActor img{display:block;pointer-events:none}
.frog-torso,.frog-arm,#frogFace{position:absolute}
.frog-torso{top:45%;left:24%;width:45%;height:54%}
.frog-arm{transition:transform .36s cubic-bezier(.23,.67,.25,1.2)}
.open-hand{top:49%;left:6%;width:32%;height:44%;transform-origin:89% 11%;transform:rotate(-13deg)}
.pointing-hand{top:48%;left:61%;width:37%;height:24%;transform-origin:10% 18%;transform:rotate(23deg)}
#frogFace{top:2%;left:14%;width:65%;height:49%;transform-origin:50% 89%;transition:transform .33s ease}
#frogFace img{position:absolute;inset:0;width:100%;height:100%}
#frogFace .lip{opacity:0;transition:opacity 38ms linear}
#frogFace[data-mouth="1"] .lip-a,#frogFace[data-mouth="2"] .lip-o,#frogFace[data-mouth="3"] .lip-e{opacity:1}
.frog-brows,.frog-blink{position:absolute;inset:0 0 auto;height:45.12%;background-size:100% 100%;mask-image:linear-gradient(#000 92%,transparent)}
.frog-blink{opacity:0;background-image:url(frog/blink.webp);animation:frog-blink 5.1s infinite}
[data-mood=surprise] .frog-brows{background-image:url(frog/surprise.webp)}
[data-mood=worry] .frog-brows{background-image:url(frog/worry.webp)}
[data-mood=alert] .frog-brows{background-image:url(frog/alert.webp)}
[data-mood=joy] .frog-brows{background-image:url(frog/joy.webp)}
[data-mood=surprise] .frog-pose{transform:translateY(-9%) rotate(-7deg)}
[data-mood=surprise] .open-hand{transform:rotate(83deg)}
[data-mood=surprise] .pointing-hand{transform:rotate(-65deg)}
[data-mood=surprise] #frogFace{transform:translateY(-4%) scale(1.07)}
[data-mood=joy] .frog-pose{transform:rotate(5deg)}
[data-mood=joy] .open-hand{transform:rotate(96deg)}
[data-mood=joy] .pointing-hand{transform:rotate(-77deg)}
[data-mood=worry] .frog-pose{transform:translateY(4%) rotate(9deg) scale(.97,.91)}
[data-mood=worry] .open-hand{transform:rotate(-43deg)}
[data-mood=worry] .pointing-hand{transform:rotate(-102deg)}
[data-mood=alert] .frog-pose,[data-pointing=true] .frog-pose{transform:translateY(-6%) rotate(-5deg)}
[data-pointing=true] .pointing-hand{transform:rotate(var(--aim))}
[data-mood=alert] #frogFace{transform:rotate(-8deg)}
/* The camera, body and joints have independent rhythms; the board stays still. */
.frog-camera{height:100%;width:100%;transform-origin:42% 96%}
@media(prefers-reduced-motion:no-preference){
 .frog-camera{animation:frog-dolly 8.4s ease-in-out infinite}
 .frog-bounce{animation:frog-weight 3.3s ease-in-out infinite}
 #frogFace{animation:frog-look 4.9s ease-in-out infinite}
 .open-hand{animation:frog-wrist 2.8s ease-in-out infinite}
 .pointing-hand{animation:frog-elbow 3.7s ease-in-out infinite}
 [data-pointing=true] .pointing-hand{animation:none}
 [data-talking=true] .frog-bounce{animation:frog-emphasis 1.85s ease-in-out infinite}
 [data-talking=true] .open-hand{animation:frog-explain 1.44s ease-in-out infinite}
 [data-talking=true] #frogFace{animation:frog-nod 1.24s ease-in-out infinite}
}
@keyframes frog-dolly{
 0%,100%{transform:scale(1)} 20%{transform:scale(1.06)} 51%{transform:scale(1.34)} 66%{transform:scale(1.27)} 86%{transform:scale(1.02)}
}
@keyframes frog-weight{
 0%,100%{transform:translate(-1%,0) rotate(-2deg) scale(1.015,.99)}
 32%{transform:translate(2%,-3%) rotate(2deg) scale(.99,1.035)}
 70%{transform:translate(1%,.5%) rotate(.4deg) scale(1.025,.985)}
}
@keyframes frog-look{0%,100%{rotate:-3deg}38%{rotate:5deg}72%{rotate:1deg}}
@keyframes frog-nod{0%,100%{rotate:-4deg;translate:0 0}34%{rotate:4deg;translate:0 3%}68%{rotate:1deg;translate:0 -2%}}
@keyframes frog-wrist{0%,100%{rotate:-4deg}45%{rotate:16deg}}
@keyframes frog-elbow{0%,100%{rotate:0deg}55%{rotate:-13deg}}
@keyframes frog-explain{0%,100%{rotate:2deg}28%{rotate:36deg}53%{rotate:19deg}72%{rotate:43deg}}
@keyframes frog-emphasis{
 0%,100%{transform:translate(-2%,0) rotate(-3deg)}
 22%{transform:translate(1%,1%) rotate(2deg) scale(1.04,.96)}
 41%{transform:translate(3%,-5%) rotate(4deg) scale(.985,1.04)}
 68%{transform:translate(0,-1%) rotate(-1deg)}
}
@keyframes frog-blink{0%,43%,47%,100%{opacity:0}45%{opacity:1}}
@media(max-width:650px){#frogPanel{height:clamp(64px,9vh,87px)}#frogActor{--size:clamp(106px,15vh,146px)}}
@media(max-height:550px){main>#studio{grid-template-rows:minmax(0,1fr) auto 46px 28px 14px}#frogPanel{height:39px}#frogActor{--size:70px}}
@media(prefers-reduced-motion:reduce){#frogActor,.frog-bounce,.frog-pose,.frog-arm,#frogFace,.frog-blink{animation:none!important;transition:none!important;translate:none!important}.frog-pose{transform:none!important}}

.frog-expression{position:absolute;inset:0;background-image:url(frog/expressions.webp);background-size:400% 300%;background-position:var(--portrait-x,33.333%) var(--portrait-y,100%)}
[data-talking=true] .frog-expression{background-image:url(frog/rest.webp);background-size:100% 100%;background-position:center}
[data-talking=true] [data-mouth="1"] .frog-expression{background-image:url(frog/open.webp)}
[data-talking=true] [data-mouth="2"] .frog-expression{background-image:url(frog/round.webp)}
[data-talking=true] [data-mouth="3"] .frog-expression{background-image:url(frog/wide.webp)}

/* Collar registration keeps the independent head attached across all 16 drawings. */
.frog-gesture{position:absolute;left:14%;top:34%;width:68%;height:68%;background:url(frog/body-gestures.webp) 0 var(--gesture-row,0%) / 400% 400%;transform-origin:50% 93%}
#frogActor:not([data-pointing=true]) :is(.frog-arm,.frog-torso){visibility:hidden}
#frogActor[data-pointing=true] .frog-gesture{visibility:hidden}
#frogActor[data-mood=worry]{--gesture-row:33.333333%}
#frogActor[data-mood=surprise],#frogActor[data-mood=alert]{--gesture-row:66.666667%}
#frogActor[data-mood=joy]{--gesture-row:100%}
@media(prefers-reduced-motion:no-preference){
 .frog-gesture{animation:gesture-drawings 3.4s steps(1,end) infinite,gesture-breathe 2.4s ease-in-out infinite}
 [data-talking=true] .frog-gesture{animation-duration:1.85s,1.45s}
 [data-mood=joy] .frog-bounce{animation:gesture-hop 2.1s ease-in-out infinite}
 [data-mood=worry] #frogFace{animation:gesture-question 2.6s ease-in-out infinite}
}
@keyframes gesture-drawings{0%,100%{background-position-x:0%}15%,76%{background-position-x:33.333333%}30%{background-position-x:66.666667%}61%,87%{background-position-x:100%}}
@keyframes gesture-breathe{0%,100%{transform:rotate(-1deg) scale(1,.99)}50%{transform:rotate(1deg) scale(1.01,1.02)}}
@keyframes gesture-hop{0%,60%,100%{transform:none}15%{transform:scale(1.04,.94)}32%{transform:translateY(-8%) rotate(3deg)}47%{transform:scale(1.03,.96)}}
@keyframes gesture-question{0%,100%{rotate:-4deg}44%{rotate:9deg;translate:2% -2%}73%{rotate:5deg}}
@media(prefers-reduced-motion:reduce){.frog-gesture{background-position-x:66.666667%}}

#frogPanel{width:100%}
#frogTravel{position:absolute;left:0;bottom:0;width:0;height:0;transform:translate(var(--walk-x,0px),var(--walk-y,0px));transition:transform .92s cubic-bezier(.42,0,.23,1);pointer-events:none}
#frogActor{left:0;translate:none}
@media(prefers-reduced-motion:reduce){#frogTravel{transition:none}}

/* In portrait the board sets the layout; transport controls follow in normal flow. */
@media (max-width:760px) and (orientation:portrait){
 main:has(>#studio:not([hidden])){display:block;overflow:auto}
 main>#studio{height:auto;max-height:none;width:100%;grid-template-rows:auto auto auto auto auto;row-gap:4px}
 #studio>.boardrow{container-type:normal;justify-content:flex-start;gap:2px;width:100%}
 #studio .boardstage,#studio .boardrow>.meter,#studio .boardrow>#history{width:100%;max-width:none}
 #studio .boardstage{flex:none}
 #studio #board{width:100%;aspect-ratio:1}
 #studio .boardrow>#history{height:14px}
 #studio .boardrow>.meter{height:21px;min-height:21px}
 #studio #frogPanel{height:clamp(48px,9dvh,70px)}
 #studio .audioctrl{min-height:52px}
 #studio .transport{min-height:40px}
}
@media (orientation:landscape) and (max-height:500px) and (max-width:1000px){
 main>#studio{grid-template-columns:minmax(0,1fr) minmax(150px,30%);grid-template-rows:minmax(0,1fr) auto auto auto;max-height:none}
 #studio>.boardrow{grid-area:1/1/-1/2}
 #studio>#frogPanel{grid-area:1/2;align-self:end}
 #studio>.audioctrl{grid-area:2/2;flex-wrap:wrap}
 #studio>.transport{grid-area:3/2}
 #studio>#speechStatus{grid-area:4/2}
 #studio .boardrow>#history{height:12px}
 #studio .boardrow>.meter{height:18px;min-height:18px}
 #studio .boardstage,#studio .boardrow>.meter,#studio .boardrow>#history{width:min(100cqw,calc(100cqh - 36px))}
}

#studio>.audioctrl{justify-content:flex-start}
#studio .audioctrl #listen{width:48px;height:48px;min-width:48px;min-height:48px;flex:0 0 48px;padding:0;display:grid;place-items:center}
#frogActor{--size:clamp(162px,22vh,226px)}
@media (max-width:760px) and (orientation:portrait){
 main>#studio{grid-template-rows:auto auto auto auto}
 #studio>#frogPanel{grid-area:2/1;height:clamp(100px,16dvh,135px)}
 #studio>.audioctrl{grid-area:2/1;align-self:end;justify-self:start;z-index:7;min-height:48px}
 #studio>.transport{grid-area:3/1}
 #studio>#speechStatus{grid-area:4/1}
 #frogActor{--size:clamp(155px,44vw,196px)}
}
@media (max-height:500px) and (orientation:landscape){#frogActor{--size:clamp(90px,32dvh,142px)}}

body:has(#studio:not([hidden])) header .players{grid-template-columns:minmax(0,1fr)}
#topPlayer,#bottomPlayer{font:650 14px/22px system-ui;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--ink)}
#bottomPlayer{height:22px;padding-inline:6px;background:var(--page);position:relative;z-index:8;width:fit-content;max-width:100%;border-radius:0 0 5px 0}
@media (min-width:761px),(orientation:landscape){
 #studio .boardrow>.boardstage,#studio .boardrow>.meter,#studio .boardrow>#history{width:min(100cqw,calc(100cqh - 87px))}
}
@media (orientation:landscape) and (max-height:500px) and (max-width:1000px){
 #studio .boardrow>.boardstage,#studio .boardrow>.meter,#studio .boardrow>#history{width:min(100cqw,calc(100cqh - 58px))}
}

#voiceProgress{width:70px;height:7px;accent-color:var(--pine)}
#listen:disabled{opacity:.45}

#studio #frogPanel{height:clamp(190px,27vh,263px);z-index:10}
#studio>.audioctrl,#studio>.transport{position:relative;z-index:11}
#studio #frogPanel .frog-camera{animation:none}
#studio #openingPortrait{position:absolute;left:calc(var(--size) * .91);bottom:14%;width:clamp(48px,14vw,78px);margin:0;text-align:center;color:var(--ink);font:600 11px/1.15 system-ui}
#openingPortrait img{width:100%;height:auto;max-height:88px;object-fit:contain;border-radius:6px}
#openingPortrait figcaption{margin-top:3px}
@media(max-width:760px) and (orientation:portrait){#studio #frogPanel{height:clamp(175px,49vw,218px)}}
@media(orientation:landscape) and (max-height:500px){#studio #frogPanel{height:clamp(100px,35dvh,155px)}}

/* The board and the shared mascot/control area fit the height of the studio. */
@media (max-width:760px) and (orientation:portrait){
 main:has(>#studio:not([hidden])){display:block;overflow:hidden;container-type:size}
 main>#studio{
  --board-width:min(100cqw,calc(100cqh - 125px - env(safe-area-inset-bottom)));
  height:100%;min-height:0;max-height:none;
  grid-template-rows:auto minmax(0,1fr) auto;row-gap:0;
  padding-bottom:env(safe-area-inset-bottom);
 }
 #studio>.boardrow{align-items:center;align-self:start;gap:2px}
 #studio .boardrow>.boardstage,#studio .boardrow>.meter,#studio .boardrow>#history{width:var(--board-width)}
 #studio>#frogPanel{grid-area:2/1;height:100%;min-height:0;container-type:size}
 #studio #frogActor{--size:min(44vw,196px,calc(100cqh + 12px))}
 #studio>.audioctrl,#studio>.transport{grid-area:2/1;align-self:end;margin:0;padding:0;min-height:44px}
 #studio>.audioctrl{justify-self:start}
 #studio>.transport{justify-self:center;width:max-content;max-width:calc(100% - 104px);gap:4px;z-index:12}
 #studio .transport button{min-width:40px;min-height:44px;padding:0 8px}
 #studio .transport:has(#bestPreview:not([hidden])){justify-self:end;max-width:calc(100% - 54px)}
 #studio .transport .navmove:disabled{opacity:1;color:#a9b6ae;background:#edf1ed}
 #studio>#speechStatus{grid-area:3/1;min-height:0;max-height:16px}
}
#frogPanel[data-scene]:not([data-scene=""]){background-size:cover;background-position:center 58%;background-repeat:no-repeat}
#frogPanel[data-scene]:not([data-scene=""]) #openingPortrait figcaption{background:#fffcf1ef;border-radius:4px;color:#18372b}

/* Shared contact plane: every scene and mascot use the same floor. */
#studio #frogPanel{width:min(100%,760px);isolation:isolate;border-radius:12px;overflow:hidden;background-position:center bottom;background-size:cover}
#frogTravel{bottom:12%;z-index:2}
#frogActor{bottom:-2px}
#frogActor::before{content:"";position:absolute;left:27%;bottom:0;width:48%;height:5%;border-radius:50%;background:radial-gradient(ellipse,#14261980,transparent 70%);z-index:-1}
#studio #frogPanel .frog-bounce,#studio #frogPanel .frog-pose{animation:none;transform:none;transform-origin:50% 98%}
#studio #frogPanel .frog-gesture{animation:gesture-drawings 3.4s steps(1,end) infinite;transform:none}
#studio #frogPanel [data-walking=true] .frog-bounce{animation:grounded-step .30s ease-in-out infinite}
@keyframes grounded-step{0%,100%{transform:rotate(-1deg) scale(1,.99)}50%{transform:rotate(1deg) scale(1,1)}}
#studio .boardrow>#history{display:none}
#topPlayer,#bottomPlayer{background:transparent;border:1px solid #809184;border-radius:5px;padding:1px 7px;width:fit-content;max-width:100%}
@media(prefers-reduced-motion:reduce){#studio #frogPanel .frog-gesture,#studio #frogPanel [data-walking=true] .frog-bounce{animation:none}}

/* Keep the painting's proportions; anchor its ground behind the frog. */
#studio #frogPanel[data-scene]:not([data-scene=""]){background-size:cover;background-position:center 78%}

/* Player labels float independently: no full-width name strip. */
body:has(#studio:not([hidden])) header{background:transparent;border-bottom:0;box-shadow:none}
#studio .boardstage{position:relative;overflow:visible;background:transparent}
#studio #board{overflow:hidden;border-radius:3px}
#studio #bottomPlayer{position:absolute;top:100%;bottom:auto;left:0;height:auto;min-height:0;margin:0;z-index:12;background:transparent}

/* The board, name and scene occupy separate rows, even in a short viewport. */
body:has(#studio:not([hidden])) main{overflow:auto;container-type:normal}
main>#studio{height:auto;min-height:100%;max-height:none;grid-template-columns:minmax(0,1fr);grid-template-rows:auto 210px auto;gap:4px;align-content:start}
#studio>.boardrow{grid-area:1/1;container-type:normal;position:relative;z-index:2;justify-content:start;align-self:start;overflow:visible}
#studio .boardrow>.boardstage,#studio .boardrow>.meter{width:min(100%,max(300px,calc(100dvh - 360px)))}
#studio .boardstage{display:flex;flex-direction:column;align-items:flex-start;gap:3px}
#studio #board{width:100%;aspect-ratio:1;flex:none;position:relative;isolation:isolate}
#topPlayer,#studio #bottomPlayer{background:#fff;border:2px solid #fff;border-radius:5px;padding:1px 7px;color:#1d352e;width:fit-content;max-width:100%}
#studio #bottomPlayer{position:relative;inset:auto;height:auto;line-height:22px;flex:none;z-index:auto}
#studio>#frogPanel{grid-area:2/1;align-self:stretch;height:100%;min-height:0;overflow:hidden;contain:paint;z-index:1;container-type:size}
#studio #frogActor{--size:min(196px,44vw,calc(100cqh * .82))}
#studio>.audioctrl,#studio>.transport{grid-area:2/1;align-self:end;position:relative;z-index:3;margin:0;padding:0;min-height:44px}
#studio>.audioctrl{justify-self:start}
#studio>.transport{justify-self:center;max-width:calc(100% - 104px);width:max-content;gap:4px}
#studio>#speechStatus{grid-area:3/1;max-height:none}
@media(max-width:760px) and (orientation:portrait){
 main>#studio{grid-template-rows:auto clamp(170px,49vw,210px) auto}
 #studio .boardrow>.boardstage,#studio .boardrow>.meter{width:100%;max-width:none}
}
@media(orientation:landscape) and (max-height:500px) and (max-width:1000px){
 main>#studio{grid-template-columns:minmax(0,1fr) minmax(150px,30%);grid-template-rows:minmax(180px,1fr) auto;min-height:100%}
 #studio>.boardrow{grid-area:1/1/3/2}
 #studio .boardrow>.boardstage,#studio .boardrow>.meter{width:min(100%,max(180px,calc(100dvh - 120px)))}
 #studio>#frogPanel,#studio>.audioctrl,#studio>.transport{grid-area:1/2}
 #studio>#speechStatus{grid-area:2/2}
 #studio>.transport{justify-self:end;max-width:calc(100% - 50px)}
}

#stockfishTarget{position:relative;display:inline-flex;align-items:center;gap:4px;background:#25392e;color:#fff;border-radius:5px;padding:0 7px;z-index:1}
#stockfishTarget svg{width:20px;height:15px;flex:none}
#stockfishTarget #score{padding-inline:0;background:none}
.evaluation-loss{position:fixed;z-index:1000;pointer-events:none;color:#fff;background:#a42e32;border:2px solid #fff;border-radius:14px;padding:3px 9px;font:800 clamp(18px,4vw,27px)/1.2 system-ui;box-shadow:0 3px 12px #311b2440;font-variant-numeric:tabular-nums;will-change:transform,opacity}
#meter .gauge,#fill{transition:width .4s ease-out}
@media(prefers-reduced-motion:reduce){#meter .gauge,#fill{transition:none}}
.meter #stockfishTarget{grid-area:1/1;place-self:center}

/* One viewport: contiguous board and scene, floating player tag, controls at left. */
body:has(#studio:not([hidden])){overflow:hidden;grid-template-rows:44px minmax(0,1fr)}
body:has(#studio:not([hidden])) header{height:44px;min-height:0;padding-inline:8px}
body:has(#studio:not([hidden])) main{height:100%;overflow:hidden;container-type:size}
main>#studio{--scene-min:154px;--meter-height:22px;--stage-width:min(100cqw,calc(100cqh - var(--scene-min) - var(--meter-height)));width:100%;height:100%;min-height:0;max-height:none;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);gap:0;padding:0;overflow:hidden}
#studio>.boardrow{grid-area:1/1;gap:0;min-height:0;z-index:3}
#studio .boardrow>.boardstage,#studio .boardrow>.meter{width:var(--stage-width);max-width:100%}
#studio .boardrow>.meter{height:var(--meter-height);min-height:var(--meter-height)}
#studio .boardstage{display:block;position:relative;gap:0}
#studio #board{border-radius:0}
#studio #bottomPlayer{position:absolute;top:100%;left:5px;z-index:5;margin-top:4px;line-height:20px;font-size:12px;padding:0 5px;max-width:calc(100% - 10px)}
#topPlayer{font-size:13px;line-height:20px}
#studio>#frogPanel{grid-area:2/1;width:var(--stage-width);height:100%;border-radius:0;overflow:hidden;contain:paint;container-type:size;z-index:1;min-height:0}
#studio #frogActor{--size:min(34cqw,172px,calc((100cqh - 22px) * .92))}
#studio #frogTravel{bottom:20px}
#studio>.audioctrl{grid-area:2/1;align-self:end;justify-self:start;margin-left:calc((100% - var(--stage-width))/2 + 5px);margin-bottom:43px;z-index:5;min-height:40px}
#studio .audioctrl #listen{width:40px;height:40px;min-width:40px;min-height:40px;flex-basis:40px;border-radius:10px}
#studio>.transport{grid-area:2/1;align-self:end;justify-self:start;width:44px;max-width:44px;margin-left:calc((100% - var(--stage-width))/2 + 3px);margin-bottom:2px;display:grid;grid-template-columns:repeat(3,1fr);gap:1px;z-index:5;min-height:38px}
#studio .transport .navmove{min-width:0;width:100%;height:35px;min-height:35px;padding:0;font-size:19px;border-radius:5px}
#studio .transport #bestPreview{position:absolute;bottom:86px;left:0;margin:0;padding:4px;font-size:10px;min-height:25px;max-width:46px}
#studio .transport:has(#bestPreview:not([hidden])){justify-self:start;max-width:44px}
#studio>#speechStatus{position:absolute;bottom:0;left:50%;transform:translateX(-50%);z-index:6;max-width:65%;font-size:10px;background:#ffffffdf;border-radius:4px;text-align:center;pointer-events:none}
#studio>#speechStatus:empty{display:none}
#voiceProgress{position:absolute;left:0;bottom:44px;width:40px}
.captured-side{position:absolute;bottom:20px;width:25%;height:calc(100% - 50px);display:flex;flex-direction:column;justify-content:end;align-items:center;gap:2px;z-index:3;pointer-events:none}
.captured-own{left:14%}.captured-opponent{right:0}
.captured-label{font:650 clamp(8px,2.4cqw,11px)/1.2 system-ui;color:#173a2b;background:#ffffffd9;border-radius:4px;padding:2px 4px;white-space:nowrap}
.captured-list{display:flex;align-items:end;justify-content:center;align-content:end;flex-wrap:wrap;gap:0;width:100%;max-height:calc(100% - 16px)}
.captured-list:empty{min-height:32px}
.captured-item{position:relative;width:33.333%;max-width:38px;aspect-ratio:1;flex-shrink:0}
.captured-character{display:block;width:100%;height:100%;background:url(captured-characters.png) var(--piece-x,0%) var(--piece-y,0%)/500% 200% no-repeat;filter:drop-shadow(0 2px 1px #17251d55)}
.captured-item b{position:absolute;bottom:-1px;right:-2px;background:#163d2e;color:white;border:1px solid #fff;border-radius:5px;padding:0 2px;font:750 10px/1.2 system-ui}
#materialBalance{position:absolute;bottom:2px;left:50%;transform:translateX(-50%);z-index:4;max-width:60%;white-space:nowrap;padding:1px 6px;border-radius:6px;background:#ffffffdf;color:#173a30;font:700 11px/16px system-ui}
#materialBalance[data-advantage=you]{color:#0c6035}#materialBalance[data-advantage=opponent]{color:#9c292c}
.captured-flight{position:fixed;width:46px;height:46px;z-index:999;pointer-events:none;will-change:transform,opacity}
@media(min-width:761px){main>#studio{--scene-min:190px}.captured-own{left:8%}.captured-opponent{right:5%}.captured-side{width:29%}.captured-item{max-width:52px}}
@media(max-height:430px) and (orientation:landscape){main>#studio{--scene-min:110px}.captured-label{font-size:8px}.captured-side{height:calc(100% - 32px);bottom:18px}.captured-item{max-width:25px}#studio #bottomPlayer{font-size:10px;line-height:14px}#studio .audioctrl #listen{width:32px;height:32px;min-width:32px;min-height:32px;flex-basis:32px}}
/* Keep the three navigation targets touchable in a vertical column. */
main>#studio{--scene-min:180px}
#studio>.audioctrl{margin-bottom:94px}
#studio>.transport{width:40px;max-width:40px;grid-template-columns:1fr;grid-template-rows:repeat(3,30px);gap:0;min-height:90px}
#studio .transport .navmove{height:30px;min-height:30px;width:40px;font-size:21px}
#studio .transport #bestPreview{left:48px;bottom:0;max-width:48px;min-height:18px;padding:2px 4px}
#studio .transport:has(#bestPreview:not([hidden])){max-width:40px}
@media(min-width:761px){main>#studio{--scene-min:190px}}
@media(max-height:430px) and (orientation:landscape){main>#studio{--scene-min:140px}#studio>.audioctrl{margin-bottom:94px}}
.captured-list:has(.captured-item:only-child) .captured-item{width:75%;max-width:64px}
.captured-list:has(.captured-item:nth-child(2):last-child) .captured-item{width:50%;max-width:50px}

/* The evaluation sits on the scenery, directly beneath the board. */
main>#studio{--stage-width:min(100cqw,calc(100cqh - var(--scene-min)))}
#studio>#frogPanel{z-index:4}
#studio #frogPanel>.meter{position:absolute;top:0;left:0;width:100%;height:22px;min-height:22px;z-index:1;border-radius:0;border:0;margin:0}
#studio #frogTravel{z-index:2}
#studio #bottomPlayer{margin-top:25px;z-index:6}
#studio .boardrow{z-index:5}
#materialBalance:empty{display:none}
.captured-character[data-color=w]{filter:brightness(1.3) contrast(1.2) drop-shadow(1px 0 0 #162733) drop-shadow(-1px 0 0 #162733) drop-shadow(0 2px 2px #07151b)}
.captured-character[data-color=b]{filter:brightness(.65) contrast(1.5) saturate(.65) drop-shadow(1px 0 0 #fff8d9) drop-shadow(-1px 0 0 #fff8d9) drop-shadow(0 2px 2px #fff8d9)}
.captured-item{background:#eef6f2d9;border-radius:8px;box-shadow:0 1px 5px #142b2940}
.captured-list{gap:2px}.captured-item{width:calc(33.333% - 2px)}

/* Large desktop screens: give the mascot and its scenery a little more height. */
@media(min-width:761px) and (min-height:860px){main>#studio{--scene-min:236px}#studio #frogActor{--size:min(34cqw,216px,calc((100cqh - 22px) * .92))}}

/* Computer screens: largest possible board on the left; evaluation bar
   standing beside it; evaluation history at top right; the frog and its
   scenery fill the right column. Phones and tablets keep the layout above. */
@media (min-width:1024px) and (hover:hover) and (pointer:fine) and (min-aspect-ratio:5/4){
 body main>#studio{--bar:30px;--side-min:340px;--board:min(calc(100cqh - 46px),calc(100cqw - var(--bar) - var(--side-min) - 72px));
  display:grid;grid-template-columns:var(--board) var(--bar) minmax(var(--side-min),620px);grid-template-rows:auto minmax(0,1fr) auto auto;
  column-gap:14px;row-gap:12px;justify-content:center;align-content:stretch;padding:10px 16px 8px;overflow:hidden}
 body main>#studio>.boardrow{display:contents}
 body main>#studio .boardrow>.boardstage{grid-column:1;grid-row:1/-1;align-self:start;width:var(--board);max-width:none;height:var(--board)}
 body main>#studio #board{width:100%;height:100%}
 body main>#studio .boardrow>#history{display:block;grid-column:3;grid-row:1;width:100%;max-width:none;height:clamp(84px,15cqh,150px);border-radius:10px;background:#222825}
 body main>#studio .boardrow>.meter{grid-column:2;grid-row:1/-1;align-self:start;position:relative;inset:auto;width:var(--bar);min-width:0;max-width:none;height:var(--board);min-height:0;margin:0;border:1px solid #809184;border-radius:6px;overflow:visible;display:block;background:#222825;z-index:4}
 body main>#studio .boardrow>.meter .gauge{position:absolute;inset:0;width:100%;height:100%;border-radius:6px;overflow:hidden}
 body main>#studio .boardrow>.meter #fill{position:absolute;left:0;right:0;bottom:0;width:100%!important;height:var(--white,50%);transition:height .4s ease-out}
 body main>#studio[data-bottom=b] .boardrow>.meter #fill{top:0;bottom:auto}
 body main>#studio .boardrow>.meter #stockfishTarget{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%) rotate(-90deg);white-space:nowrap;font-size:12px}
 body main>#studio>#frogPanel{grid-column:3;grid-row:2;align-self:stretch;justify-self:stretch;width:100%;height:auto;min-height:220px;border-radius:12px}
 body main>#studio>#frogPanel>.meter{display:none}
 body main>#studio #frogActor{--size:min(42cqw,380px,calc((100cqh - 16px) * .78))}
 body main>#studio #frogTravel{bottom:14px}
 body main>#studio>.audioctrl{grid-column:3;grid-row:3;align-self:center;justify-self:start;margin:0;z-index:5}
 body main>#studio>.transport{grid-column:3;grid-row:3;align-self:center;justify-self:start;margin:0 0 0 54px;display:flex;flex-direction:row;gap:6px;z-index:5;position:relative;inset:auto;width:auto;max-width:none;height:auto;min-height:0}
 body main>#studio>.transport #bestPreview{position:static;max-width:none;min-height:40px;padding:0 12px;font-size:14px}
 body main>#studio>.transport:has(#bestPreview:not([hidden])){max-width:none}
 body main>#studio>.transport .navmove{width:40px;min-width:40px;height:40px;min-height:40px;padding:0;font-size:18px}
 body main>#studio>#speechStatus{grid-column:3;grid-row:4;position:static;justify-self:start;max-height:none}
 body main>#studio #bottomPlayer{top:auto;bottom:8px;left:8px;margin:0;z-index:12}
}
