/* ═════ MÓVIL: pantallas pequeñas (horizontal bajo y vertical estrecho). Se carga después de flow.css ═════ */
:root { --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); }

/* barra inferior de "Comenzar aventura" (el JS la mueve a la raíz de la pantalla en móvil para que siempre se vea) */
#fl-create > .cr-ok-fixed { position: absolute; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0 !important; padding: 8px calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(12px + var(--safe-l)); display: flex; gap: 8px; background: linear-gradient(0deg, rgba(6, 5, 14, .97) 60%, rgba(6, 5, 14, .72)); border-top: 1px solid var(--fl-line); }
#fl-create > .cr-ok-fixed .fl-btn { padding: 10px 18px; font-size: 15px; letter-spacing: 3px; }

/* ───────── HORIZONTAL BAJO (teléfono girado) ───────── */
@media (max-height: 520px) {
  /* acceso */
  #fl-auth .wrap { grid-template-columns: 1fr minmax(290px, 370px); gap: 3vw; padding: 6px calc(4vw + var(--safe-l)) 6px 4vw; overflow-y: auto; align-items: center; }
  #fl-auth .hero .fl-logo { font-size: 34px !important; } #fl-auth .hero .fl-kicker, #fl-auth .hero .fl-feats, .fl-foot { display: none !important; }
  #fl-auth .hero p.tag { margin: 8px 0 0; letter-spacing: 4px; font-size: 11px; }
  .fl-card { --c: 12px; padding: 12px 16px 12px !important; }
  .fl-card .fl-input { padding: 7px 10px; font-size: 15px; } .fl-card .fl-field { margin-bottom: 4px; } .fl-card .fl-field span { font-size: 10px; }
  .fl-card .fl-tab { padding: 6px 4px; font-size: 12px; }
  .fl-card .fl-btn.big, .fl-card .fl-btn { padding: 9px 14px; font-size: 14px; letter-spacing: 3px; } .fl-or { margin: 6px 0 4px; }
  /* tutorial */
  #fl-coach { width: min(500px, 56vw); top: 6px; } #fl-coach .cut { padding: 7px 12px 8px; }
  .coach-title { font-size: 15px; margin: 0 0 2px; } .coach-text { font-size: 13px; line-height: 1.3; } .coach-top { font-size: 10px; letter-spacing: 2px; margin-bottom: 2px; }
  .coach-bar { margin-top: 6px; } .coach-steps { margin-top: 5px; } .coach-steps i { width: 16px; } .coach-skip { font-size: 10px; }
  /* campo de pruebas */
  #fl-lab { left: calc(6px + var(--safe-l)); top: 50px; bottom: auto; width: 150px; }
  #fl-lab .cut { padding: 8px 8px; gap: 4px; } #fl-lab h3, #fl-lab .sub { display: none; }
  .lab-cls { padding: 4px 6px; grid-template-columns: 24px 1fr; gap: 6px; } .lab-cls .ico { font-size: 16px; } .lab-cls b { font-size: 11.5px; letter-spacing: 1px; } .lab-cls small { display: none; }
  .lab-actions .fl-btn { padding: 5px 8px; font-size: 10px; }
  #fl-ready { bottom: auto; top: 8px; left: 50%; } #fl-ready .hint { display: none; } #fl-ready .fl-btn.big { padding: 8px 16px; font-size: 13px; letter-spacing: 2px; }
  /* creador: vista previa a la izquierda, opciones a la derecha (todo desplazable) */
  .cr-head { padding: 4px 12px 0; } .cr-head h2 { font-size: 17px; } .cr-head .fl-mut { display: none; }
  #fl-create .wrap { grid-template-columns: 34% 1fr; grid-template-rows: max-content max-content; gap: 8px 10px; padding: 4px calc(10px + var(--safe-r)) 74px calc(10px + var(--safe-l)); overflow-y: auto; align-content: start; }
  #fl-create .wrap > .cr-stage { grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 0; height: calc(100vh - 118px); min-height: 0; }
  #fl-create .wrap > .cr-col:first-child { grid-column: 2; grid-row: 1; } #fl-create .wrap > .cr-col:last-child { grid-column: 2; grid-row: 2; }
  .cr-col { overflow: visible !important; min-height: min-content !important; flex: none; padding: 10px 12px; gap: 8px; --c: 10px; } .cr-col .fl-input { padding: 7px 10px; font-size: 15px; }
  .cr-plate b { font-size: 17px; } .cr-hint { display: none; } .cr-cls { padding: 6px 8px; } .cr-cls small { display: none; } .cr-info { font-size: 12.5px; } .sw { width: 28px !important; height: 28px !important; }
  /* menú principal: lista a la izquierda, modos a la derecha */
  .hub .hb-top { padding: 4px calc(10px + var(--safe-r)) 4px calc(10px + var(--safe-l)); gap: 6px; } .hb-mini-logo { font-size: 13px; } #mm-clock { display: none; } .hb-chip { padding: 4px 8px; font-size: 11.5px; letter-spacing: .5px; clip-path: none; }
  .hub .hb-main { grid-template-columns: 232px 1fr; gap: 10px; padding: 2px calc(10px + var(--safe-r)) 4px calc(10px + var(--safe-l)); overflow: hidden; }
  .hb-center, .hub .hb-foot { display: none; }
  .hb-left { overflow-y: auto; gap: 6px; } .hb-left > * { flex: none; } .hb-hero { padding: 8px 10px; } .hb-hero .nm { font-size: 17px; } .hb-hero .cl { font-size: 10px; margin: 0 0 4px; } .hb-stats { display: none; } .hb-xp { height: 12px; }
  .hb-nav { gap: 4px; } .hb-nb { padding: 6px 10px; gap: 8px; grid-template-columns: 24px 1fr auto; } .hb-nb b { font-size: 12.5px; letter-spacing: 2px; } .hb-nb small { display: none; } .hb-nb:hover { transform: none; }
  .hb-right { overflow-y: auto; justify-content: flex-start; gap: 8px; padding-right: 2px; } .hb-dest-h { font-size: 10px; }
  .hb-mode .in { grid-template-columns: 40px 1fr; gap: 10px; padding: 9px 12px; } .hb-mode .big { width: 40px; height: 40px; font-size: 22px; } .hb-mode h3 { font-size: 15px; letter-spacing: 1.5px; } .hb-mode p { font-size: 11.5px; margin: 1px 0 4px; } .risk { font-size: 10px; letter-spacing: 1px; padding: 2px 6px; } .hb-mode:hover { transform: none; }
  /* equipo y banco */
  .hb-panel { padding: 4px calc(8px + var(--safe-r)) 4px calc(8px + var(--safe-l)); } .hb-pin { padding: 8px 12px; } .hb-ph { margin-bottom: 6px; } .hb-ph h2 { font-size: 18px; } .hb-x { width: 32px; height: 32px; }
  .hb-warn { padding: 4px 8px; font-size: 11.5px; margin-bottom: 6px; } .hb-tab { padding: 6px 12px; font-size: 12px; }
  .gp-grid { grid-template-columns: 215px 1fr; gap: 10px; } .gp-stage { display: none; } .gp-left { overflow-y: auto; }
  /* ventana de modo de juego */
  #mode-select-modal .mode-select-card { max-height: 98vh; width: 96vw; } #mode-select-modal .mode-choice-card { padding: 10px 14px 12px; } #mode-select-modal .mode-desc { font-size: 12px; line-height: 1.35; }
  #mode-select-modal .btn-launch-mode { position: sticky; bottom: 0; font-size: 15px; padding: 10px 16px; letter-spacing: 3px; z-index: 5; }
  .fl-modal .cut { padding: 14px 18px; } .fl-modal h3 { font-size: 16px; }
}

