/* Local visual pilot; gameplay and shared chrome remain owned by the page. */
body { background:radial-gradient(ellipse at 50% 0%,#d9f6ff 0%,#fff0d8 65%,#f7d5ad 100%); }
h1 { font-family:'Fredoka',sans-serif; color:#173955; text-shadow:0 2px 0 #fff; letter-spacing:0; }
a.back { color:#245978; }
#hud > span { background:linear-gradient(#fff,#e5f6fc); color:#173955; border:1px solid #bddfe9; border-radius:16px; box-shadow:0 3px 0 #9bbecb,0 6px 15px #174b6820; }
#hud > span span { background:transparent; color:inherit; box-shadow:none; padding:0; border:0; }
.progress-track,#nitroBar { background:#c5dfeb; box-shadow:inset 0 2px 4px #24597830; }
.progress-fill { background:linear-gradient(90deg,#16aee6,#60dac5); }
#wrap { border-radius:24px; }
#startGate,#overlay,html.dark #startGate { color:#173955; background:linear-gradient(165deg,#f5fcfff5,#fff1d9f5); border:2px solid #fff; border-radius:24px; box-sizing:border-box; box-shadow:inset 0 0 30px #fff8; }
#startGate .sg-title,#overlay .msg { font-family:'Fredoka',sans-serif; color:#173955; }
#startGate .sg-desc { opacity:1; color:#42647a; }
#startGate .sg-icon { animation:none; }
#startGate .sg-icon::before { content:''; display:block; width:110px; height:110px; margin:0 auto 8px; background:var(--pilot-portrait) center/contain no-repeat; border-radius:22px; }
#overlay .big { color:#173955; }
#wrap .btn { min-height:48px; border-radius:16px; background:linear-gradient(#26c2f3,#1687d2); box-shadow:0 4px 0 #10659e,0 7px 18px #1687d230; color:#fff; }
#wrap .btn.alt { background:linear-gradient(#fff,#e5f5fb); color:#245978; box-shadow:0 4px 0 #a7c8d5; }

body { --pilot-portrait:url('card-back.webp'); }
#wrap.panel,html.dark #wrap.panel { background:linear-gradient(145deg,#effaff,#fff4e0); border:2px solid #fff; box-shadow:0 12px 30px #174b6825; padding:22px 12px; }
#grid { justify-content:center; gap:10px; }
.flip-front { background:linear-gradient(135deg,#26c2f3,#1687d2); border:2px solid #fff; box-shadow:0 4px 0 #1687a5,0 5px 12px #174b6830; overflow:hidden; }
.flip-back { background:linear-gradient(#fff,#eaf7ff); border:2px solid #fff; box-shadow:0 4px 0 #a7c8d5; overflow:hidden; }
.flip-outer.matched .flip-back { background:linear-gradient(#d2ffe8,#74dec3); border-color:#fff4aa; box-shadow:0 4px 0 #36a38b,0 0 12px #ffd56c; }
.pilot-card-art { position:absolute; inset:0; width:100%; height:100%; object-fit:contain; opacity:0; image-rendering:auto; }
.flip-front .pilot-card-art { object-fit:cover; }
.pilot-card-art.is-ready { opacity:1; }
.pilot-fallback { display:flex; align-items:center; justify-content:center; width:100%; height:100%; }
.pilot-fallback.is-hidden { visibility:hidden; }
#muteCtl { width:48px; height:48px; border-radius:16px; background:#effaff; color:#173955; box-shadow:0 3px 0 #a7c8d5; }
@media(max-width:420px) { #grid { gap:6px; grid-template-columns:repeat(var(--pilot-cols,4),minmax(0,70px)) !important; } .flip-outer { width:100%; } }
/* Content-sized panel; fractional columns use the available width at every level. */
#wrap.panel { width:100%; max-width:620px; min-height:0; height:auto; padding:16px 12px; }
#grid { width:100%; grid-template-columns:repeat(var(--pilot-cols,4),minmax(0,1fr)) !important; gap:10px; }
#grid .flip-outer { width:100%; height:auto; aspect-ratio:1; min-width:0; padding:0; background:transparent; box-shadow:none; perspective:800px; }
#grid .flip-inner { transform-style:preserve-3d; transition:transform .48s cubic-bezier(.2,.75,.25,1); }
#grid .flip-front,#grid .flip-back { box-sizing:border-box; backface-visibility:hidden; -webkit-backface-visibility:hidden; }
#grid .flip-front { transform:rotateY(0deg); }
#grid .flip-back { transform:rotateY(180deg); }
#grid .is-flipped .flip-inner { transform:rotateY(180deg); }
#grid .matched { animation:pilot-pair-pop .65s ease-out; }
#grid .matched::after { content:'✦'; position:absolute; right:-3px; top:-8px; color:#ffca45; font-size:25px; pointer-events:none; text-shadow:0 0 8px #fff; animation:pilot-sparkle .8s ease-out forwards; }
@keyframes pilot-pair-pop { 0%,100%{transform:scale(1)} 45%{transform:scale(1.08)} }
@keyframes pilot-sparkle { 0%{opacity:0;transform:scale(.4)} 40%{opacity:1;transform:scale(1.3) rotate(20deg)} 100%{opacity:0;transform:translateY(-16px) rotate(50deg)} }
.pilot-win-art { display:flex; align-items:center; justify-content:center; gap:8px; width:100%; }
.pilot-win-art img { width:clamp(55px,17vw,100px); height:auto; filter:drop-shadow(0 5px 5px #174b6825); }
.pilot-win-art span { font-size:2rem; }
#wrap #overlay { padding:12px; gap:10px; overflow:auto; }
@media(max-width:420px) { #grid { gap:6px; } #wrap.panel { padding:12px 8px; } }
@media(prefers-reduced-motion:reduce) { #grid .flip-inner { transition-duration:.01s; } #grid .matched,#grid .matched::after { animation:none; } }
/* Win content gets its own space even on the shortest six-card round. */
#wrap.panel:has(#overlay.show) { min-height:390px; }
#wrap #overlay { box-sizing:border-box; }
