:root{color-scheme:dark;background:#171128;color:#fff0df;font-family:system-ui,sans-serif}
*{box-sizing:border-box}body{margin:0}
header,main{max-width:72rem;margin:auto;padding:1rem}
header{display:flex;justify-content:space-between;gap:1rem;border-bottom:1px solid #795a96}
a{color:#ffdb99}h1,h2{font-family:Georgia,serif;color:#ffe7b5}
#side-player{padding:clamp(.65rem,3vw,1.25rem);border:1px solid #9d77b6;border-radius:1rem;background:#281a40}
#side-canvas{width:100%;height:auto;display:block;border:1px solid #b88ed4;border-radius:.65rem;background:#1a1230}
.side-hud,.side-controls{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin:.65rem 0}
.side-controls button,.side-hud button{min-height:48px;padding:.45rem .7rem;font:700 1rem system-ui;border:1px solid #d2a7e4;border-radius:.5rem;background:#472d65;color:white;touch-action:none}
.side-hud button{background:#ffdf9e;color:#281738}
#side-status{min-height:1.5em}
@media(max-width:470px){.side-controls button{flex:1 1 auto;font-size:.82rem}}

/* Shared ergonomic layout for all 25 side-scroll adventures. */
#side-player .side-controls{
  display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;
  width:100%;gap:clamp(4px,1.2vw,12px);padding-inline:max(0px,env(safe-area-inset-left)) max(0px,env(safe-area-inset-right));
  touch-action:manipulation;
}
#side-player .side-controls .touch-joystick{
  flex:0 0 clamp(72px,15vw,92px);width:clamp(72px,15vw,92px);height:clamp(72px,15vw,92px);
  margin-right:auto;touch-action:none;
}
#side-player .side-controls button{
  flex:0 1 auto;min-width:0;white-space:nowrap;
  padding-inline:clamp(6px,1.5vw,14px);touch-action:none;
}
#side-player .side-controls button[data-control="jump"]{order:3}
#side-player .side-controls button[data-control="action"]{order:1}
#side-player .side-controls button[data-control="technique"]{order:2}
@media(max-width:470px){
  #side-player .side-controls{gap:4px}
  #side-player .side-controls button{flex:0 1 auto;font-size:clamp(.65rem,2.8vw,.85rem);padding-inline:5px}
}
#side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls{
  justify-content:space-between;max-width:none;width:100%;
}

/* Polished translucent mobile gamepad, shared by all 25 adventures. */
#side-player .side-controls{user-select:none;-webkit-user-select:none}
#side-player .side-controls .touch-joystick{
  border:2px solid rgba(193,231,255,.72);
  background:radial-gradient(circle at 35% 25%,rgba(132,174,242,.40),rgba(26,37,77,.68) 70%);
  box-shadow:inset 0 0 0 6px rgba(255,255,255,.07),0 6px 20px rgba(0,0,0,.27);
  backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);
}
#side-player .side-controls .touch-joystick>span{
  background:linear-gradient(145deg,rgba(255,255,255,.95),rgba(139,176,249,.82));
  box-shadow:0 3px 10px rgba(0,0,0,.42),inset 0 1px 2px rgba(255,255,255,.7);
}
#side-player .side-controls button{
  border:1px solid rgba(227,212,255,.7);
  border-radius:999px;
  background:linear-gradient(145deg,rgba(119,79,174,.78),rgba(43,33,92,.72));
  box-shadow:0 4px 13px rgba(0,0,0,.28),inset 0 1px 1px rgba(255,255,255,.26);
  color:#fff;min-height:clamp(48px,9dvh,62px);
  text-shadow:0 1px 2px rgba(0,0,0,.5);
  backdrop-filter:blur(7px);-webkit-backdrop-filter:blur(7px);
  -webkit-tap-highlight-color:transparent;
}
#side-player .side-controls button[data-control="jump"]{
  background:linear-gradient(145deg,rgba(56,171,211,.85),rgba(22,83,158,.78));
  border-color:rgba(178,245,255,.85);
}
#side-player .side-controls button:active,
#side-player .side-controls button[aria-pressed="true"]{
  transform:scale(.95);filter:brightness(1.22);
  box-shadow:inset 0 2px 8px rgba(0,0,0,.35),0 0 12px rgba(132,219,255,.4);
}
#side-player .side-controls button:focus-visible,
#side-player .side-controls .touch-joystick:focus-visible{
  outline:3px solid #fff0a6;outline-offset:3px;
}
@media(prefers-reduced-motion:no-preference){
  #side-player .side-controls button{transition:transform .09s ease,filter .09s ease}
}

