/* R63: native controls over the original generated comic background.
   CSS rows reserve real space for navigation, the egg and the hatch action. */
body:not(.playing) #workshop-nav{grid-template-columns:repeat(5,minmax(0,1fr))}
#workshop-nav [data-screen=research] svg{width:32px;height:36px;fill:#cfdbb8;stroke:#4e8e9c;stroke-width:1.5}
#research-screen{position:relative;inset:auto;grid-row:3;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto auto;gap:10px;min-width:0;min-height:0;width:100%;height:100%;padding:12px max(20px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));z-index:5;overflow:hidden;pointer-events:none}
#research-screen[hidden]{display:none}
#research-screen>:is(.research-heading,#research-egg-space,.research-pity,.research-actions){grid-column:1}
#research-screen .research-heading{grid-row:1;display:flex;align-items:center;gap:12px;min-width:0;min-height:44px;pointer-events:auto}
#research-screen h1{margin:0;font-size:clamp(22px,3vw,36px);font-weight:950;font-style:italic;color:#fff8e9;text-shadow:3px 3px #080918}
.research-heading .back{min-height:44px;min-width:44px;padding:4px 12px;font-size:24px}
#research-info{min-height:44px;padding:6px 16px;font-size:14px;white-space:nowrap}
.research-dna{margin-left:auto;display:flex;align-items:center;gap:10px;padding:8px 14px;border:1px solid #80688d;background:#111024d9;color:#d6c6df;font-size:14px;white-space:nowrap}
.research-dna strong{color:#ffda65;font-size:22px;font-variant-numeric:tabular-nums}
#research-egg-space{grid-row:2;min-width:0;min-height:0;width:100%;justify-self:center}
.research-pity{grid-row:3;display:grid;grid-template-columns:1fr 1fr;gap:26px;width:min(100%,680px);justify-self:center;padding:6px 14px;background:#111024c9;border:1px solid #70527d;pointer-events:auto}
.pity-gauge{display:grid;grid-template-columns:1fr auto;align-items:center;gap:6px 8px;color:#e0baff;font-size:14px;min-width:0}
.pity-gauge.five{color:#ffda72}
.pity-gauge strong{color:#fff4de;font-variant-numeric:tabular-nums;white-space:nowrap}
.pity-gauge label{white-space:nowrap}
.pity-gauge progress{grid-column:1/-1;width:100%;height:8px;border:1px solid #746080;background:#131124;accent-color:#ba7ef2;overflow:hidden}
.pity-gauge progress::-webkit-progress-bar{background:#131124}
.pity-gauge progress::-webkit-progress-value{background:linear-gradient(90deg,#744ab7,#d09bff)}
.pity-gauge.five progress{accent-color:#ffcc48}
.pity-gauge.five progress::-webkit-progress-value{background:linear-gradient(90deg,#bb731d,#ffdf73)}
.research-actions{grid-row:4;display:flex;align-items:center;justify-content:center;gap:18px;min-width:0;max-width:100%;pointer-events:auto}
.hatch-command{display:grid;grid-template-rows:auto auto;gap:3px;width:min(46vw,440px);text-align:center}
#egg-price{font-size:14px;font-weight:800;color:#fff3d6;text-shadow:1px 2px #080918;font-variant-numeric:tabular-nums}
#hatch-egg{min-height:66px;min-width:0;width:100%;padding:8px 24px;font-size:clamp(22px,3vw,32px);font-style:italic;font-weight:950;color:#221322;background:linear-gradient(135deg,#ffe992,#ffc529 55%,#eb951c);border:2px solid #ffe9a3;box-shadow:inset 0 -5px #c47816,0 4px #2b1128;clip-path:polygon(16px 0,calc(100% - 16px) 0,100% 16px,calc(100% - 8px) calc(100% - 8px),calc(100% - 20px) 100%,0 100%,0 16px)}
#hatch-egg:hover:enabled{filter:brightness(1.12)}
#hatch-egg:disabled{filter:saturate(.35);opacity:.6;cursor:default}
#research-trial{min-height:48px;padding:8px 20px;font-size:16px;color:#f1e9f3;background:#171628;border:1px solid #9b83ad}
#research-screen :is(button,progress){pointer-events:auto}
#research-screen button:focus-visible,#research-details button:focus-visible{outline:3px solid #fff;outline-offset:-6px}
#research-screen[data-phase]:not([data-phase=idle]) .research-pity{visibility:hidden;pointer-events:none}
#research-screen[data-phase]:not([data-phase=idle]) .research-actions{visibility:hidden;pointer-events:none}
#research-screen[data-phase]:not([data-phase=idle]):not([data-phase=revealed]){grid-template-rows:auto minmax(0,1fr) 0 0}
#hatch-flash{position:fixed;inset:0;background:#fff;z-index:90;pointer-events:none;opacity:var(--hatch-flash,0)}
body:not([data-screen=research]) #hatch-flash{display:none}
#research-screen #hatch-result{grid-column:1;grid-row:2/5;justify-self:center;align-self:stretch;width:min(100%,960px);height:100%;min-width:0;min-height:0;display:grid;grid-template-rows:minmax(0,1fr) auto;padding:clamp(8px,2vw,20px);color:#fff5e1;background:radial-gradient(ellipse at 50% 35%,#44335b9c,#171328e6 68%);border:2px solid var(--rarity,#f4c366);pointer-events:auto;overflow:auto}
#research-screen #hatch-result[hidden]{display:none}
.hatch-reveal-art{min-width:0;min-height:0;display:grid;place-items:center;background:radial-gradient(ellipse,#fff1b31a,transparent 66%)}
#hatch-dino-art{width:100%;height:100%;min-height:0;object-fit:contain;filter:drop-shadow(0 8px 1px #100b25aa);animation:hatch-art-entrance .32s cubic-bezier(.15,.75,.25,1) both}
.hatch-reveal-caption{display:grid;grid-template-columns:1fr auto;grid-template-areas:"tag stars" "name button" "bonus button";gap:3px 20px;align-items:center;padding:8px 12px;border-top:1px solid #b7a1c850;text-align:left}
#hatch-tag{grid-area:tag;color:var(--rarity,#ffce43);font-size:14px;font-weight:800}
#hatch-stars{grid-area:stars;justify-self:end;color:var(--rarity,#ffce43);font-size:26px;letter-spacing:4px}
#hatch-name{grid-area:name;font-size:clamp(24px,3vw,36px);margin:0}
#hatch-bonus{grid-area:bonus;margin:0;font-size:14px;color:#e7d9ec}
#hatch-continue{grid-area:button;width:auto;min-width:180px;min-height:50px;padding:8px 20px;background:#ffc64c;color:#20182b;font-size:20px;font-weight:900}
#research-details{width:min(620px,calc(100% - 24px));max-height:calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:0;color:#eee5f4;background:#181426;border:2px solid #9a80b0;box-shadow:8px 8px #080714;overflow:hidden}
#research-details::backdrop{background:#080817c9;backdrop-filter:blur(5px)}
#research-details[open]{display:flex;flex-direction:column}
#research-details>header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 16px;border-bottom:1px solid #675175;flex:none}
#research-details h2{margin:0;font-size:23px;color:#ffe1a2}
#research-info-close{min-height:44px;padding:6px 15px}
.research-details-body{min-height:0;overflow:auto;overscroll-behavior:contain;padding:16px}
.research-inventory{display:grid;grid-template-columns:1fr auto;margin:0 0 16px;gap:12px}
.research-inventory dd{margin:0;color:#ffe1a2;font-weight:900}
.mecha-gene-panel{display:grid;grid-template-columns:1fr auto;gap:8px;padding:12px;border:1px solid #665476;background:#121223}
.mecha-gene-panel progress{grid-column:1/-1;width:100%;accent-color:#ffc84e}
#research-details h3{font-size:16px;margin:18px 0 8px;color:#ffe1a2}
#egg-odds-list>div{display:grid;grid-template-columns:44px 1fr auto;gap:8px;align-items:center;padding:6px 0;border-bottom:1px solid #65517666;font-size:14px}
#egg-odds-list img{width:44px;height:40px;object-fit:contain}
#egg-odds-list strong{color:#ffe1a2}
#egg-odds-list .star-odds{display:block;font-size:16px;font-weight:900}
#egg-odds-list p,#egg-next-odds{font-size:14px;line-height:1.6;color:#e1d8e7}
.research-home-entry{position:absolute;right:30px;top:110px;min-height:50px;padding:8px 20px;background:#234457;color:#bceef0;border:1px solid #74c5ce;font-size:18px;font-weight:800;pointer-events:auto}
body.portal-travel:after{content:"";position:fixed;inset:0;z-index:150;pointer-events:all;background:radial-gradient(ellipse,#92ecf5bb,#123e62ed);backdrop-filter:blur(3px)}
@keyframes hatch-art-entrance{from{opacity:0;transform:translateY(12px) scale(.94)}to{opacity:1;transform:none}}
@media(max-width:600px){.brand-mark{flex-shrink:0}
#research-screen{padding:8px 10px max(10px,env(safe-area-inset-bottom));gap:7px}
#research-screen .research-heading{gap:7px}
#research-screen h1{font-size:24px}
.research-dna{gap:5px;padding:6px 8px;font-size:12px}
.research-dna strong{font-size:18px}
#research-info{padding:5px 9px;font-size:12px}
.research-pity{padding:8px;gap:12px}
.pity-gauge{gap:5px;font-size:11px}
.research-actions{gap:8px;flex-wrap:wrap}
.hatch-command{width:min(100%,360px)}
#hatch-egg{min-height:58px;font-size:27px}
#egg-price{font-size:12px}
#research-trial{min-height:44px;font-size:13px;padding:5px 12px}
.hatch-reveal-caption{grid-template-columns:1fr auto;grid-template-areas:"tag stars" "name name" "bonus bonus" "button button";padding:6px;gap:3px}
#hatch-continue{width:100%;min-width:0;min-height:46px;font-size:18px}
#hatch-name{font-size:25px}
.research-home-entry{right:12px;top:96px;min-height:44px;font-size:15px}


}
@media(max-height:570px){#research-screen{gap:5px;padding-top:5px;padding-bottom:max(6px,env(safe-area-inset-bottom))}
#research-screen .research-heading{min-height:44px}
#research-screen h1{font-size:24px}
.research-pity{padding:5px 10px}
.pity-gauge{font-size:12px;gap:3px 6px}
.pity-gauge progress{height:6px}
.hatch-command{gap:1px;width:min(50vw,380px)}
#hatch-egg{min-height:48px;font-size:24px}
#egg-price{font-size:12px}
#research-trial{min-height:44px}
.hatch-reveal-caption{padding:5px 8px}
#hatch-continue{min-height:44px;font-size:18px}
#hatch-bonus{font-size:12px}


}
@media(max-width:420px) and (max-height:570px){.pity-gauge{font-size:10px}
.research-pity{gap:8px;padding:5px}
.hatch-command{width:100%}
#research-trial{min-height:44px}
.research-actions{gap:4px}
}
@media(prefers-reduced-motion:reduce){#hatch-dino-art{animation:none}
}
body.reduced-effects #hatch-dino-art{animation:none}
/* The shared metal theme paints a pseudo-element face. Match that actual face,
   rather than placing dark text on its old dark selected background. */
body #research-details{padding:0;background:#181426;border-color:#9a80b0;box-shadow:8px 8px #080714}
body #research-details h2,body #research-details h3{color:#ffe1a2}
#mecha-gene-progress{appearance:none;height:8px;background:#111024;border:1px solid #746080}
#mecha-gene-progress::-webkit-progress-bar{background:#111024}
#mecha-gene-progress::-webkit-progress-value{background:#ffca55}
/* Existing grade-skin controls remain outside the hatch layout. */
#dino-skins{margin:6px 0;width:100%;grid-area:skins;display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:10px}
#dino-skins h3{font-size:13px;margin:0 0 4px;color:#cbd7e6;grid-column:1}
.skin-choices{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:5px;grid-column:1}
.skin-choices button{min-height:44px;padding:7px 3px;color:var(--rarity);border:1px solid #526078;background:#151d2b;font-size:13px;letter-spacing:-1px;white-space:nowrap}
.skin-choices button[aria-pressed=true]{border:2px solid var(--rarity);background:#303147;box-shadow:0 0 10px #0008}
.skin-choices button[data-locked=true]{opacity:.6}
.skin-choices button:focus-visible{outline:3px solid #fff;outline-offset:2px}
#dino-skins p{font-size:12px;margin:4px 0;color:#cbd7e6;grid-column:1}
#dino-skins .skin-apply{min-height:44px;padding:6px 15px;font-size:14px;grid-column:2;grid-row:1/4;align-self:center}
.skin-apply:disabled{opacity:.55}
@media(min-width:1101px) and (min-height:641px){#dinos-screen .dino-detail{grid-template-areas:"summary stats" "traits stats" "skill skill" "skins skins" "actions actions"}
}
@media(max-width:1100px){#dino-skins{display:block}
#dino-skins .skin-apply{width:100%;margin-top:4px}
}