/* ───────── VERTICAL ESTRECHO (teléfono de pie) ───────── */
@media (max-width: 900px) and (orientation: portrait) {
  #fl-auth .wrap { grid-template-columns: 1fr; padding: 3vh 5vw; gap: 18px; overflow-y: auto; align-content: start; grid-template-rows: none; } #fl-auth .hero .fl-logo { font-size: 40px !important; } #fl-auth .hero .fl-feats { display: none; } #fl-auth .hero p.tag { margin: 8px 0 0; letter-spacing: 5px; }
  .fl-card { padding: 20px 18px 18px !important; }
  #fl-coach { width: 94vw; top: 8px; } #fl-coach .cut { padding: 10px 14px; } .coach-title { font-size: 17px; } .coach-text { font-size: 14px; }
  #fl-lab { left: 6px; right: 6px; top: auto; bottom: 150px; width: auto; } #fl-lab .cut { flex-direction: row; flex-wrap: wrap; padding: 6px; } #fl-lab h3, #fl-lab .sub { display: none; } .lab-cls small { display: none; } .lab-cls { grid-template-columns: 22px auto; padding: 5px 8px; } .lab-cls b { font-size: 11px; letter-spacing: 1px; } .lab-actions { margin: 0; }
  #fl-ready { bottom: 215px; width: 92vw; } #fl-ready .hint { font-size: 12px; } #fl-ready .fl-btn.big { padding: 10px 14px; font-size: 14px; letter-spacing: 2px; }
  .cr-head { padding: 10px 14px 0; flex-direction: column; gap: 2px; align-items: flex-start; } .cr-head h2 { font-size: 20px; } .cr-head .fl-mut { font-size: 10px !important; letter-spacing: 2px !important; }
  #fl-create .wrap { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: max-content; gap: 10px; padding: 4px 10px 84px; overflow-y: auto; align-content: start; }
  #fl-create .wrap > .cr-stage { order: -1; position: sticky; top: 0; z-index: 4; height: 36vh; min-height: 220px; background: linear-gradient(180deg, #090714 78%, rgba(9, 7, 20, 0)); }
  .cr-col { overflow: visible !important; min-height: min-content !important; flex: none; padding: 12px 14px; } .cr-hint { display: none; } .cr-plate b { font-size: 20px; }
  .hub .hb-top { padding: 8px 12px; flex-wrap: wrap; gap: 6px; } .hb-mini-logo { font-size: 14px; } #mm-clock { display: none; } .hb-chip { padding: 5px 9px; font-size: 12px; clip-path: none; }
  .hub .hb-main { display: flex; flex-direction: column; gap: 14px; padding: 4px 12px 10px; overflow-y: auto; }
  .hb-center, .hub .hb-foot { display: none; } .hb-right { order: -1; justify-content: flex-start; flex: none; } .hb-left { flex: none; } .hb-stats { display: none; } .hb-nb:hover, .hb-mode:hover { transform: none; }
  .hb-mode .in { padding: 12px 14px; grid-template-columns: 48px 1fr; gap: 12px; } .hb-mode .big { width: 48px; height: 48px; font-size: 26px; }
  .hb-panel { padding: 6px; } .hb-pin { padding: 10px 12px; } .hb-ph h2 { font-size: 20px; }
  .gp-grid { grid-template-columns: 1fr; overflow-y: auto; gap: 10px; } .gp-stage { height: 170px; }
  #mode-select-modal .mode-select-card { width: 96vw; max-height: 96vh; } #mode-select-modal .mode-choice-card { padding: 16px 16px 14px; } #mode-select-modal .btn-launch-mode { position: sticky; bottom: 0; z-index: 5; }
}

/* nunca desplazamiento horizontal de la página; y con barra fija inferior el contenido deja espacio libre */
html, body { overflow-x: hidden; max-width: 100vw; }
#fl-create:has(> .cr-ok-fixed) .wrap { padding-bottom: 80px; }
@media (min-height: 521px) and (min-width: 901px) { #fl-create:has(> .cr-ok-fixed) .wrap { overflow-y: auto; } }