/* Fullscreen landscape: pin the gamepad to the lower screen corners. */
#side-player:is(:fullscreen,.game-fullscreen-expanded){position:relative;overflow:hidden}
#side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls{
  position:absolute;left:0;right:0;bottom:0;z-index:20;
  margin:0;padding:8px max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
  background:transparent;pointer-events:none;
  display:flex;justify-content:space-between;align-items:flex-end;
}
#side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls>*{pointer-events:auto}
#side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls .touch-joystick{
  margin-right:auto;align-self:flex-end;
}
#side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls button{
  align-self:flex-end;
}
@media(orientation:landscape) and (max-height:520px){
  #side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls .touch-joystick{
    width:clamp(66px,20dvh,90px);height:clamp(66px,20dvh,90px);flex-basis:clamp(66px,20dvh,90px);
  }
  #side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls button{
    min-height:clamp(44px,13dvh,58px);
  }
}

/* Approved concept: a separate illustrated controller deck BELOW the playfield. */
#side-player .side-controls{
  position:relative!important;inset:auto!important;
  display:flex;align-items:center;justify-content:space-between;
  min-height:clamp(116px,23dvh,178px);width:100%;margin:0!important;
  padding:clamp(10px,2vw,18px)!important;
  border:3px solid rgba(255,210,100,.85);border-radius:20px;
  background:
    linear-gradient(100deg,rgba(11,32,84,.92),rgba(63,26,111,.66) 46%,rgba(8,30,85,.94)),
    url('../assets/whisker-luna-master.webp') center 43%/auto 235% no-repeat;
  box-shadow:inset 0 0 0 3px #4ad7ff90,inset 0 0 25px #a366ff88,0 8px 22px #0008;
  isolation:isolate;overflow:hidden;
}
#side-player .side-controls::before{
  content:'SUPER PAW HEROES  ★  ' attr(data-stage-title);
  position:absolute;left:23%;right:29%;top:7px;text-align:center;
  font:900 clamp(9px,1.8vw,16px) system-ui,sans-serif;letter-spacing:.06em;
  color:#fff0b3;text-shadow:0 2px 5px #10042b,0 0 9px #8b58ff;
  pointer-events:none;
}
#side-player .side-controls::after{
  content:'👍  WHISKER  ★  LUNA  👍';
  position:absolute;left:25%;right:29%;bottom:9px;text-align:center;
  font:900 clamp(10px,2vw,16px) system-ui,sans-serif;
  color:white;text-shadow:0 2px 5px #10042b,0 0 9px #aa78ff;
  pointer-events:none;
}
#side-player .side-controls[data-stage-theme="1"]{border-color:#82ecff;filter:hue-rotate(12deg)}
#side-player .side-controls[data-stage-theme="2"]{border-color:#ffbe67;filter:hue-rotate(-18deg)}
#side-player .side-controls[data-stage-theme="3"]{border-color:#cfa0ff;filter:hue-rotate(32deg)}
#side-player .side-controls[data-stage-theme="4"]{border-color:#93f6ba;filter:hue-rotate(66deg)}
#side-player .side-controls[data-stage-theme="5"]{border-color:#ffd978;filter:hue-rotate(-42deg)}
#side-player .side-controls .touch-joystick{position:relative;z-index:1;flex-shrink:0}
#side-player .side-controls button{position:relative;z-index:1;flex-shrink:0}
#side-player:is(:fullscreen,.game-fullscreen-expanded){overflow:auto!important}
#side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls{
  position:relative!important;bottom:auto!important;left:auto!important;right:auto!important;
  margin-top:4px!important;
}
#side-player:is(:fullscreen,.game-fullscreen-expanded) #side-canvas{
  width:min(100%,calc(65dvh * 800 / 380));max-height:65dvh;object-fit:contain;
}
@media(orientation:landscape) and (max-height:520px){
  #side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls{
    min-height:clamp(82px,24dvh,124px);padding:6px 12px!important;
  }
  #side-player:is(:fullscreen,.game-fullscreen-expanded) #side-canvas{
    max-height:56dvh;width:min(100%,calc(56dvh * 800 / 380));
  }
  #side-player .side-controls::after{display:none}
}

/* Use available canonical hero art; avoid requesting a missing controller asset. */
#side-player .side-controls{
  background-image:
    linear-gradient(90deg,rgba(6,18,55,.12),rgba(15,9,50,.03) 50%,rgba(6,18,55,.12)),
    url('whisker-luna-master.webp');
  background-position:center,center;
  background-size:cover,auto 235%;
  background-repeat:no-repeat;
}
#side-player .side-controls::after{display:none}

