/* The stage owns the canvas, the game screens and every transient message. */
#stage{container-type:size;touch-action:auto;--wood:#765237;--ink:#263f38;--paper:#fff1c6;--sea:#27665c}
.console #stage{min-height:clamp(415px,63vh,740px)}
.play-only .console #stage{min-height:0}
#gameplay,.world-screen{position:absolute;inset:0}
#gameplay{touch-action:none}
.world-screen,#dialog{overscroll-behavior:contain;touch-action:pan-y;scrollbar-color:#9c8458 #e4d6ac;scrollbar-width:thin}
.world-screen{z-index:4;overflow:auto}
#stage:focus:not(:focus-visible){outline:none}
#toast{position:absolute;z-index:8;bottom:16%;max-width:86%;width:max-content;text-align:center;color:#fff4ca;background:#244e46;border:2px solid #e9ca8a;box-shadow:0 3px #483e31}
#stage:has(dialog[open]) #toast{visibility:hidden}
#gameplay .loadouts{position:absolute;z-index:2;top:12px;left:12px;min-height:0;gap:5px;background:none;border:0;padding:0;pointer-events:none}
#gameplay .loadout{padding:4px 7px;background:#203e43ed;border-radius:7px}.loadout button{pointer-events:auto}

body:not(.play-only) .mission{position:absolute;z-index:2;bottom:9px;left:9px;max-width:65%;min-height:0;padding:5px 9px;background:#203e43ed;border:0;border-radius:8px;color:white}

body:not(.play-only) .mission-icon{width:25px;height:25px;font-size:18px}
body:not(.play-only) .mission p{font-size:12px;margin:0}

#home-screen{display:flex;flex-direction:column;background:#77b8c6 url('./assets/menu-isles.webp') 57% center /cover no-repeat}
#home-screen:before{content:'';position:absolute;inset:0;background:linear-gradient(90deg,#143d4dfa,#194453a8 29%,#1e425a08 70%),linear-gradient(0deg,#143c47c9,transparent 33%);pointer-events:none}
.menu-hero{flex:1 0 auto;width:100%;min-height:0;border:0;border-radius:0;background:none;overflow:visible}
.menu-hero:before{display:none}
.menu-copy{width:clamp(235px,35cqw,400px);padding:clamp(22px,4cqh,54px) 0 12px clamp(18px,6cqw,96px);box-sizing:content-box}
.menu-copy h2{font:italic 900 clamp(50px,min(10cqw,13cqh),134px)/.92 var(--title);letter-spacing:-.035em;text-transform:uppercase;color:#fff6d3;text-shadow:0 .045em #a86e35,0 .075em #334d48;white-space:nowrap;margin:0 0 clamp(16px,3.3cqh,32px)}
.menu-choice{border:2px solid #45665b;border-bottom:4px solid #264c46;border-radius:8px;background:#fff1cf;color:#24473f;box-shadow:0 2px 0 #122d3933}
.menu-choice:hover{background:#fff8e2}.menu-choice .ic{color:#486557}
.menu-choice.solo-choice,.resume-choice{border-color:#63774b;border-bottom-color:#405f45;background:#a7e790;color:#254a3b}
.menu-choices{grid-template-columns:1fr}
#home-screen .animal-shelf{position:relative;margin:0;padding:7px clamp(18px,6cqw,96px) clamp(12px,3.4cqh,38px);width:min(100%,760px)}
#home-screen .section-title{margin:0 0 7px}#home-screen .section-title h2{color:#ffedc4;font:800 22px/1 var(--title);text-shadow:0 2px #244e4b}
#home-screen .section-title .ic{display:none}
#animal-slots{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
#home-screen .slot-card{background:#244f4de8;border:1px solid #a6cabe;border-bottom:3px solid #163b3a;border-radius:8px;min-height:44px;padding:5px 9px}
#home-screen .slot-picture{width:42px;height:38px;background:none}#home-screen .slot-picture canvas{width:49px;height:40px}
#home-screen .slot-detail strong{font-size:20px}
.world-tools{display:flex;align-items:center;justify-content:center;gap:6px}
#home-tools{position:sticky;z-index:2;top:8px;align-self:flex-end;margin:8px 10px -48px 0;min-height:40px}
.world-tools button,#editor-tools button{background:#234f4ce8;color:#fff2cf;border:1px solid #c3cfac;border-radius:7px}
.world-tools .help span{display:none}#home-tools .help{padding:8px}
#home-tools .play-window,#board-tools .play-window{font-size:12px;min-height:34px;padding:7px 10px;box-shadow:none}
#home-tools .icon-btn,#board-tools .icon-btn,#editor-tools .icon-btn{width:34px;height:34px}
#board-tools:not(:empty){margin:14px auto 0}
#animal-screen{padding:clamp(12px,3cqw,30px);background:linear-gradient(110deg,#23494bf7,#376762ee),url('./assets/menu-isles.webp') center/cover}
#animal-screen .wardrobe-title,#wardrobe{max-width:980px;margin-inline:auto}
.wardrobe-title{color:#fff1c6}.wardrobe-title h2{font-size:clamp(24px,4cqw,37px)}
#editor-tools{margin-left:auto}
#wardrobe .options-card{background:#fff1cf;color:var(--ink);border:3px solid #97704c;border-radius:10px}
#wardrobe .pick-grid:not(.pick-color) button{background:#e9d7ac;border-color:#b69c69;color:#354837}
#wardrobe .pick-grid:not(.pick-color) button[aria-pressed=true]{background:#b8e4a5;border-color:#3a6f56;box-shadow:inset 0 0 0 1px #3a6f56}
#wardrobe .pick-color button[aria-pressed=true]{outline-color:#365342}
#wardrobe .preview-card{border:3px solid #97704c;border-radius:10px;background:radial-gradient(ellipse at 50% 65%,#83b6a4,#44827a 53%,#27575a)}
/* A non-top-layer dialog. The scrim and its scroll area stop at the edge of the course. */
#dialog{position:absolute;inset:0;z-index:9;margin:0;padding:clamp(6px,2cqh,22px) max(9px,env(safe-area-inset-right)) clamp(6px,2cqh,22px) max(9px,env(safe-area-inset-left));border:0;border-radius:0;width:100%;height:100%;max-width:none;max-height:none;overflow:hidden;background:linear-gradient(0deg,#163b4885,#12384250);box-shadow:none;color:var(--ink)}
#dialog[open]{display:flex;align-items:center;justify-content:center}
.dialog-box{position:relative;width:min(100%,370px);max-height:100%;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;border:3px solid var(--wood);border-radius:9px 9px 13px 13px;background:linear-gradient(110deg,#fff7d8,#f7e4b2);box-shadow:inset 0 0 0 2px #fffcdf,0 4px 0 #513f30,0 8px 0 #153e452c;padding:clamp(12px,2.6cqh,24px) clamp(15px,3.3cqw,28px);text-align:center}
#dialog .close{z-index:2;right:7px;top:7px;width:30px;height:30px;border:1px solid #987b51;background:#f1dfb1;color:#5b543b;border-radius:7px}
#dialog h2{margin:0 24px 7px;font:italic 900 clamp(28px,7cqh,39px)/1 var(--title);color:#2e5447;letter-spacing:-.025em}
#dialog p{color:#435443;font-size:14px;line-height:1.35;margin:8px 0}
.dialog-symbol{height:35px;width:35px;background:#2b655a;color:#fff0b7;border:2px solid #7eac83;border-radius:9px;transform:rotate(-5deg);margin:0 auto 8px}
.dialog-symbol .ic{height:20px;width:20px}
#stage .action{min-height:36px;padding:8px 12px;color:#183f35;background:#a4da88;border:2px solid #547d50;border-bottom-width:4px;border-radius:7px;font:700 14px/1.12 var(--body)}
#stage .action:hover{background:#b6e49b}#stage .action.secondary{color:#334e42;background:#eddeb4;border-color:#ae9569}#stage .action.secondary:hover{background:#f7e9c8}
#stage :focus-visible{outline:3px solid #eeab37;outline-offset:1px}
.dialog-actions{margin-top:12px;gap:6px}
#dialog label{text-align:left;font-size:13px}
#dialog input,.room-code{background:#fcf6dc;border:2px solid #a99365;border-radius:6px;color:#25483c}
.room-code{font-size:29px;margin:14px 0;padding:6px}
#room-issue:empty{display:none}
.help-rows{margin:10px 0;gap:2px}.help-rows .keyrow{color:#3d5346;font-size:12px}.help-rows kbd{background:#e6d5ae;color:#344a40;border-color:#b69b68;box-shadow:0 1px #ad9265}
.pause-actions{grid-template-columns:1fr 1fr}.pause-actions #resume{grid-column:1/-1}.pause-actions #pause-home:last-child:nth-child(even){grid-column:1/-1}
#dialog[data-kind=levels] .dialog-box{width:min(560px,100%)}
.board-courses{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px;margin-top:14px}
.board-courses .course-card{height:clamp(58px,16cqh,90px);padding:6px;color:white;border-radius:6px}.board-courses .card-title{font-size:clamp(14px,2.8cqw,20px)}
#dialog[data-kind=win] .dialog-box{width:min(100%,338px);border-top:5px solid #73ac60;background:linear-gradient(120deg,#fff5ce,#f6dfab)}
.award-art{display:block;width:min(215px,72%,40cqh);height:auto;margin:-5px auto 0}
#dialog[data-kind=win] h2{margin:0 -5px 5px;padding:6px 10px 8px;background:#2c6559;color:#fff6cd;clip-path:polygon(0 0,100% 0,97% 50%,100% 100%,0 100%,3% 50%);text-shadow:0 2px #184a43}

.win-stats{display:flex;align-items:center;justify-content:center;gap:18px;color:#3c513f;font-weight:bold;font-variant-numeric:tabular-nums}
.win-gems{display:inline-flex;align-items:center;gap:1px}.win-gems .ic{width:23px;height:23px;filter:drop-shadow(0 1px 0 #a67536)}.win-gems .missing{filter:grayscale(1);opacity:.42}
.win-time{display:flex;align-items:center;gap:4px}.win-time .ic{width:17px;height:17px}
@container (max-width:650px){
  .menu-copy{width:min(78%,280px);padding:52px 15px 9px}.menu-choices{gap:5px}.menu-choice{min-height:35px;padding:6px 11px}
  #home-screen .animal-shelf{padding:6px 15px 12px}.menu-hero{align-items:center}
  #animal-screen #wardrobe{grid-template-columns:1fr}
}
@container (max-height:460px) and (min-width:500px){
  .menu-copy{padding:12px 0 4px 5cqw}.menu-copy h2{font-size:48px;margin-bottom:12px}.menu-choices{gap:4px}.menu-choice{min-height:32px;padding:5px 12px}
  #home-screen .animal-shelf{padding:3px 5cqw 8px}
  #home-screen .slot-picture{height:30px}.award-art{width:129px}.dialog-box{padding-block:10px}
}
@media(max-width:760px){.console #stage{height:clamp(350px,68svh,720px);min-height:0;aspect-ratio:auto}.play-only .console #stage{height:100%}}
@media(pointer:coarse){body:not(.play-only) .mission{bottom:auto;top:96px;max-width:75%}}
@media(orientation:landscape) and (max-height:560px){.console #stage{height:calc(100svh - 74px);min-height:0}.play-only .console #stage{height:100%}}

@keyframes jewel-arrives{from{opacity:0;transform:translateY(-5px) scale(.8)}to{opacity:1;transform:none}}
@media(prefers-reduced-motion:no-preference){
  .win-gems .ic:not(.missing){animation:jewel-arrives .24s ease-out backwards}
  .win-gems .ic:nth-child(2){animation-delay:.09s}.win-gems .ic:nth-child(3){animation-delay:.18s}
}
