*{box-sizing:border-box} [hidden]{display:none!important} html,body{margin:0;min-height:100%;background:#1b2920;color:#f4f3dc;font:14px system-ui,sans-serif}main{width:100%;max-width:1280px;margin:auto;padding:8px max(8px,env(safe-area-inset-right)) 8px max(8px,env(safe-area-inset-left))}header{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:6px}h1{font-size:17px;margin:0;letter-spacing:1px}small,#status,footer{color:#becfb4;font-size:11px}form{display:flex;gap:5px;flex-wrap:wrap;margin-bottom:8px}button,input{font:inherit;color:inherit;background:#314635;border:1px solid #81977a;border-radius:5px;padding:7px}input{width:140px;min-width:0;flex:1}button{cursor:pointer;touch-action:manipulation}button:disabled{opacity:.45;cursor:default}body.playing #join input,body.playing #join button:not(#leaveButton){display:none}body.playing #join{position:absolute;right:10px;top:47px;z-index:30}body:not(.playing) #controls{opacity:.45;pointer-events:none}body:not(.playing) #joystick{pointer-events:none}body.playing #leaveButton{font-size:11px;padding:5px;background:#26392d}#game{position:relative;isolation:isolate;width:100%;aspect-ratio:4/3;min-height:340px;max-height:calc(100dvh - 110px);overflow:hidden;background:#a8dc64;box-shadow:0 0 0 1px #71875e}#game canvas{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;margin:0!important;image-rendering:pixelated;z-index:0}#hud{position:absolute;top:8px;left:8px;z-index:3;display:flex;flex-direction:column;gap:3px;pointer-events:none;max-width:70%}#locationHint,#saveStatus{display:block;width:max-content;max-width:100%;font-size:11px;padding:3px 6px;background:rgba(26,40,27,.78);color:#fff9d9;border-radius:3px}#saveStatus{font-size:10px;opacity:.8}
#controls{position:absolute;right:12px;bottom:12px;display:flex;gap:12px;align-items:flex-end;z-index:25;touch-action:none;user-select:none;pointer-events:none}.ab{display:flex;align-items:flex-end;gap:7px}.ab button,#joystick{pointer-events:auto;touch-action:none}.ab button{display:flex;flex-direction:column;align-items:center;justify-content:center;width:45px;height:45px;border-radius:50%;border:2px solid #fff9da88;background:#202f28cc;color:#fff;font-weight:bold;font-size:20px;padding:0;box-shadow:0 2px 4px #17251e55}.ab button small{color:#fff;font-size:9px;font-weight:normal}.ab #interact{width:54px;height:54px;margin-bottom:16px;background:#934239e6}.ab button:active{transform:scale(.93)}
#joystick{width:104px;height:104px;border-radius:50%;background:#20352b8c;border:2px solid #e8eed59c;position:relative;box-shadow:inset 0 0 0 5px #18281b30;cursor:grab;outline-offset:3px}.arrow{position:absolute;font-size:12px;color:#f7f5e3;pointer-events:none}.n{top:4px;left:50%;transform:translateX(-50%)}.s{bottom:4px;left:50%;transform:translateX(-50%)}.w{left:5px;top:50%;transform:translateY(-50%)}.e{right:5px;top:50%;transform:translateY(-50%)}#thumb{width:37px;height:37px;position:absolute;top:50%;left:50%;border-radius:50%;background:#d6dfc5d9;border:2px solid #fbf9e4b0;box-shadow:0 2px 5px #1e332a99;transform:translate(-50%,-50%);pointer-events:none}
#lab,#battlemsg,#actions,#battleSub,.hpbox{background:#fffdf3;color:#1e261c;border:4px double #272d22;border-radius:2px}#lab{position:absolute;z-index:12;left:8px;right:8px;bottom:126px;padding:9px;max-height:calc(100% - 170px);overflow:auto}#lab p{margin:5px 0 8px;font-size:14px;font-weight:bold}#starterChoices{display:flex;gap:4px}#starterChoices button{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;color:#1e261c;background:#f5f4da;border:1px solid #8e9c79;font-size:11px;padding:3px}#starterChoices img{height:48px;width:48px;image-rendering:pixelated}#lab>button{color:#1e261c;background:#f2f3dc;margin-top:6px;font-size:12px}button.selected{outline:3px solid #d59136;outline-offset:-3px}#battle{position:absolute;inset:0;z-index:10;background:#f1f4d6;color:#202820;display:flex;flex-direction:column;padding:8px 8px 126px;gap:4px;overflow:auto}#battlefield{display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;align-items:center;gap:4px;flex:1;min-height:110px}.hpbox{padding:5px 7px;font-size:12px}.hpbox p{margin:1px 0}.hpbox progress{width:100%;height:8px;accent-color:#59a043}.sprite{position:relative;display:grid;place-items:center;isolation:isolate;height:100%;min-height:50px}.sprite:before{content:'';position:absolute;bottom:5%;width:70%;height:26%;border-radius:50%;background:#b2cc83;z-index:-1}.sprite img{width:min(25vw,112px);height:min(21vw,96px);max-height:100%;object-fit:contain;image-rendering:pixelated}.own-sprite img{transform:scaleX(-1)}#battlemsg{min-height:36px;padding:5px;font-size:12px;font-weight:bold}#actions,#subActions{display:grid;grid-template-columns:1fr 1fr;gap:3px;padding:3px}#actions button,#battleSub button{background:#fffdf3;color:#202820;border:1px solid #b8bea3;font-size:12px;text-align:left;padding:5px}#team{display:flex;flex-wrap:wrap;gap:3px;padding:3px}#battleBack{margin:3px}#party{font-size:12px;padding:7px 0;color:#f2efd4}#notice{font-size:12px;margin:0 0 5px;color:#f7e4a4}#notice:empty{display:none}footer{text-align:center}
@media(min-width:760px){#game{min-height:420px;aspect-ratio:4/3;max-height:calc(100dvh - 115px)}#joystick{width:126px;height:126px}#controls{right:22px;bottom:20px}#lab{left:20px;right:20px;bottom:154px}#battle{padding:14px 14px 154px}#starterChoices img{width:64px;height:64px}}
@media(orientation:landscape) and (max-height:550px){main{padding:4px}header{margin:0}#game{height:calc(100dvh - 65px);min-height:250px;max-height:calc(100dvh - 65px);aspect-ratio:auto}#joystick{width:88px;height:88px}#controls{bottom:7px;right:8px}#battle{padding-bottom:100px}#lab{bottom:100px;max-height:calc(100% - 120px)}#party,footer{font-size:10px}}

#avatarSelect{margin:8px 0 12px;padding:10px;background:#25392b;border:1px solid #607c57;border-radius:5px}#avatarSelect>small{display:block;margin:3px 0 7px}#avatarOptions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
#avatarOptions button{display:flex;align-items:center;flex-direction:column;font-size:11px;padding:5px 2px;gap:4px}#avatarOptions canvas{width:48px;height:48px;image-rendering:pixelated}#avatarOptions button[aria-pressed=true]{border:2px solid #f4d17a;background:#40543a}body.playing #avatarSelect{display:none}#factionBadge{font-weight:bold}

/* Gold-era battle presentation: white stage, diagonal sprites, monochrome frames. */
#game.battling{height:clamp(440px,76dvh,760px);min-height:440px;max-height:none;aspect-ratio:auto;background:#fbfbf5}
#game.battling #hud{display:none}
#game.battling #controls{bottom:6px;right:10px;gap:9px;align-items:center}
#game.battling #joystick{width:66px;height:66px;border-color:#a3aaa0;background:#3d483c}
#game.battling #thumb{width:23px;height:23px}
#game.battling .ab button{width:34px;height:34px;font-size:15px;border-color:#a6aaa0}
#game.battling .ab #interact{width:40px;height:40px;margin-bottom:0}
#game.battling .ab button small{font-size:8px}
#battle{background:#fbfbf5;color:#161719;padding:8px 8px 80px;gap:0;overflow:auto}
#battlefield{position:relative;display:block;flex:1 0 auto;min-height:210px;isolation:isolate}
#battle .sprite{position:absolute;display:block;width:46%;height:49%;min-height:0}
#battle .sprite:before{display:none}
#battle .sprite img{display:block;width:100%;height:100%;max-height:none;object-fit:contain;image-rendering:pixelated;transform:none}
#battle .enemy-sprite{top:0;right:0}
#battle .own-sprite{bottom:0;left:0}
#battle .hpbox{position:absolute;width:51%;border:0;border-radius:0;padding:5px 8px 8px;background:none;color:#171719;font-family:monospace;font-size:clamp(12px,3.6vw,23px);line-height:1.25}
#battle .hpbox b{display:block;white-space:nowrap;font-weight:800;font-size:inherit;letter-spacing:-.5px}
#battle .hpbox.enemy{top:8%;left:0;border-left:3px solid #202022;border-bottom:3px solid #202022}
#battle .hpbox.own{bottom:5%;right:0;border-right:3px solid #202022;border-bottom:3px solid #202022}
#battle .hpbox:after{content:'';position:absolute;bottom:-3px;width:8px;height:6px;background:#202022}
#battle .hpbox.enemy:after{right:-4px;clip-path:polygon(0 0,100% 100%,0 100%)}
#battle .hpbox.own:after{left:-4px;clip-path:polygon(100% 0,100% 100%,0 100%)}
.hp-line,.xp-line{display:flex;align-items:center;gap:2px;margin:5px 0 2px}
.hp-line span{font-size:.68em;font-weight:bold;color:#f3d997;background:#242426;padding:2px 3px}
#battle progress{appearance:none;-webkit-appearance:none;display:block;border:2px solid #222325;border-radius:0;height:10px;flex:1;min-width:0;background:#e5e5db}
#battle progress::-webkit-progress-bar{background:#e5e5db}
#battle progress::-webkit-progress-value{background:var(--hp-color,#39a64d)}
#battle progress::-moz-progress-bar{background:var(--hp-color,#39a64d)}
#battle .xp-line{font-size:.52em;margin-top:4px}
#battle .xp-line progress{height:5px;border-width:1px;--hp-color:#6c92c8}
#battle #ownHP{text-align:right;font-weight:bold;margin:1px 0}
#battleBottom{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0;flex:none;background:#fff}
#battlemsg,#battle #actions,#battle #battleSub,#battleResult{border:5px double #202022;border-radius:0;background:#fff;color:#171719;box-shadow:none;min-width:0}
#battlemsg{padding:10px;font-size:clamp(13px,3.5vw,21px);line-height:1.5;font-weight:700;min-height:100px;overflow-wrap:anywhere;margin:0}
#battle #actions,#battle #subActions{display:grid;grid-template-columns:1fr 1fr;gap:0;padding:3px}
#battle #actions button,#battle #battleSub button,#battleContinue{position:relative;display:block;text-align:left;background:white;border:0;border-radius:0;color:#171719;padding:9px 4px 9px 16px;min-height:40px;font-size:clamp(12px,3.4vw,20px);font-weight:700;line-height:1.3;overflow-wrap:anywhere;box-shadow:none;outline:none}
#battle button.selected:before{content:'▶';position:absolute;left:2px;top:50%;transform:translateY(-50%);font-size:11px;color:#181818}
#battle button.selected{outline:none;background:#f0f0e7}
#battle button:active{background:#deded5}
#battle #battleSub{padding:3px}
#battle #team{display:grid;grid-template-columns:1fr 1fr;gap:1px;padding:0}
#battle #team button{font-size:12px;min-height:30px}
#battle #battleResult{display:grid;place-items:center}
#battle .sprite.hit{animation:retro-hit .24s steps(2,end) 2}
@keyframes retro-hit{0%,100%{opacity:1;translate:0 0}50%{opacity:.25;translate:3px 0}}
#battle .sprite.enter{animation:retro-enter .22s steps(5,end)}
@keyframes retro-enter{from{transform:translateX(18px);opacity:.2}to{transform:translateX(0);opacity:1}}
@media(min-width:760px){#battle{padding:16px 20px 84px}#battle .sprite{width:44%}#battlemsg{min-height:120px}}
@media(orientation:landscape) and (max-height:550px){#game.battling{height:calc(100dvh - 65px);min-height:260px}#battle{display:grid;grid-template-columns:1.25fr 1fr;padding:6px 8px 56px;gap:5px}#battlefield{min-height:170px}#battleBottom{grid-template-columns:1fr;align-content:center}#battlemsg{min-height:54px;font-size:12px;padding:5px}#battle #actions button,#battle #battleSub button{font-size:12px;min-height:28px;padding-top:5px;padding-bottom:5px}#game.battling #joystick{width:48px;height:48px}#game.battling #thumb{width:17px;height:17px}}
@media(prefers-reduced-motion:reduce){#battle .sprite.hit,#battle .sprite.enter{animation:none}}

body.battling header{padding-right:62px}body.playing.battling #join{top:8px;right:8px}#battle .hpbox b{white-space:normal}#battle .hpbox p[hidden]{display:none!important}

#battle #moveList{grid-column:1/-1;display:grid;grid-template-columns:1fr;gap:1px}#battle #moveList button{min-height:32px;padding-top:6px;padding-bottom:6px}#battle #moveInfo{grid-column:1/-1;border-top:2px solid #242426;padding:5px 3px;font-size:11px;font-weight:bold;line-height:1.4}#battle #moveList button:disabled{color:#999;opacity:.8}

#battle .statusTag{display:inline-block;background:#343237;color:#fff;padding:1px 4px;font-size:10px;font-weight:bold;border:1px solid #222;line-height:1.2}

#eventSchedule,#recoveryNotice{padding:7px 9px;border:1px solid #6c8262;background:#273c30;color:#e9f1d5;font-size:12px;margin:5px 0;border-radius:4px}#recoveryNotice{border-color:#d5ad70;background:#59462d;color:#fff3c4;font-weight:bold}

#facilityActions{display:grid;grid-template-columns:1fr 1fr;gap:5px}#lab #facilityActions button {
 background:#f0f5ef;
 color:#1b3225;
 border-color:#8da397;
 font-size:13px;
 font-weight:600;
 line-height:1.35;
 min-height:38px;
 padding:8px;
}
#lab #facilityActions input[data-market-search]{grid-column:1/-1;min-height:38px;border:1px solid #8da397;border-radius:3px;background:#fff;color:#1b3225;padding:7px;font-size:14px}
#lab #facilityActions button:not(:disabled):is(:hover,:focus-visible,.selected) {
 background:#d8ebdf;
}#progressInfo{padding:6px 9px;background:#314b36;color:#f4e9bb;font-size:12px;border:1px solid #69825c;margin:4px 0}

/* Mobile two-thumb layout. Keep the movement stick on the right and A/B on the left. */
#controls,#game.battling #controls{left:12px;right:12px;justify-content:space-between;gap:0}
.ab{gap:9px}
.ab button{width:51px;height:51px;font-size:22px}
.ab #interact{width:61px;height:61px;margin-bottom:14px}
#joystick{width:116px;height:116px}
.arrow{font-size:16px}
#thumb{width:41px;height:41px}
#lab{bottom:136px}
#game.battling #joystick{width:76px;height:76px}
#game.battling #thumb{width:27px;height:27px}
#game.battling .ab button{width:40px;height:40px;font-size:17px}
#game.battling .ab #interact{width:46px;height:46px}
#battle{padding-bottom:90px}
#minimap{position:absolute;left:8px;top:8px;z-index:5;width:var(--minimap-width);background:rgba(25,40,28,.93);border:1px solid #e4e8c3;border-radius:4px;box-shadow:0 2px 6px #17251e60;color:#fff9dc;padding:4px;pointer-events:none}
#miniToggle{display:flex;justify-content:space-between;align-items:center;gap:4px;width:100%;font-size:11px;font-weight:bold;padding:2px 3px;border:0;background:transparent;text-align:left;pointer-events:auto}
#miniSvg{display:block;width:100%;height:auto;border:1px solid #d4d8b0}
#miniNorth,#miniSouth{text-align:center;font-size:9px;font-weight:700;line-height:1.4;color:#f8e8b2}
#miniLegend{display:flex;flex-wrap:wrap;gap:2px 5px;margin-top:3px;font-size:9px;line-height:1.2}
#miniLegend span{display:flex;align-items:center;gap:2px}
#miniLegend b{display:inline-grid;place-items:center;width:11px;height:11px;color:#fff;font-size:8px;border-radius:1px}
#miniLegend .miniMe{color:#ffed72}
#game.battling #minimap,#game:has(#lab:not([hidden])) #minimap{display:none!important}
@media(min-width:760px){#controls,#game.battling #controls{left:22px;right:22px}#joystick{width:140px;height:140px}#lab{bottom:166px}#battle{padding-bottom:92px}}
@media(orientation:landscape) and (max-height:550px){#controls,#game.battling #controls{left:8px;right:8px}#joystick{width:98px;height:98px}#thumb{width:34px;height:34px}.ab button{width:48px;height:48px}.ab #interact{width:56px;height:56px;margin-bottom:10px}#lab{bottom:112px}#game{--minimap-width:112px}#game.battling #joystick{width:58px;height:58px}#game.battling #thumb{width:21px;height:21px}#game.battling .ab button{width:36px;height:36px}#game.battling .ab #interact{width:42px;height:42px}#battle{padding-bottom:68px}}
@media(max-width:360px){#game{--minimap-width:106px}.ab{gap:6px}}

/* Reserve the top-left corner for the minimap while exploring. */
#game{--minimap-width:clamp(106px,30vw,154px)}
#game:has(#minimap:not([hidden])):not(:has(#lab:not([hidden]))) #hud{left:calc(var(--minimap-width) + 16px);right:8px;max-width:none}
@media(orientation:landscape) and (max-height:550px){#game{--minimap-width:112px}}
@media(max-width:360px){#game{--minimap-width:106px}}

/* Gold-inspired trainer menu; controls stay in their established positions. */
#collectionOpen{position:absolute;right:8px;top:62px;z-index:8;background:#26392d;border:1px solid #eee9c4;font-weight:700;font-size:12px;padding:7px 12px}
#collectionPanel{position:absolute;inset:6px 6px 6px;z-index:28;display:flex;flex-direction:column;gap:6px;background:#fffdf0;color:#263125;border:4px double #29382b;padding:8px;overflow:hidden}
#collectionPanel button,#collectionPanel select{background:#f1efdc;color:#263125;border:1px solid #7e8b6f;padding:7px;border-radius:2px;font-size:12px}
.collectionHeader{display:flex;justify-content:space-between;align-items:center}
#collectionTabs{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:4px}
#collectionTabs button{padding-inline:3px}
#collectionTabs button[aria-pressed=true]{background:#3a5037;color:white;font-weight:bold}
#collectionMessage{font-size:11px;color:#52673b;min-height:14px}
#collectionContent{overflow:auto;flex:1;min-height:0;padding:2px;overscroll-behavior:contain}
#collectionContent p{margin:4px 0 8px;font-size:12px}
#collectionContent h3{font-size:14px;margin:8px 0}
.pokemonCard{display:grid;grid-template-columns:46px 1fr;gap:8px;border:1px solid #a9b191;background:#f5f3e5;padding:6px;margin-bottom:5px}
.pokemonCard img,.dexGrid img{width:42px;height:42px;object-fit:contain;image-rendering:pixelated}
.pokemonCard small,.dexGrid small{display:block;color:#505b44;font-size:10px}
.moveEditor{margin:5px 0}
.moveSlots{list-style:none;padding:0;margin:6px 0}
.moveSlots li{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:4px;margin:3px 0;font-size:12px}
#collectionPanel .moveSlots button{min-width:34px;min-height:32px;font-size:15px}
.moveEditor label{display:flex;align-items:center;justify-content:space-between;gap:6px;margin:4px 0;font-size:11px}
.moveEditor select{width:68%;min-width:0}
.pokemonCard progress{display:block;width:100%;height:7px;accent-color:#59a043}
.collectionActions{display:flex;flex-wrap:wrap;align-items:center;gap:4px;margin-top:3px}
.dexGrid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}
.dexGrid article{display:grid;place-items:center;align-content:center;min-height:73px;border:1px solid #a9b191;background:#f5f3e5;font-size:12px;text-align:center}
#game.battling #collectionOpen,#game:has(#lab:not([hidden])) #collectionOpen,#game:has(#collectionPanel:not([hidden])) #collectionOpen,#game:has(#collectionPanel:not([hidden])) #controls{display:none!important}

/* 150% right joystick; leave the left A/B buttons and minimap unchanged. */
#joystick{width:174px;height:174px;flex-shrink:0}
#joystick .arrow{font-size:24px}
#thumb{width:61.5px;height:61.5px}
#lab{bottom:194px;max-height:calc(100% - 206px)}
#game.battling #joystick{width:114px;height:114px}
#game.battling #thumb{width:40.5px;height:40.5px}
#battle{padding-bottom:128px}
@media(min-width:760px){#joystick{width:210px;height:210px}#lab{bottom:236px;max-height:calc(100% - 248px)}}
@media(orientation:landscape) and (max-height:550px){#joystick{width:147px;height:147px}#thumb{width:51px;height:51px}#lab{bottom:161px;max-height:calc(100% - 173px)}#game.battling #joystick{width:87px;height:87px}#game.battling #thumb{width:31.5px;height:31.5px}#battle{padding-bottom:96px}#game.battling #joystick .arrow{font-size:20px}}
@media(max-width:340px){#controls{left:8px;right:8px}.ab{gap:4px}}

/* 150% left A/B touch controls, preserving the enlarged right stick. */
.ab{flex-shrink:0}
.ab button{width:76.5px;height:76.5px;font-size:33px}
.ab #interact{width:91.5px;height:91.5px;margin-bottom:21px}
.ab button small{font-size:13px}
#game.battling .ab button{width:60px;height:60px;font-size:25.5px}
#game.battling .ab #interact{width:69px;height:69px;margin-bottom:0}
#game.battling .ab button small{font-size:12px}
@media(orientation:landscape) and (max-height:550px){.ab button{width:72px;height:72px}.ab #interact{width:84px;height:84px;margin-bottom:15px}#game.battling .ab button{width:54px;height:54px}#game.battling .ab #interact{width:63px;height:63px}}
/* Stack diagonally on narrow portrait screens so the two thumb zones never overlap. */
@media(max-width:410px) and (orientation:portrait){#controls:not(#game.battling #controls) .ab{position:relative;display:block;width:128px;height:164px}.ab #cancelBtn{position:absolute;left:0;bottom:0}.ab #interact{position:absolute;left:36px;bottom:73px;margin:0}#game.battling .ab{display:flex;width:auto;height:auto}#game.battling .ab #cancelBtn,#game.battling .ab #interact{position:static}}
@media(max-width:340px) and (orientation:portrait){#controls:not(#game.battling #controls) .ab{width:92px;height:176px}#controls:not(#game.battling #controls) .ab #interact{left:0;bottom:84px}}

#pvpOpen{position:absolute;right:8px;top:102px;z-index:8;background:#5a4738;border:1px solid #eee9c4;font-weight:700;font-size:12px;padding:7px 12px}
#game.battling #pvpOpen,#game:has(#lab:not([hidden])) #pvpOpen,#game:has(#collectionPanel:not([hidden])) #pvpOpen{display:none!important}
#pvpPanel{background:#26392d;border:2px solid #d6d3ac;color:#fff9df;padding:8px;margin:5px 0;font-size:12px}
.pvpHeader{display:flex;align-items:center;justify-content:space-between}
#pvpOptions{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}#pvpOptions button,#pvpClose{padding:7px 10px;font-size:12px}
#pvpTurn{background:#e9e6d4;color:#292d23;font-size:12px;font-weight:bold;padding:4px 8px;border-bottom:1px solid #6c745a}

#pvpPanel{position:absolute;z-index:24;top:40%;left:50%;transform:translate(-50%,-40%);width:min(290px,85%);max-height:40%;overflow:auto;box-shadow:0 3px 12px #18251f80}#game.battling #pvpPanel{display:none!important}

#miniSide{color:#e9edc6;font-size:10px;line-height:1.35;padding:2px 0}
.questEntry{padding:8px 0;border-bottom:1px solid #81977a66}
.questEntry p{margin:4px 0}

#collectionTabs button{font-size:11px}
#collectionContent:has(.regionMapFrame){display:flex;flex-direction:column}
.regionMapPicker{display:flex;gap:6px;margin-bottom:6px}
#collectionPanel .regionMapPicker [aria-pressed="true"]{background:#364c33;color:#fffdf0}
.regionMapFrame{position:relative;flex:1 0 150px;min-height:0;margin:6px 0;overflow:hidden;border:1px solid #809577;border-radius:6px;background:#dce9c9}
.regionMapFrame svg{position:absolute;inset:0;display:block;width:100%;height:100%}
.regionRoad,.regionTrail{stroke:#788b72;stroke-width:3}
.regionTrail{stroke:#8c7749;stroke-dasharray:4 4}
.regionNode{cursor:pointer}
.regionNode rect{fill:#f3ecd2;stroke:#719077;stroke-width:1}
.regionNode.town rect{fill:#e1efd9}
.regionNode.league rect{fill:#e8e2f0;stroke:#897c9a}
.regionNode.current rect{fill:#ffdf81;stroke:#694d1d;stroke-width:2}
.regionNode[aria-pressed=true] rect,.regionNode:focus-visible rect{stroke:#2d5e48;stroke-width:2.5}
.regionNode text{fill:#263125;font-weight:680;font-size:9px;pointer-events:none}
.regionMapDetails{display:grid;gap:4px;margin:6px 0 10px;font-size:12px}

.regionGuide{margin:5px 0;padding:4px 6px;background:#ffefc4;color:#60451d;border-radius:4px;font-size:12px}
.regionRoad.regionGuided,.regionTrail.regionGuided{stroke:#bd603d;stroke-width:5}
.regionNode.destination rect{stroke:#ad5241;stroke-width:2.5}
#miniGuide{font-size:10px;font-weight:700;color:#ffdf89;padding:2px 0}


#game #cancelBtn,#game #interact{font-size:clamp(12px,3.6vw,18px)}
#game.battling #cancelBtn,#game.battling #interact{font-size:clamp(11px,3.1vw,16px)}
#collectionPanel :focus-visible,#pvpPanel :focus-visible{outline:2px solid #d59136;outline-offset:2px}

/* Expanded trainer roster: compact, scrollable and usable on mobile. */
#avatarOptions{grid-template-columns:repeat(auto-fit,minmax(76px,1fr));max-height:252px;overflow-y:auto;overscroll-behavior:contain;padding:2px;align-content:start}#avatarOptions button{min-height:70px}#avatarOptions canvas{width:48px;height:48px}

/* Compact mobile Pokedex detail layout. */
.dexControls{display:flex;gap:6px;margin:8px 0;flex-wrap:wrap}.dexControls input{flex:1;min-width:110px;width:100%;font-size:13px}.dexControls select{max-width:44%;font-size:12px}.dexGrid article{padding:5px;min-width:0}.dexGrid details{width:100%;text-align:left;overflow-wrap:anywhere}.dexGrid details summary{font-size:11px;cursor:pointer;text-align:center;color:#394d37}.dexGrid article:has(details[open]){grid-column:1/-1;display:grid;grid-template-columns:48px 1fr;place-items:start;text-align:left;gap:3px 8px}.dexGrid article:has(details[open]) details{grid-column:1/-1}.dexGrid details strong{display:block;margin-top:7px}.dexGrid details small{font-size:12px;line-height:1.45;margin:3px 0}

#extraBattleItems{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr;gap:3px;max-height:100px;overflow-y:auto}#extraBattleItems[hidden]{display:none}

#battle.summit-battle #battlefield {
 background:
  linear-gradient(160deg, transparent 55%, #37456355 55%) left top / 50% 70% no-repeat,
  linear-gradient(200deg, transparent 55%, #37456355 55%) right top / 50% 70% no-repeat,
  linear-gradient(#222c48, #697b95 57%, #b5a58b 58%, #dbcaa5);
}
#battle.summit-battle .sprite::before {
 background: #78675888;
}

#battleScenery {
 position:absolute;
 inset:0;
 width:100%;
 height:100%;
 image-rendering:pixelated;
 pointer-events:none;
 z-index:-1;
 border:2px solid #3f494c;
}
#battle .sprite.hit img {animation:pixel-flash .28s steps(2,end)}
#battle .sprite.hit::after {
 content:"";
 position:absolute;
 left:51%;
 top:44%;
 width:5px;
 height:5px;
 background:#fff3bf;
 box-shadow:-11px -6px #ffca72, 10px 4px #ffca72, 6px -12px #fff3bf, -8px 11px #f28d62;
 pointer-events:none;
 animation:pixel-impact .3s steps(4,end) both;
}
@keyframes pixel-flash {
 35% {filter:contrast(1.25) brightness(1.35)}
}
@keyframes pixel-impact {
 from {opacity:1;transform:scale(.5)}
 to {opacity:0;transform:scale(2)}
}
@media (prefers-reduced-motion:reduce) {
 #battle .sprite.hit::after {animation:none;display:none}
 #battle .sprite.hit img {animation:none}
}

#battle .sprite .capture-ball {
 display:none;
 position:absolute;
 left:49%;
 bottom:8%;
 width:18px;
 height:18px;
 border:2px solid #342a36;
 border-radius:45%;
 background:linear-gradient(#d65b58 0 44%,#342a36 44% 57%,#f6e9d1 57%);
 box-shadow:0 3px #38374362;
}
#battle.capture-success .enemy-sprite .capture-ball,
#battle.capture-breakout .enemy-sprite .capture-ball {display:block;animation:capture-toss 1.2s steps(4,end) both}
#battle.capture-success .enemy-sprite img {animation:capture-absorb 1.2s steps(5,end) both}
#battle.capture-breakout .enemy-sprite img {animation:capture-escape 1.2s steps(5,end) both}
#battle.capture-breakout .enemy-sprite .capture-ball {animation-name:capture-breakout-ball}
#battle.capture-success #battleResult {animation:capture-result 1.2s step-end both}
#battle.capture-success .capture-ball::after {
 content:"";
 position:absolute;
 width:3px;
 height:3px;
 left:5px;
 top:-7px;
 background:#fff2b4;
 box-shadow:-10px 4px #f4ca68, 10px 4px #f4ca68;
 animation:capture-spark 1.2s step-end both;
}
@keyframes capture-spark {0%,89%,100% {opacity:0} 90% {opacity:1}}
@keyframes capture-toss {
 0% {transform:translate(-120px,55px) rotate(-120deg)}
 28% {transform:translate(0,-26px) rotate(45deg)}
 48%,100% {transform:translate(0,0)}
 59%,79% {transform:rotate(-22deg)}
 69%,89% {transform:rotate(22deg)}
}
@keyframes capture-breakout-ball {
 0% {transform:translate(-120px,55px)}
 27% {transform:translate(0,-26px)}
 45% {transform:translate(0,0)}
 65% {transform:rotate(25deg)}
 83%,100% {opacity:0}
}
@keyframes capture-absorb {
 0%,26% {opacity:1;transform:scale(1)}
 44%,100% {opacity:0;transform:translateY(20px) scale(.08)}
}
@keyframes capture-escape {
 0%,26%,100% {opacity:1;transform:scale(1)}
 43%,66% {opacity:0;transform:translateY(20px) scale(.08)}
 78% {opacity:1;transform:scale(1.08)}
}
@keyframes capture-result {from {visibility:hidden} to {visibility:visible}}
@media (prefers-reduced-motion:reduce) {
 #battle.capture-success .enemy-sprite img {animation:none;visibility:hidden}
 #battle.capture-breakout .enemy-sprite img,#battle.capture-success #battleResult {animation:none}
 #battle.capture-success .enemy-sprite .capture-ball {animation:none}
 #battle.capture-success .capture-ball::after {animation:none;display:none}
 #battle.capture-breakout .enemy-sprite .capture-ball {display:none}
}

#battle .damage-pop {
 position:absolute;
 top:24%;
 left:45%;
 color:#ffdb92;
 font:bold 16px monospace;
 text-shadow:2px 1px #332a3d,-1px -1px #332a3d;
 pointer-events:none;
 animation:damage-rise .6s steps(6,end) both;
}
@keyframes damage-rise {from {opacity:1;transform:translateY(0)} to {opacity:0;transform:translateY(-24px)}}
@media (prefers-reduced-motion:reduce) {
 #battle .damage-pop {display:none}
}

#battle .sprite {width:51%;height:54%}
#battle .enemy-sprite {padding:2% 5% 0 0}
#battle .own-sprite {padding:0 0 2% 4%}
#battleIntro[hidden] {display:none}
#battleIntro {
 position:absolute;
 inset:0;
 display:grid;
 place-items:center;
 z-index:30;
 isolation:isolate;
 overflow:hidden;
 animation:battle-reveal 1s steps(8,end) both;
}
#battleIntro::before,#battleIntro::after {
 content:"";
 position:absolute;
 left:0;
 right:0;
 height:52%;
 background:repeating-linear-gradient(0deg,#20263b 0 8px,#29344e 8px 12px);
 z-index:-1;
}
#battleIntro::before {top:0;animation:intro-top 1s steps(8,end) both}
#battleIntro::after {bottom:0;animation:intro-bottom 1s steps(8,end) both}
#battleIntro strong {
 color:#fff2d2;
 background:#342739;
 border-block:3px solid #e2b579;
 box-shadow:0 5px #1b2031;
 padding:.65em 1em;
 letter-spacing:.08em;
 font-size:clamp(15px,5vw,25px);
}
@keyframes intro-top {0% {transform:translateY(-100%)} 25%,64% {transform:translateY(0)} 100% {transform:translateY(-100%)}}
@keyframes intro-bottom {0% {transform:translateY(100%)} 25%,64% {transform:translateY(0)} 100% {transform:translateY(100%)}}
@keyframes battle-reveal {0% {opacity:0} 18%,65% {opacity:1} 100% {opacity:0}}
#settingsOpen{margin:0 0 6px}#fieldSheet{display:none}
body.sheet-compact{background:#f4f6f5;color:#24352f;font:14px system-ui,sans-serif}
.sheet-compact main{background:white}.sheet-compact header{background:#226746;color:white;padding:8px 12px}
.sheet-compact header small,.sheet-compact header #status{color:white}
.sheet-compact button,.sheet-compact input,.sheet-compact #avatarSelect,.sheet-compact #party,.sheet-compact #progressInfo,.sheet-compact #eventSchedule{background:#f5f7f6;color:#203c30;border:1px solid #cad4ce;border-radius:2px;box-shadow:none}
.sheet-compact #game{background-color:white;background-image:linear-gradient(#dce3df 1px,transparent 1px),linear-gradient(90deg,#dce3df 1px,transparent 1px);background-size:72px 28px}
.sheet-compact #game>canvas,.sheet-compact #game img,.sheet-compact #minimap,.sheet-compact #game #battleScenery,.sheet-compact #game .sprite,.sheet-compact #battleIntro{visibility:hidden}
.sheet-compact.playing #fieldSheet{display:block;position:absolute;inset:15% 2% auto;pointer-events:none}
#fieldSheet table{border-collapse:collapse;width:100%;table-layout:fixed;background:white;text-align:center;color:#415049;font:12px system-ui}
#fieldSheet td{border:1px solid #ced8d2;height:clamp(19px,4vh,32px);overflow:hidden}
#fieldSheet tr:first-child td,#fieldSheet td:first-child{background:#eef3ef;color:#52655a}#fieldSheet td.current{outline:2px solid #23744b;outline-offset:-2px;background:#e5f4ea;font-weight:bold}
.sheet-compact #game #battle,.sheet-compact #battlefield,.sheet-compact #game .hpbox,.sheet-compact #battlemsg,.sheet-compact #actions,.sheet-compact #battleSub,.sheet-compact #lab,.sheet-compact #collectionPanel{background:#fff;color:#223a2c;border:1px solid #c2cfc7;box-shadow:none}
.sheet-compact #battlefield::before,.sheet-compact #battlefield::after{display:none}
.sheet-compact #controls button,.sheet-compact #joystick{border-radius:4px;background:#ecf1ee;color:#234231;box-shadow:none;border:1px solid #acbeb3}
.sheet-compact #controls small,.sheet-compact .arrow,.sheet-compact footer,.sheet-compact #notice{color:#486052}
#sheetDesk{display:none}
.sheet-compact.playing #sheetDesk{display:block;border:1px solid #ccd6cf;margin:6px 0;padding:8px;background:white}
#sheetDesk header{background:#eef3f0;color:#25392d;padding:4px 8px}
#sheetMetric,#sheetNote{padding:5px 8px;font-size:12px}
#sheetCommands{display:flex;flex-wrap:wrap;gap:4px}#sheetCommands button{font-size:12px;padding:6px 12px}
#sheetCommands .sheetSelected{border-color:#317451;background:#e5eee8}
.sheet-compact #fieldSheet{pointer-events:auto}.sheet-compact #fieldSheet [data-direction]{cursor:pointer;background:#f0f6f2}
body.sheet-compact #controls,body.sheet-compact #battle,body.sheet-compact #lab,body.sheet-compact #hud,body.sheet-compact #party,body.sheet-compact #notice,body.sheet-compact #eventSchedule,body.sheet-compact #progressInfo,body.sheet-compact #regionTitle,body.sheet-compact.playing #status,body.sheet-compact footer,body.sheet-compact #collectionOpen,body.sheet-compact #pvpOpen{display:none!important}
body.sheet-compact #game{height:clamp(310px,60vh,620px);min-height:310px;aspect-ratio:auto}
body.sheet-compact #game:has(#battle:not([hidden])) #fieldSheet,body.sheet-compact #game:has(#lab:not([hidden])) #fieldSheet{display:none}
body.sheet-compact.playing #fieldSheet{inset:10px 8px auto;pointer-events:auto;z-index:1}
body.sheet-compact.playing #join{position:static;display:inline-flex;margin-left:8px}
body.sheet-compact #collectionPanel{inset:4px;max-height:100%;overflow:auto}

#sheetTabs,.sheetRows,.sheetCols{display:none}
#sheetFrame{display:contents}
body.sheet-mode{background:#f3f6f4;color:#263a30}
.sheet-mode main{background:white}
.sheet-mode main>header{background:#236948;color:white;padding:8px 12px}
.sheet-mode #sheetTabs{display:flex;gap:2px;border-bottom:1px solid #a9c1b4;background:#eff3f1}
#sheetTabs button{border:0;border-radius:0;background:transparent;color:#42574a;padding:7px 14px}
#sheetTabs button[aria-pressed=true]{background:white;color:#196841;box-shadow:inset 0 -3px #278454;font-weight:600}
.sheet-mode:not(.sheet-compact) #sheetFrame{display:grid;grid-template-columns:24px minmax(0,1fr);grid-template-rows:22px auto;background:#f0f4f1;border:1px solid #bdccc3}
.sheet-mode:not(.sheet-compact) .sheetCols{grid-column:1/-1;display:grid;grid-template-columns:24px repeat(8,1fr)}
.sheet-mode:not(.sheet-compact) .sheetRows{display:grid;grid-template-rows:repeat(12,1fr)}
.sheetCols span,.sheetRows span{display:grid;place-items:center;border-right:1px solid #c9d5cd;border-bottom:1px solid #c9d5cd;color:#55695d;font:11px system-ui}
.sheet-mode:not(.sheet-compact) main>footer,.sheet-mode:not(.sheet-compact) #notice{color:#415e4b}
.sheet-mode.playing #join{position:static;display:inline-flex;margin-left:8px}

.sheet-mode:not(.playing) #join,
.sheet-mode #avatarSelect {
 background:#fff;
 border:1px solid #cad6ce;
 border-radius:0;
 color:#283b30;
}
.sheet-mode:not(.playing) #join {
 display:grid;
 grid-template-columns:repeat(4,minmax(0,1fr));
 gap:1px;
 background:#dce5de;
}
.sheet-mode:not(.playing) #join input,
.sheet-mode:not(.playing) #join button,
.sheet-mode #avatarOptions button {
 width:100%;
 background:#fff;
 color:#283b30;
 border:0;
 border-radius:0;
 box-shadow:none;
}
.sheet-mode:not(.playing) #join input {
 grid-column:span 2;
 min-height:38px;
}
.sheet-mode:not(.playing) #leaveButton {display:none}
.sheet-mode:not(.playing) #join button:hover,
.sheet-mode #avatarOptions button:hover {background:#f3f8f4}
.sheet-mode #avatarSelect {padding:8px 0 0}
.sheet-mode #avatarSelect>strong,
.sheet-mode #avatarSelect>small {margin-inline:8px}
.sheet-mode #avatarSelect>small {color:#52665a}
.sheet-mode #avatarOptions {
 gap:0;
 padding:0;
 border-top:1px solid #dce5de;
}
.sheet-mode #avatarOptions button {
 min-height:74px;
 border-right:1px solid #dce5de;
 border-bottom:1px solid #dce5de;
}
.sheet-mode #avatarOptions button[aria-pressed=true] {
 background:#f0f7f2;
 box-shadow:inset 0 0 0 2px #398058;
}
.sheet-mode:not(.sheet-compact) #sheetFrame,
.sheet-mode:not(.sheet-compact) #game {background:#fff}
.sheet-mode:not(.sheet-compact) #game::after {
 content:"";
 position:absolute;
 inset:0;
 z-index:28;
 pointer-events:none;
 background-color:#ffffff10;
 background-image:linear-gradient(to right,#284a3738 1px,transparent 1px),
                  linear-gradient(to bottom,#284a3738 1px,transparent 1px);
 background-size:calc(100% / 8) calc(100% / 12);
}

.sheet-mode #settingsOpen,
.sheet-mode.playing #join #leaveButton,
.sheet-mode #game :is(#collectionOpen,#pvpOpen) {
 background:#f7faf8;
 color:#183829;
 border:1px solid #739384;
 font-weight:700;
}
.sheet-mode #settingsOpen:hover,
.sheet-mode.playing #join #leaveButton:hover,
.sheet-mode #game :is(#collectionOpen,#pvpOpen):hover {background:#e2eee6}
#game #lab button:disabled,
#lab #facilityActions button:disabled,
.sheet-mode #sheetCommands button:disabled {
 opacity:1;
 background:#e2e6e2;
 color:#414b45;
 border:1px solid #a2aca5;
}

:is(#battlefield,#teamField) .move-particle{
 position:absolute;left:0;top:0;z-index:5;pointer-events:none;opacity:0;
 width:10px;height:10px;background:var(--move-color);border:2px solid var(--move-highlight);
}
:is(#battlefield,#teamField) .move-particle-slash,:is(#battlefield,#teamField) .move-particle-sweep{width:39px;height:14px}
:is(#battlefield,#teamField) .move-particle-beam{width:38px;height:8px}
:is(#battlefield,#teamField) .move-particle-pulse,:is(#battlefield,#teamField) .move-particle-guard{
 width:29px;height:20px;border:3px solid var(--move-color);background:transparent;border-radius:35%;
 box-shadow:inset 0 0 0 1px var(--move-highlight);
}
:is(#battlefield,#teamField) .move-particle-spark {
 width:14px;height:42px;border:0;
 background:linear-gradient(120deg,var(--move-highlight) 36%,var(--move-color) 73%);
}
:is(#battlefield,#teamField) .move-particle-shot{border-radius:30%}
:is(#battlefield,#teamField) .move-particle-dust{width:7px;height:7px}
:is(#battlefield,#teamField) :is(.move-particle-flame,.move-particle-ember) {
 width:26px;height:15px;border:0;border-radius:22% 72% 72% 22%;
 background:radial-gradient(ellipse at 74% 50%,var(--move-highlight),var(--move-color) 43%,transparent 74%);
}
:is(#battlefield,#teamField) .move-particle-ember{width:19px;height:12px}
:is(#battlefield,#teamField) .move-particle-stream {
 width:29px;height:9px;border:0;border-radius:80% 60% 55% 80%;
 background:linear-gradient(90deg,transparent,var(--move-color) 38%,var(--move-highlight));
}
:is(#battlefield,#teamField) :is(.move-particle-leaf,.move-particle-bloom) {
 width:15px;height:10px;border:1px solid var(--move-color);border-radius:85% 12% 85% 12%;
 background:linear-gradient(160deg,var(--move-highlight),var(--move-color) 62%,#275f3d);
}
:is(#battlefield,#teamField) .move-particle-vine {
 width:56px;height:11px;border:0;
 background:linear-gradient(var(--move-highlight),var(--move-color) 52%,#356548);
}
:is(#battlefield,#teamField) .move-particle-orb {
 width:20px;height:20px;border:0;border-radius:50%;
 background:radial-gradient(circle,var(--move-highlight),var(--move-color) 57%,transparent 73%);
 box-shadow:0 0 10px var(--move-color);
}
:is(#battlefield,#teamField) .move-particle-ring {
 width:34px;height:26px;border:2px solid var(--move-highlight);border-radius:50%;
 background:transparent;box-shadow:inset 0 0 5px var(--move-color),0 0 6px var(--move-color);
}
:is(#battlefield,#teamField) .move-particle-wave {
 width:31px;height:12px;border:0;border-radius:70% 90% 15% 15%;
 background:linear-gradient(var(--move-highlight),var(--move-color) 58%,transparent);
}
:is(#battlefield,#teamField) .move-particle-wind {
 width:37px;height:17px;border:2px solid transparent;border-top-color:var(--move-highlight);
 border-right-color:var(--move-color);border-radius:50%;background:transparent;
}
:is(#battlefield,#teamField) .move-particle-trail {
 width:34px;height:5px;border:0;border-radius:50%;
 background:linear-gradient(90deg,transparent,var(--move-color) 52%,var(--move-highlight));
}
:is(#battlefield,#teamField) .move-particle-needle {
 width:25px;height:8px;border:0;
 background:linear-gradient(90deg,var(--move-color),var(--move-highlight));
}
:is(#battlefield,#teamField) .move-particle-thread {
 width:30px;height:7px;border:0;border-top:2px solid var(--move-highlight);
 border-radius:48%;background:transparent;
}
:is(#battlefield,#teamField) .move-particle-rubble {
 width:15px;height:14px;border:0;
 background:linear-gradient(138deg,var(--move-highlight),var(--move-color) 56%,#564431);
}
:is(#battlefield,#teamField) .move-particle-spiral {
 width:25px;height:20px;border:2px solid var(--move-color);border-top-color:transparent;
 border-left-color:var(--move-highlight);border-radius:50%;background:transparent;
 box-shadow:0 0 5px var(--move-color);
}
:is(#battlefield,#teamField) .move-particle-bubble {
 width:13px;height:13px;border:1px solid var(--move-highlight);border-radius:50%;
 background:radial-gradient(circle at 30% 24%,#fff 9%,transparent 30%,var(--move-color) 90%);
}
:is(#battlefield,#teamField) .move-particle-sand {
 width:15px;height:10px;border:0;border-radius:55% 42% 35% 47%;
 background:radial-gradient(ellipse,var(--move-highlight) 15%,var(--move-color) 55%,transparent 75%);
}
@media(prefers-reduced-motion:reduce){:is(#battlefield,#teamField) .move-particle{display:none}}


#settingsDialog{
 width:min(390px,calc(100vw - 24px));max-height:calc(100dvh - 24px);
 color:#23392d;background:#fffdf3;border:1px solid #798a77;border-radius:10px;padding:15px;
 box-shadow:0 12px 38px #13251c55;
}
#settingsDialog::backdrop{background:#13221ab0}
.settingsHeader{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:13px}
.settingsHeader h2{font-size:18px;margin:0}
.settingsHeader form{margin:0}
#settingsDialog button{background:#eaf1e9;color:#23392d;border-color:#82978a;min-height:36px}
#settingsDialog fieldset{min-width:0;margin:0 0 10px;border:1px solid #c6d2c7;border-radius:5px;padding:8px 10px}
#settingsDialog fieldset:last-child{margin-bottom:0}
#settingsDialog legend{font-weight:700}
.volumeControl{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:0 8px;font-size:13px}
.volumeControl output{font-variant-numeric:tabular-nums}
#settingsDialog input[type=range]{grid-column:1/-1;width:100%;min-height:32px;margin:0;padding:0;accent-color:#376f50}
.settingToggle{display:flex;align-items:center;gap:8px;min-height:36px;cursor:pointer}
#settingsDialog input[type=checkbox]{flex:none;width:18px;height:18px;margin:0;accent-color:#376f50}

#teamOpen{margin:0 0 6px 4px}
#teamDialog{
 width:min(660px,calc(100vw - 18px));max-height:calc(100dvh - 18px);overflow:auto;
 padding:12px;background:#fffdf3;color:#24392d;border:1px solid #798a77;border-radius:10px;
}
#teamDialog::backdrop{background:#13221ab0}
.teamHeader{display:flex;justify-content:space-between;align-items:center;gap:8px}
.teamHeader h2{margin:0;font-size:18px}
#teamBanner{margin:6px 0}
#teamDialog select,#teamDialog button{font:inherit;color:#23392d;background:#eaf1e9;border:1px solid #82978a;border-radius:4px;padding:6px;min-height:34px}
#teamDialog select{width:100%}
#teamSetup,#teamActions{display:grid;gap:6px}
#teamSetup{grid-template-columns:repeat(2,minmax(0,1fr))}
#teamSetup p,#teamSetup button,#teamActions button,#teamMovePreview{grid-column:1/-1}
#teamSetup p{margin:0}
#teamRepresentatives{grid-column:1/-1;padding:8px;border:1px solid currentColor;border-radius:6px}
#teamRepresentatives summary{cursor:pointer}
#teamRepresentatives label,#teamRepresentatives button{margin-top:6px}
#teamActions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
#teamDialog h3{margin:0 0 5px;font-size:14px}
.teamCard{display:flex;align-items:center;gap:5px;margin:0 0 5px;padding:5px;background:#f0f4e9;border-radius:5px;border:1px solid #bacab5}
.teamCardSelf{border:2px solid #447e56;padding:4px}
.teamCardDown{opacity:.55}
.teamCard img{width:40px;height:42px;object-fit:contain;image-rendering:pixelated}
.teamCard div{min-width:0;overflow-wrap:anywhere}
.teamCard small{display:block;color:#405948}
.teamCard progress{display:block;width:100%;height:7px;accent-color:var(--team-hp)}
.teamCard .teamRecovery{color:#175d31;font-weight:600}
.teamStage{display:inline-block;margin:3px 3px 0 0;padding:1px 4px;border-radius:4px;background:#dceee3;color:#204b30;font-size:11px}
.teamStage[data-direction="down"]{background:#f4dddd;color:#791f2a}
#teamLog{max-height:110px;overflow:auto;margin:8px 0;padding-left:22px;font-size:12px}
#teamLog:empty{display:none}
#teamFooter{display:flex;justify-content:flex-end;margin-top:8px}

#fieldChat{margin:8px 0;padding:8px 10px;border:1px solid #81977a;border-radius:5px;background:#253a2d}
#fieldChatLog{list-style:none;margin:5px 0;padding:0;min-height:36px;max-height:100px;overflow:auto;overflow-wrap:anywhere}
#fieldChatLog li{padding:2px 0}
#fieldChatLog strong{color:#bde3b7}
#fieldChatForm{display:flex;flex-wrap:nowrap;margin:0}
#fieldChatInput{font-size:16px}
#fieldChatNotice:empty{display:none}
.sheet-compact #fieldChat{background:#fff;color:#24352f;border-color:#cad4ce}
.sheet-compact #fieldChatLog strong,.sheet-compact #fieldChatNotice{color:#285640}

#teamMovePreview{margin:0;color:#30463a;font-size:12px;line-height:1.45}

#teamNomination{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:6px}
.teamCardActing{outline:2px solid #2b7564;outline-offset:-2px}

#dungeonDialog{width:min(520px,calc(100vw - 18px));max-height:calc(100dvh - 18px);overflow:auto;padding:14px;background:#fffdf3;color:#24392d;border:1px solid #798a77;border-radius:10px}
#dungeonDialog::backdrop{background:#13221ab0}
#dungeonTitle{margin:0;font-size:18px}
#dungeonDialog select,#dungeonDialog button{font:inherit;color:#23392d;background:#eaf1e9;border:1px solid #82978a;border-radius:4px;padding:6px;min-height:36px}
#dungeonDialog select{width:100%}
.dungeonLineup{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:7px;margin-bottom:12px}
#dungeonRunHud{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:5px 8px;background:#27343c;color:#fff5de}
#dungeonGroup{margin:12px 0 0;border:1px solid #b8c3ae;padding:8px}
#dungeonJoinGroup{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
#dungeonJoinGroup input{width:100%;background:#fff;color:#24392d}

#teamDialog.teamBattleScreen{
 position:fixed;inset:0;width:100%;height:100dvh;max-width:none;max-height:none;margin:0;
 padding:clamp(8px,2vw,18px);box-sizing:border-box;border:none;border-radius:0;
 background:#182e28;color:#fff8df;overscroll-behavior:contain;
}
#teamDialog.teamBattleScreen[open]{display:flex;flex-direction:column}
.teamBattleScreen > :is(.teamHeader,#teamBanner,#teamArena,#teamFooter){
 width:100%;max-width:1080px;margin-inline:auto;
}
.teamBattleScreen .teamHeader{padding:4px 2px}
.teamBattleScreen #teamClock{font-variant-numeric:tabular-nums;color:#ffe49a;white-space:nowrap}
.teamBattleScreen #teamBanner{font-size:clamp(12px,2vw,15px);line-height:1.35;color:#e5ebd9}
#teamArena{display:flex;flex-direction:column;flex:1;gap:8px}
#teamArena[hidden]{display:none}
#teamField{
 position:relative;isolation:isolate;overflow:hidden;display:grid;grid-template-rows:1fr 1.08fr;
 flex:1 0 clamp(276px,57dvh,620px);min-height:276px;padding:6px clamp(4px,4vw,56px);
 border:2px solid #9aa78e;border-radius:10px;background:#bcaf91;
}
#teamScenery{position:absolute;inset:0;width:100%;height:100%;image-rendering:pixelated;z-index:-2}
#teamField::before{
 content:'';position:absolute;inset:40% 0 0;z-index:-1;pointer-events:none;
 background:repeating-linear-gradient(0deg,transparent 0 40px,#f9e7be29 40px 42px),
 repeating-linear-gradient(90deg,transparent 0 65px,#f9e7be24 65px 67px);
 mask-image:linear-gradient(transparent,#000);
}
.teamLine{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(4px,2vw,26px);align-items:center}
.teamLineEnemy{padding-inline:7%}
.teamLine .teamCard{
 position:relative;display:flex;flex-direction:column;justify-content:center;min-width:0;
 gap:1px;margin:0;padding:0;border:0;border-radius:0;background:none;outline:0;
}
.teamLineEnemy .teamCard{flex-direction:column-reverse}
.teamFigure{position:relative;isolation:isolate;display:grid;place-items:end center;width:100%}
.teamFigure::before{
 content:'';position:absolute;bottom:2%;width:88%;max-width:190px;height:25%;z-index:-1;
 border-radius:50%;background:#ced4bb;border:2px solid #7e9984;box-shadow:0 4px #403b34a0;
}
.teamLineEnemy .teamFigure::before{background:#dcd0bd;border-color:#a0857e}
.teamCardActing .teamFigure::before{
 border-color:#fff3a9;box-shadow:0 0 0 2px #9f6837,0 2px 12px #ffdfa6;
}
#battle .battle-idle{width:100%;height:100%}
#battleScenery,#teamScenery{object-fit:cover;object-position:50% 58%}
.battle-idle{display:block;transform-origin:50% 88%}
.teamFigure .battle-idle{width:min(100%,17dvh,154px);height:clamp(60px,14dvh,138px)}
.teamLineEnemy .teamFigure .battle-idle{width:min(100%,15dvh,134px);height:clamp(53px,12dvh,114px)}
.teamFigure img{display:block;width:100%;height:100%;transform-origin:50% 85%}
@media(prefers-reduced-motion:no-preference){
 body:not(.sheet-compact) #battle:not([hidden],.capture-success,.capture-breakout) .sprite:not(.cast-down) .battle-idle[data-motion],
 body:not(.sheet-compact) #teamDialog[open] #teamArena:not([hidden]) .teamCard:not(.teamCardDown) .battle-idle[data-motion] {
  animation:battle-idle var(--idle-period,2.8s) var(--idle-delay,0s) ease-in-out infinite;
 }
 .own-sprite .battle-idle,.teamCard:nth-child(2) .battle-idle{--idle-delay:-.85s}
 .teamCard:nth-child(3) .battle-idle{--idle-delay:-1.7s}
 .battle-idle[data-motion="heavy"]{--idle-period:3.7s;--idle-stretch:1.016;--idle-width:1.012}
 .battle-idle[data-motion="fly"] {
  --idle-period:1.9s;--idle-base:-2px;--idle-peak:-8px;--idle-tilt:1.3deg;
 }
 .battle-idle[data-motion="hover"] {
  --idle-period:3.1s;--idle-base:-4px;--idle-peak:-12px;--idle-tilt:-1deg;
 }
}
@keyframes battle-idle{
 0%,100%{transform:translateY(var(--idle-base,0px)) scale(1)}
 50%{transform:translateY(var(--idle-peak,-1px)) rotate(var(--idle-tilt,0deg)) scale(var(--idle-width,.994),var(--idle-stretch,1.034))}
}
.teamLine .teamVitals{
 width:min(100%,205px);box-sizing:border-box;padding:4px 6px;background:#fffbed;
 color:#20362d;border:1px solid #647762;border-radius:6px;box-shadow:0 2px #483b3255;
 line-height:1.16;font-size:clamp(11px,1.75vw,15px);
}
.teamLine .teamCardSelf .teamVitals{border-left:4px solid #26816b}
.teamLine .teamCardActing .teamVitals{outline:2px solid #fff4a1}
.teamLine .teamVitals small{font-size:clamp(9px,1.4vw,12px)}
.teamVitals progress{margin-block:3px}
.teamLine .teamStage{font-size:10px;margin:1px 2px 0 0;padding:1px 2px}
.teamBattleScreen #teamActions,.teamBattleScreen #teamNomination{
 padding:7px 9px;border:1px solid #95a58b;border-radius:7px;background:#f7f3df;color:#20362d;
}
.teamBattleScreen #teamActions button{justify-self:end;min-width:110px}
.teamBattleScreen #teamLog{max-height:min(10dvh,76px);margin:0;color:#e7eedb}
.teamBattleScreen #teamFooter{margin-top:5px}
#teamField .move-particle-quake{width:17px;height:13px;clip-path:polygon(0 82%,35% 8%,73% 18%,100% 100%,17% 100%)}
#teamField .move-particle-aura{width:12px;height:12px;clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%)}
@media(max-height:560px) and (orientation:landscape){
 #teamField{flex-basis:245px;min-height:245px}
 .teamBattleScreen #teamLog{max-height:55px}
}

#teamField .teamPick{
 position:absolute;inset:0;z-index:2;width:100%;padding:0;background:transparent;border:1px dashed #fff4c9;
 border-radius:9px;touch-action:manipulation;cursor:pointer;
}
#teamField .teamPick:is([aria-pressed="true"],:focus-visible){
 border:2px solid #ffed8e;outline:2px solid #36544b;outline-offset:-3px;
 box-shadow:0 0 10px #fff2b080;
}
#teamMove{grid-column:1/-1;display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,108px),1fr));gap:5px}
#teamDialog #teamMove button{
 min-width:0;min-height:42px;justify-self:stretch;grid-column:auto;text-align:left;line-height:1.2;
}
#teamMove strong,#teamMove small{display:block}
#teamMove small{margin-top:3px;font-size:11px}
#teamDialog #teamMove button[aria-pressed="true"]{background:#ceebdc;border-color:#277862;box-shadow:inset 0 0 0 1px #277862}
#teamDialog #teamMove button:disabled{opacity:.52}
#teamTarget{align-self:center;font-size:12px;font-weight:700}
#teamActions #teamCommit{grid-column:2;grid-row:2}
#teamActions #teamMovePreview{grid-row:3}
@media(max-width:540px){#teamField{flex-basis:clamp(264px,47dvh,375px);min-height:264px}}

#lab:has(.residentPortrait){padding-left:83px;min-height:88px}
.residentPortrait{position:absolute;top:9px;left:9px;width:64px;height:64px;background:#edf0df url('/sprites/resident-portraits.png?v=faces64') no-repeat;image-rendering:pixelated;border-radius:4px}
.castGuide{display:inline-block;margin-left:8px;color:inherit;font-size:12px;text-underline-offset:3px}
#settingsDialog .castGuide{margin-left:0;padding:8px 0;font-size:14px}

#avatarOptions button canvas{width:64px;height:64px}

/* Native species artwork stays crisp; give the starter and avatar previews sufficient room. */
#avatarOptions button canvas{width:96px;height:96px;max-width:100%;object-fit:contain;image-rendering:pixelated}
#avatarOptions button{min-height:118px}
#starterChoices img{width:clamp(64px,12vw,96px);height:clamp(64px,12vw,96px);object-fit:contain;image-rendering:pixelated}

#battleAutoBattleToggle{grid-column:1/-1;justify-self:end;align-self:end;margin:3px 4px}
.teamHeaderControls{display:flex;align-items:center;justify-content:flex-end;gap:6px}
#battle .battleAutoToggle,#teamDialog .battleAutoToggle{
 min-height:32px;padding:4px 8px;border:1px solid #5a7465;border-radius:5px;
 background:#f3f5ed;color:#253b30;font-size:12px;font-weight:700;white-space:nowrap;
}
#battle .battleAutoToggle[aria-pressed="true"],#teamDialog .battleAutoToggle[aria-pressed="true"]{
 border-color:#294f39;background:#366044;color:#f5ffe9;
}