/* Android-friendly controls: protect button hit targets and fit landscape screens. */
#side-player .side-controls{isolation:isolate;min-height:94px}
#side-player .side-controls button,
#side-player .side-controls .touch-joystick{position:relative;z-index:2}
#side-player .side-controls button{min-width:54px}
#side-player .side-hud{align-items:center;row-gap:.45rem}
#side-player .side-hud button{touch-action:manipulation}
#side-player #side-progress{line-height:1.45;overflow-wrap:anywhere}
@media (orientation:landscape) and (max-height:520px){
  #side-player{padding:clamp(4px,1.4vh,9px)}
  #side-player .side-controls{min-height:76px;margin:.25rem 0}
  #side-player .side-controls .touch-joystick{flex-basis:76px;width:76px;height:76px}
  #side-player .side-controls button{min-height:50px}
  #side-player .side-hud{margin:.2rem 0}
}

/* Keep the gamepad unobstructed: no character poster behind touch buttons. */
#side-player .side-controls,
#side-player:is(:fullscreen,.game-fullscreen-expanded) .side-controls{
  background-image:none!important;
  background:linear-gradient(110deg,#14264e 0%,#312052 55%,#142c50 100%)!important;
}

/* Reserve space for both thumbs and the HUD in tablet fullscreen. */
#side-player.game-fullscreen-expanded{position:fixed}
@media (min-width:600px) and (min-height:540px){
  #side-player[data-fullscreen-game]:is(:fullscreen,.game-fullscreen-expanded){
    display:grid;
    grid-template-rows:auto auto auto auto auto minmax(0,1fr) auto auto;
    gap:.25rem;
    overflow:auto;
  }
  #side-player[data-fullscreen-game]:is(:fullscreen,.game-fullscreen-expanded) :is(#side-rules,#side-status){
    margin:.25rem 0;
  }
  #side-player[data-fullscreen-game]:is(:fullscreen,.game-fullscreen-expanded) #side-canvas{
    width:100%;height:100%;min-height:0;max-height:none;object-fit:contain;
  }
  #side-player[data-fullscreen-game]:is(:fullscreen,.game-fullscreen-expanded) .side-controls{
    min-height:112px;justify-content:space-between;
  }
  #side-player[data-fullscreen-game]:is(:fullscreen,.game-fullscreen-expanded) .side-controls .touch-joystick{
    width:96px;height:96px;flex-basis:96px;
  }
  #side-player[data-fullscreen-game]:is(:fullscreen,.game-fullscreen-expanded) .side-controls button{
    min-height:56px;
  }
}

#side-player .side-controls button[hidden]{display:none}

#side-player .side-controls .side-action-buttons{
  display:flex;flex:0 1 auto;flex-wrap:wrap;justify-content:flex-end;
  align-items:center;gap:inherit;min-width:0;margin-left:auto;
}
#side-player .side-controls .side-action-buttons button{
  flex:0 0 auto;max-width:100%;white-space:normal;overflow-wrap:anywhere;
}


/* Game Room responsive control and rendering safeguards, shared by all 25 games. */
#side-player{min-width:0;max-width:100%;overflow-x:clip}
#side-player #side-canvas{max-width:100%;touch-action:none;image-rendering:auto}
#side-player .side-hud{min-width:0}
#side-player .side-hud button{flex-shrink:0}
#side-player .side-controls{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
#side-player .side-controls .side-action-buttons{max-width:68%;min-width:0}
#side-player .side-controls .side-action-buttons button{min-width:48px;min-height:48px}
#side-player button:focus-visible,#side-player a:focus-visible{outline:3px solid #ffe36c;outline-offset:3px}
@media(orientation:landscape) and (max-height:540px){
  #side-player{padding:clamp(4px,1vh,10px)}
  #side-player h1{font-size:clamp(16px,3.8vh,23px);margin:.15rem 0}
  #side-player #side-rules,#side-player #side-status{font-size:12px;line-height:1.25;margin:.2rem 0}
  #side-player .side-hud{gap:4px;margin:.25rem 0}
  #side-player .side-hud button{min-height:34px;padding:3px 8px;font-size:12px}
  #side-player .side-controls{margin:.25rem 0;gap:6px}
  #side-player .side-controls .touch-joystick{width:clamp(58px,17vh,80px);height:clamp(58px,17vh,80px);flex-basis:clamp(58px,17vh,80px)}
  #side-player .side-controls .side-action-buttons button{min-height:42px;padding:5px 10px;font-size:12px}
}
@media(max-width:360px){
  #side-player .side-controls .side-action-buttons{max-width:72%;gap:3px}
  #side-player .side-controls .side-action-buttons button{padding:5px;font-size:11px}
}
@media(prefers-reduced-motion:reduce){
  #side-player .side-controls button,#side-player .side-hud button{transition:none!important;animation:none!important}
}
