/* PAM V658C · Adaptación interior de Cubo rodante. Solo distribución visual. */
body[data-pam-spatial-v658c="cubo-rodante"]{min-width:0}

/* Tablet, portátil y ordenador: el tablero y las respuestas comparten pantalla sin scroll general. */
@media (min-width:761px){
  html,body[data-pam-spatial-v658c="cubo-rodante"]{height:100%;min-height:0}
  body[data-pam-spatial-v658c="cubo-rodante"]{height:100dvh;overflow:hidden}
  body[data-pam-spatial-v658c="cubo-rodante"] .app-shell{
    flex:1;min-height:0!important;height:auto!important;
    grid-template-columns:minmax(0,1fr) clamp(290px,32vw,390px)!important;
    max-width:1600px;margin-inline:auto;width:100%;align-items:stretch
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .scene-wrap{
    min-height:0!important;height:auto!important;padding:10px 12px!important;
    place-items:stretch!important;overflow:hidden
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .scene{
    width:100%;height:100%!important;min-height:0!important;max-height:none!important;
    border-radius:20px
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .answer-panel{
    order:initial!important;min-height:0!important;overflow:auto;
    border-left:1px solid #26315d!important;border-bottom:0!important;
    padding:10px!important
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .question-card{
    position:relative!important;top:auto!important;min-height:100%;
    display:flex;flex-direction:column
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .next-row{margin-top:auto;padding-top:8px}
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-dicebar .diebox{margin-left:0!important}
  body[data-pam-spatial-v658c="cubo-rodante"] .face-config.open,
  body[data-pam-spatial-v658c="cubo-rodante"] .path-config.open,
  body[data-pam-spatial-v658c="cubo-rodante"] .learn-config.open,
  body[data-pam-spatial-v658c="cubo-rodante"] .explain-config.open{
    max-height:min(52dvh,520px);overflow:auto;flex:0 0 auto
  }
}

/* Tablet: cabecera en dos filas y botones de respuesta más grandes. */
@media (min-width:761px) and (max-width:1180px){
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header{
    display:grid;grid-template-columns:auto minmax(0,1fr) auto;
    grid-template-areas:"logo meta back" "controls controls exits";
    gap:6px 10px;padding:7px 10px
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header .logo{grid-area:logo}
  body[data-pam-spatial-v658c="cubo-rodante"] .app-meta{grid-area:meta}
  body[data-pam-spatial-v658c="cubo-rodante"] .header-index-link{grid-area:back;margin:0!important}
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls{grid-area:controls;overflow-x:auto}
  body[data-pam-spatial-v658c="cubo-rodante"] .return-links{grid-area:exits;width:auto!important;justify-content:flex-end!important;margin:0!important}
  body[data-pam-spatial-v658c="cubo-rodante"] .options:not(.exam-options){grid-template-columns:repeat(3,minmax(0,1fr))}
  body[data-pam-spatial-v658c="cubo-rodante"] .answer-panel{padding:8px!important}
  body[data-pam-spatial-v658c="cubo-rodante"] .card{padding:10px}
}

/* Monitor ancho: más tablero, panel estable y lectura sin líneas demasiado largas. */
@media (min-width:1400px){
  body[data-pam-spatial-v658c="cubo-rodante"] .app-shell{
    grid-template-columns:minmax(0,1fr) 400px!important
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .scene-wrap{padding:14px 18px!important}
  body[data-pam-spatial-v658c="cubo-rodante"] .question{font-size:1.05rem}
}

/* Portátiles y tablet apaisada con poca altura. */
@media (min-width:761px) and (max-height:720px){
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header{padding-top:4px!important;padding-bottom:4px!important}
  body[data-pam-spatial-v658c="cubo-rodante"] .app-sub{display:none}
  body[data-pam-spatial-v658c="cubo-rodante"] .topbar{padding-top:3px!important;padding-bottom:3px!important}
  body[data-pam-spatial-v658c="cubo-rodante"] .answer-panel{gap:6px;padding:6px!important}
  body[data-pam-spatial-v658c="cubo-rodante"] .card{padding:8px 9px}
  body[data-pam-spatial-v658c="cubo-rodante"] .question{font-size:.88rem;line-height:1.16}
  body[data-pam-spatial-v658c="cubo-rodante"] .options{margin-top:6px;gap:4px}
  body[data-pam-spatial-v658c="cubo-rodante"] .option-btn{min-height:34px}
  body[data-pam-spatial-v658c="cubo-rodante"] .primary,
  body[data-pam-spatial-v658c="cubo-rodante"] .secondary,
  body[data-pam-spatial-v658c="cubo-rodante"] .step-action{min-height:36px;padding:7px 6px}
}

/* Móvil conserva la interfaz anterior y solo respeta el área segura inferior. */
@media (max-width:760px){
  body[data-pam-spatial-v658c="cubo-rodante"] .scene-wrap{
    padding-bottom:max(10px,calc(env(safe-area-inset-bottom) + 6px))
  }
}


/* RC3Z · Cabecera móvil clara: una sola vuelta al menú espacial y controles completos. */
@media (max-width:760px){
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header{
    display:grid!important;
    grid-template-columns:auto minmax(0,1fr) auto;
    grid-template-areas:
      "logo meta meta"
      "back back home"
      "controls controls controls";
    align-items:center;
    gap:7px 8px;
    padding:8px 10px!important;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header .logo{grid-area:logo}
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header .app-meta{grid-area:meta;min-width:0}
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header .header-index-link{
    grid-area:back;
    order:initial!important;
    width:100%;
    min-width:0;
    margin:0!important;
    padding-inline:12px;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header .return-links{
    grid-area:home;
    order:initial!important;
    width:auto!important;
    margin:0!important;
    justify-content:flex-end!important;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header .return-links a{
    min-width:74px;
    min-height:36px;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header .header-controls{
    grid-area:controls;
    order:initial!important;
    width:100%;
    display:grid;
    grid-template-columns:minmax(104px,.9fr) minmax(112px,1.08fr) minmax(92px,.9fr);
    gap:6px;
    overflow:visible;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .stepper,
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .modebox{
    width:100%;
    min-width:0;
    margin:0;
    padding:5px 6px;
    border-radius:12px;
    align-content:center;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .stepper{
    display:grid;
    grid-template-columns:26px minmax(30px,1fr) 26px;
    grid-template-rows:auto 26px;
    gap:3px 4px;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .stepper-label{
    grid-column:1/-1;
    text-align:center;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .arrow-btn,
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .step-value{
    width:100%;
    height:26px;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .modebox{
    display:grid;
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:auto 26px;
    gap:3px;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .modebox label{
    text-align:center;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .modebox select,
  body[data-pam-spatial-v658c="cubo-rodante"] #visualMode,
  body[data-pam-spatial-v658c="cubo-rodante"] #exerciseMode{
    width:100%!important;
    max-width:none!important;
    height:26px;
    padding:2px 4px;
    font-size:.70rem;
  }
}
@media (max-width:380px){
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header{
    gap:6px;
    padding-inline:7px!important;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .compact-header .header-controls{
    grid-template-columns:minmax(98px,.92fr) minmax(105px,1.05fr) minmax(86px,.86fr);
    gap:4px;
  }
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .stepper,
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .modebox{padding-inline:4px}
  body[data-pam-spatial-v658c="cubo-rodante"] .header-controls .modebox select{font-size:.66rem}
}
